2016-06-27 19:54:50 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-11-16 19:12:36 +01:00
|
|
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
2016-06-24 00:29:55 +02:00
|
|
|
|
2016-06-27 19:54:50 +02:00
|
|
|
function SignupForm(props) {
|
2016-09-02 20:51:30 +02:00
|
|
|
const { fields: { username, email, password, confirmPassword }, handleSubmit, submitting, invalid, pristine } = props;
|
2016-06-27 19:54:50 +02:00
|
|
|
return (
|
2016-12-19 22:49:37 +01:00
|
|
|
<form className="form" onSubmit={handleSubmit(props.signUpUser.bind(this, props.previousPath))}>
|
2016-12-16 00:43:58 +01:00
|
|
|
<p className="form__field">
|
|
|
|
<label htmlFor="username" className="form__label">User Name</label>
|
2016-06-27 19:54:50 +02:00
|
|
|
<input
|
2016-12-16 00:43:58 +01:00
|
|
|
className="form__input"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="username"
|
2016-06-27 19:54:50 +02:00
|
|
|
type="text"
|
2016-12-16 00:43:58 +01:00
|
|
|
id="username"
|
2016-11-16 19:12:36 +01:00
|
|
|
{...domOnlyProps(username)}
|
2016-06-27 19:54:50 +02:00
|
|
|
/>
|
2016-09-02 19:05:42 +02:00
|
|
|
{username.touched && username.error && <span className="form-error">{username.error}</span>}
|
2016-06-27 19:54:50 +02:00
|
|
|
</p>
|
2016-12-16 00:43:58 +01:00
|
|
|
<p className="form__field">
|
|
|
|
<label htmlFor="email" className="form__label">Email</label>
|
2016-06-27 19:54:50 +02:00
|
|
|
<input
|
2016-12-16 00:43:58 +01:00
|
|
|
className="form__input"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="email"
|
2016-06-27 19:54:50 +02:00
|
|
|
type="text"
|
2016-12-16 00:43:58 +01:00
|
|
|
id="email"
|
2016-11-16 19:12:36 +01:00
|
|
|
{...domOnlyProps(email)}
|
2016-06-27 19:54:50 +02:00
|
|
|
/>
|
2016-09-02 19:05:42 +02:00
|
|
|
{email.touched && email.error && <span className="form-error">{email.error}</span>}
|
2016-06-27 19:54:50 +02:00
|
|
|
</p>
|
2016-12-16 00:43:58 +01:00
|
|
|
<p className="form__field">
|
|
|
|
<label htmlFor="password" className="form__label">Password</label>
|
2016-06-27 19:54:50 +02:00
|
|
|
<input
|
2016-12-16 00:43:58 +01:00
|
|
|
className="form__input"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="password"
|
2016-06-27 19:54:50 +02:00
|
|
|
type="password"
|
2016-12-16 00:43:58 +01:00
|
|
|
id="password"
|
2016-11-16 19:12:36 +01:00
|
|
|
{...domOnlyProps(password)}
|
2016-06-27 19:54:50 +02:00
|
|
|
/>
|
2016-09-02 19:05:42 +02:00
|
|
|
{password.touched && password.error && <span className="form-error">{password.error}</span>}
|
2016-06-27 19:54:50 +02:00
|
|
|
</p>
|
2016-12-16 00:43:58 +01:00
|
|
|
<p className="form__field">
|
|
|
|
<label htmlFor="confirm password" className="form__label">Confirm Password</label>
|
2016-06-27 19:54:50 +02:00
|
|
|
<input
|
2016-12-16 00:43:58 +01:00
|
|
|
className="form__input"
|
2016-06-27 19:54:50 +02:00
|
|
|
type="password"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="confirm password"
|
2016-12-16 00:43:58 +01:00
|
|
|
id="confirm password"
|
2016-11-16 19:12:36 +01:00
|
|
|
{...domOnlyProps(confirmPassword)}
|
2016-06-27 19:54:50 +02:00
|
|
|
/>
|
2017-06-06 04:33:32 +02:00
|
|
|
{
|
|
|
|
confirmPassword.touched &&
|
|
|
|
confirmPassword.error &&
|
|
|
|
<span className="form-error">{confirmPassword.error}</span>
|
|
|
|
}
|
2016-06-27 19:54:50 +02:00
|
|
|
</p>
|
2016-09-02 20:51:30 +02:00
|
|
|
<input type="submit" disabled={submitting || invalid || pristine} value="Sign Up" aria-label="sign up" />
|
2016-06-27 19:54:50 +02:00
|
|
|
</form>
|
|
|
|
);
|
2016-06-24 00:29:55 +02:00
|
|
|
}
|
|
|
|
|
2016-06-27 19:54:50 +02:00
|
|
|
SignupForm.propTypes = {
|
|
|
|
fields: PropTypes.shape({
|
2016-08-30 05:26:45 +02:00
|
|
|
username: PropTypes.object.isRequired,
|
|
|
|
email: PropTypes.object.isRequired,
|
|
|
|
password: PropTypes.object.isRequired,
|
|
|
|
confirmPassword: PropTypes.object.isRequired
|
2016-06-27 19:54:50 +02:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
2016-09-02 20:51:30 +02:00
|
|
|
signUpUser: PropTypes.func.isRequired,
|
|
|
|
submitting: PropTypes.bool,
|
|
|
|
invalid: PropTypes.bool,
|
2016-11-10 22:13:00 +01:00
|
|
|
pristine: PropTypes.bool,
|
|
|
|
previousPath: PropTypes.string.isRequired
|
2016-06-27 19:54:50 +02:00
|
|
|
};
|
|
|
|
|
2017-02-22 20:29:35 +01:00
|
|
|
SignupForm.defaultProps = {
|
|
|
|
submitting: false,
|
|
|
|
pristine: true,
|
|
|
|
invalid: false
|
|
|
|
};
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
export default SignupForm;
|