2016-06-27 19:54:50 +02:00
|
|
|
import React, { PropTypes } from 'react';
|
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 (
|
|
|
|
<form className="signup-form" onSubmit={handleSubmit(props.signUpUser.bind(this))}>
|
|
|
|
<p className="signup-form__field">
|
|
|
|
<input
|
|
|
|
className="signup-form__username-input"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="username"
|
2016-06-27 19:54:50 +02:00
|
|
|
type="text"
|
|
|
|
placeholder="Username"
|
|
|
|
{...username}
|
|
|
|
/>
|
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>
|
|
|
|
<p className="signup-form__field">
|
|
|
|
<input
|
|
|
|
className="signup-form__email-input"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="email"
|
2016-06-27 19:54:50 +02:00
|
|
|
type="text"
|
|
|
|
placeholder="Email"
|
|
|
|
{...email}
|
|
|
|
/>
|
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>
|
|
|
|
<p className="signup-form__field">
|
|
|
|
<input
|
|
|
|
className="signup-form__password-input"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="password"
|
2016-06-27 19:54:50 +02:00
|
|
|
type="password"
|
|
|
|
placeholder="Password"
|
|
|
|
{...password}
|
|
|
|
/>
|
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>
|
|
|
|
<p className="signup-form__field">
|
|
|
|
<input
|
|
|
|
className="signup-form__confirm-password-input"
|
|
|
|
type="password"
|
|
|
|
placeholder="Confirm Password"
|
2016-08-01 03:38:46 +02:00
|
|
|
aria-label="confirm password"
|
2016-06-27 19:54:50 +02:00
|
|
|
{...confirmPassword}
|
|
|
|
/>
|
2016-09-02 19:05:42 +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,
|
|
|
|
pristine: PropTypes.bool
|
2016-06-27 19:54:50 +02:00
|
|
|
};
|
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
export default SignupForm;
|