<commit_before>import React from "react";
import {connect} from "react-redux";
import FlatButton from "material-ui/FlatButton";
import FormsyText from "formsy-material-ui/lib/FormsyText";
import {login} from "../../../actions/userActions";

@connect()
export default class Login extends React.Component {

  constructor() {
    super();
    this.state = {
      canSubmit: false,
    };
  };

  enableButton = () => {
    this.setState({
      canSubmit: true,
    });
  };

  disableButton = () => {
    this.setState({
      canSubmit: false,
    });
  };

  submit = () => {
    this.props.dispatch(login(this.refs.email.getValue(), this.refs.password.getValue()));
  };

  render() {
    return (
      <Formsy.Form
        onValid={this.enableButton}
        onInvalid={this.disableButton}
        onValidSubmit={this.submit}
        onInvalidSubmit={this.notifyFormError}
      >
        <FormsyText
          ref="email" type="text" name="email"
          required
          hintText="email"
        />
        <FormsyText
          ref="password" type="password" name="password"
          required
          hintText="password"
        />
        <FlatButton label="Login" type="submit"
                    disabled={!this.state.canSubmit}
        />

      </Formsy.Form>
    );
  }
}<commit_msg>Using formsy for form validation<commit_after>import React from "react";
import {connect} from "react-redux";
import FlatButton from "material-ui/FlatButton";
import FormsyText from "formsy-material-ui/lib/FormsyText";
import {login} from "../../../actions/userActions";

@connect()
export default class Login extends React.Component {

  constructor() {
    super();
    this.state = {
      canSubmit: false,
    };
  };

  enableButton = () => {
    this.setState({
      canSubmit: true,
    });
  };

  disableButton = () => {
    this.setState({
      canSubmit: false,
    });
  };

  submit = () => {
    this.props.dispatch(login(this.refs.email.getValue(), this.refs.password.getValue()));
  };

  render() {
    return (
      <Formsy.Form
        onValid={this.enableButton}
        onInvalid={this.disableButton}
        onValidSubmit={this.submit}
      >
        <FormsyText
          ref="email" type="text" name="email"
          required
          hintText="email"
        />
        <FormsyText
          ref="password" type="password" name="password"
          required
          hintText="password"
        />
        <FlatButton label="Login" type="submit"
                    disabled={!this.state.canSubmit}
        />
      </Formsy.Form>
    );
  }
}
{'fraction_non_alphanumeric': 0.1480046493607129, 'fraction_numerical': 0.0, 'mean_word_length': 2.235588972431078, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7143697', 'n_tokens_mistral': 771, 'n_tokens_neox': 756, 'n_words': 137}