<commit_before>import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import * as actions from '../../actions';

// validations

class SignUpPage extends Component {

	onFormSubmit({ username, email, password }) {
		this.props.signUpUser({ username, email, password }, this.props.history);
	}

	renderField(field) {
		return (
			<fieldset className="form-group">
				<label htmlFor={field.name}>{field.label}</label>
				<input
					className="form-control"
					type={field.type}
					{...field.input}
				/>
				{field.meta.touched && field.meta.error && !field.meta.active ? (
					<div className="errorMessage">
						{field.meta.error || field.meta.warning}
					</div>
				) : null}
			</fieldset>
		);
	}

	renderAlert() {
		const message = this.props.errorMessage;

		return message ? (
			<div className="alert alert-danger">
				<strong>Oops!</strong> {message}
			</div>
		) : null;
	}

	render() {
		const { handleSubmit } = this.props;
		return (
			<div>
				<h2>
					Please Register!
				</h2>
				<form onSubmit={handleSubmit(values => this.onFormSubmit(values))}>
					<Field
						label="Username"
						name="username"
						type="text"
						component={this.renderField}
					/>
					<Field
						label="Email (optional)"
						name="email"
						type="text"
						component={this.renderField}
					/>
					<Field
						label="Password"
						type="password"
						name="password"
						component={this.renderField}
					/>
					<Field
						label="Confirm Password"
						type="password"
						name="passwordConfirm"
						component={this.renderField}
					/>
				{this.renderAlert()}
					<button type="submit" className="btn btn-primary">Register</button>
				</form>
			</div>
		);
	}
}

const validate = (values) => {
	const errors = {};

	if (!values.username) {
		errors.username = 'Username is required!';
	}
	if ((values.email) && !(/.+@.+\..+/.test(values.password))) {
		errors.email = 'Please enter a valid email address!';
	}
	if (!values.password) {
		errors.password = 'Password is required for registration.';
	}
	if (!values.passwordConfirm) {
		errors.passwordConfirm = 'Please re-enter the password.';
	}
	if (values.password !== values.passwordConfirm) {
		errors.passwordConfirm = 'Check your password - entries do not match!';
	}
	return errors;
};

const mapStateToProps = state => (
	{
		errorMessage: state.auth.error
	}
);

export default reduxForm(<commit_msg>fix bad reference in test method<commit_after>import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { connect } from 'react-redux';
import * as actions from '../../actions';

// validations

class SignUpPage extends Component {

	onFormSubmit({ username, email, password }) {
		this.props.signUpUser({ username, email, password }, this.props.history);
	}

	renderField(field) {
		return (
			<fieldset className="form-group">
				<label htmlFor={field.name}>{field.label}</label>
				<input
					className="form-control"
					type={field.type}
					{...field.input}
				/>
				{field.meta.touched && field.meta.error && !field.meta.active ? (
					<div className="errorMessage">
						{field.meta.error || field.meta.warning}
					</div>
				) : null}
			</fieldset>
		);
	}

	renderAlert() {
		const message = this.props.errorMessage;

		return message ? (
			<div className="alert alert-danger">
				<strong>Oops!</strong> {message}
			</div>
		) : null;
	}

	render() {
		const { handleSubmit } = this.props;
		return (
			<div>
				<h2>
					Please Register!
				</h2>
				<form onSubmit={handleSubmit(values => this.onFormSubmit(values))}>
					<Field
						label="Username"
						name="username"
						type="text"
						component={this.renderField}
					/>
					<Field
						label="Email (optional)"
						name="email"
						type="text"
						component={this.renderField}
					/>
					<Field
						label="Password"
						type="password"
						name="password"
						component={this.renderField}
					/>
					<Field
						label="Confirm Password"
						type="password"
						name="passwordConfirm"
						component={this.renderField}
					/>
					{this.renderAlert()}
					<button type="submit" className="btn btn-primary">Register</button>
				</form>
			</div>
		);
	}
}

const validate = (values) => {
	const errors = {};

	if (!values.username) {
		errors.username = 'Username is required!';
	}
	if ((values.email) && !(/.+@.+\..+/.test(values.email))) {
		errors.email = 'Please enter a valid email address!';
	}
	if (!values.password) {
		errors.password = '<PASSWORD>.';
	}
	if (!values.passwordConfirm) {
		errors.passwordConfirm = 'Please re-enter the password.';
	}
	if (values.password !== values.passwordConfirm) {
		errors.passwordConfirm = 'Check your password - entries do not match!';
	}
	return errors;
};

const mapStateToProps = state => (
	{
		errorMessage: state.auth.error
	}
);

export default reduxForm(
{'fraction_non_alphanumeric': 0.16027452563584982, 'fraction_numerical': 0.0008074283407347598, 'mean_word_length': 2.954509177972865, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 56, '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': '4900823', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1566, 'n_words': 330}