<commit_before>import React from 'react';
import Form from 'components/Form';
import { reduxForm } from 'redux-form';
import { Input, ExternalLoginButton } from 'components';
import { register } from 'redux/modules/account';
import { clearAuthentication as clearExternalAuthentication } from 'redux/modules/externalLogin';
import { Button, Col } from 'react-bootstrap';

class RegisterForm extends Form {
  modifyValues(values) {
    return {
      ...values,
      linkExternalLogin: this.props.externalLogin.externalAuthenticated
    };
  }
  onRemoveExternalAuthClick(action) {
    return (event) => {
      event.preventDefault();
      action();
    };
  }
  render() {
    const {
      fields: { userName, email, password, passwordConfirm },
      externalLogin: { externalAuthenticated, externalAuthenticatedProvider }
    } = this.props;
    return (
      <form onSubmit={this.handleApiSubmit(register)} className="form-horizontal">
        {this.renderGlobalErrorList()}
        {externalAuthenticated &&
          <div className="form-group">
            <Col md={2} />
            <Col md={10}>
              <ExternalLoginButton
                scheme={externalAuthenticatedProvider.scheme}
                text={'Registering with ' + externalAuthenticatedProvider.displayName}
                />
              {' '}
              <Button onClick={this.onRemoveExternalAuthClick(this.props.clearExternalAuthentication)}>
                Cancel
              </Button>
            </Col>
          </div>
        }
        <Input field={userName} label="<NAME>" />
        <Input field={email} label="Email" />
        <Input field={password} type="password" label="Password" />
        <Input field={passwordConfirm} type="password" label="Confirm" />
        <div className="form-group">
          <div className="col-md-offset-2 col-md-10">
            <button type="submit" className="btn btn-default">Register</button>
          </div>
        </div>
      </form>
    );
  }
}

RegisterForm = reduxForm({
  form: 'register',
  fields: ['userName', 'email', 'password', 'passwordConfirm']
},
(state) => ({
  externalLogin: state.externalLogin,
  initialValues: { userName: state.externalLogin.proposedUserName, email: state.externalLogin.proposedEmail }
}),
{ clearExternalAuthentication }
)(RegisterForm);

export default RegisterForm;<commit_msg>Fixed a bug where the server rendered different values than the client.<commit_after>import React from 'react';
import Form from 'components/Form';
import { reduxForm } from 'redux-form';
import { Input, ExternalLoginButton } from 'components';
import { register } from 'redux/modules/account';
import { clearAuthentication as clearExternalAuthentication } from 'redux/modules/externalLogin';
import { Button, Col } from 'react-bootstrap';

class RegisterForm extends Form {
  modifyValues(values) {
    return {
      ...values,
      linkExternalLogin: this.props.externalLogin.externalAuthenticated
    };
  }
  onRemoveExternalAuthClick(action) {
    return (event) => {
      event.preventDefault();
      action();
    };
  }
  render() {
    const {
      fields: { userName, email, password, passwordConfirm },
      externalLogin: { externalAuthenticated, externalAuthenticatedProvider }
    } = this.props;
    return (
      <form onSubmit={this.handleApiSubmit(register)} className="form-horizontal">
        {this.renderGlobalErrorList()}
        {externalAuthenticated &&
          <div className="form-group">
            <Col md={2} />
            <Col md={10}>
              <ExternalLoginButton
                scheme={externalAuthenticatedProvider.scheme}
                text={'Registering with ' + externalAuthenticatedProvider.displayName}
                />
              {' '}
              <Button onClick={this.onRemoveExternalAuthClick(this.props.clearExternalAuthentication)}>
                Cancel
              </Button>
            </Col>
          </div>
        }
        <Input field={userName} label="User name" />
        <Input field={email} label="Email" />
        <Input field={password} type="password" label="Password" />
        <Input field={passwordConfirm} type="password" label="Confirm" />
        <div className="form-group">
          <div className="col-md-offset-2 col-md-10">
            <button type="submit" className="btn btn-default">Register</button>
          </div>
        </div>
      </form>
    );
  }
}

RegisterForm = reduxForm({
  form: 'register',
  fields: ['userName', 'email', 'password', '<PASSWORD>']
},
(state) => ({
  externalLogin: state.externalLogin,
  initialValues: { userName: (state.externalLogin.proposedUserName ? state.externalLogin.proposedUserName : ''), email: (state.externalLogin.proposedEmail ? state.externalLogin.proposedEmail : '') }
}),
{ clearExternalAuthentication }
)(RegisterForm);

export default RegisterForm;
{'fraction_non_alphanumeric': 0.13020299364363339, 'fraction_numerical': 0.002460529013737954, 'mean_word_length': 2.9024, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 49, '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': '1788839', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1290, 'n_words': 269}