<commit_before>import React from 'react';

import Formsy from 'formsy-react';
import FormsyText from 'formsy-material-ui/lib/FormsyText';
import FormsyToggle from 'formsy-material-ui/lib/FormsyToggle';
import RaisedButton from 'material-ui/lib/raised-button';
import Paper from 'material-ui/lib/paper';

import ClassPaper from './ClassPaper';

import '../styles/partials/_HomeForm';

Formsy.addValidationRule('isMoreThan', (values, value, otherField) => (
  Number(value) > Number(values[otherField])
));

const errorMessages = {
  numericError: 'Please provide a number.',
};

const HomeForm = props => (
  <Formsy.Form
    id="Form"
    onValid={props.toggleSubmit.bind(this, true)}
    onInvalid={props.toggleSubmit.bind(this, false)}
  >
    <div className="row">
      <div className="col-xs-12 col-md-8">
        <ClassPaper
          classes={props.classes}
          formProps={props.classFormProps}
          onUserInteraction={props.toggleDialog}
          changeSubmit={props.setClassSubmit}
          addClass={props.addClass}
          selectClass={props.selectClass}
          removeClass={props.removeClass}
          includeClasses={props.includeClasses}
        />
      </div>
      <div className="col-xs-12 col-md-4 first-md">
        <Paper zDepth={1} className="PaperContainer" id="InputContainer">
          <FormsyText
            name="currentCredits"
            required
            hintText="How many credits do you have?"
            floatingLabelText="Current Credits"
            validations="isNumeric"
            validationError={errorMessages.numericError}
          />
          <FormsyText
            name="targetCredits"
            required
            hintText="What is your credit target?"
            floatingLabelText="Target Credits"
            validations="isNumeric,isMoreThan:currentCredits"
            validationError={errorMessages.numericError}
          />
          <FormsyText
            name="currentGPA"
            required
            hintText="What is your current GPA?"
            floatingLabelText="Current GPA"
            validations="isNumeric"
            validationError={errorMessages.numericError}
          />
          <FormsyText
            name="goalGPA"<commit_msg>Target credits now validates against current credits added to the total class credits.<commit_after>import React from 'react';

import Formsy from 'formsy-react';
import FormsyText from 'formsy-material-ui/lib/FormsyText';
import FormsyToggle from 'formsy-material-ui/lib/FormsyToggle';
import RaisedButton from 'material-ui/lib/raised-button';
import Paper from 'material-ui/lib/paper';

import { getTotalCreditsFromClasses } from '../controller/gpaTools.js';
import ClassPaper from './ClassPaper';

import '../styles/partials/_HomeForm';

Formsy.addValidationRule('isMoreThanWith', (values, value, array) => {
  const inputs = array.substring(1, array.length - 1).split(',');
  return Number(value) > (Number(values[inputs[0]]) + Number(inputs[1]));
});

const errorMessages = {
  numericError: 'Please provide a number.',
};

const HomeForm = props => (
  <Formsy.Form
    id="Form"
    onValid={props.toggleSubmit.bind(this, true)} // eslint-disable-line react/jsx-no-bind
    onInvalid={props.toggleSubmit.bind(this, false)} // eslint-disable-line react/jsx-no-bind
  >
    <div className="row">
      <div className="col-xs-12 col-md-8">
        <ClassPaper
          classes={props.classes}
          formProps={props.classFormProps}
          onUserInteraction={props.toggleDialog}
          changeSubmit={props.setClassSubmit}
          addClass={props.addClass}
          selectClass={props.selectClass}
          removeClass={props.removeClass}
          includeClasses={props.includeClasses}
        />
      </div>
      <div className="col-xs-12 col-md-4 first-md">
        <Paper zDepth={1} className="PaperContainer" id="InputContainer">
          <FormsyText
            name="currentCredits"
            required
            hintText="How many credits do you have?"
            floatingLabelText="Current Credits"
            validations="isNumeric"
            validationError={errorMessages.numericError}
          />
          <FormsyText
            name="targetCredits"
            required
            hintText="What is your credit target?"
            floatingLabelText="Target Credits"
            validations=
            {`isNumeric,isMoreThanWith:[currentCredits,${getTotalCreditsFromClasses(props.classes)}]`} // eslint-disable-line max-len
            validationError={errorMessages.numericError}
          />
          <FormsyText
            name="currentGPA"
            required
            hintText="What is your current GPA?"
            floatingLabelText="Current GPA"
            validations="isNumeric"
            validationError={errorMessages.numericError}
          />
          <FormsyText
            name="goalGPA"
{'fraction_non_alphanumeric': 0.11358075040783035, 'fraction_numerical': 0.00367047308319739, 'mean_word_length': 2.6360266864343957, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, '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': '7190630', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1327, 'n_words': 257}