2018-02-07 18:06:07 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2020-08-17 09:51:59 +00:00
|
|
|
import { withTranslation } from 'react-i18next';
|
2020-04-19 20:45:09 +00:00
|
|
|
|
2016-11-16 18:12:36 +00:00
|
|
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
2020-04-19 20:45:09 +00:00
|
|
|
import Button from '../../../common/Button';
|
2016-06-23 22:29:55 +00:00
|
|
|
|
2016-06-27 17:54:50 +00:00
|
|
|
function SignupForm(props) {
|
2018-05-05 00:22:39 +00:00
|
|
|
const {
|
|
|
|
fields: {
|
2021-01-27 21:14:21 +00:00
|
|
|
username, /* email, */ password, confirmPassword
|
2020-07-24 21:11:10 +00:00
|
|
|
},
|
|
|
|
handleSubmit,
|
|
|
|
submitting,
|
|
|
|
invalid,
|
|
|
|
pristine,
|
2018-05-05 00:22:39 +00:00
|
|
|
} = props;
|
2016-06-27 17:54:50 +00:00
|
|
|
return (
|
2020-07-24 21:11:10 +00:00
|
|
|
<form
|
|
|
|
className="form"
|
|
|
|
onSubmit={handleSubmit(props.signUpUser.bind(this, props.previousPath))}
|
|
|
|
>
|
2016-12-15 23:43:58 +00:00
|
|
|
<p className="form__field">
|
2020-08-17 09:51:59 +00:00
|
|
|
<label htmlFor="username" className="form__label">{props.t('SignupForm.Title')}</label>
|
2016-06-27 17:54:50 +00:00
|
|
|
<input
|
2016-12-15 23:43:58 +00:00
|
|
|
className="form__input"
|
2020-08-17 09:51:59 +00:00
|
|
|
aria-label={props.t('SignupForm.TitleARIA')}
|
2016-06-27 17:54:50 +00:00
|
|
|
type="text"
|
2016-12-15 23:43:58 +00:00
|
|
|
id="username"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(username)}
|
2016-06-27 17:54:50 +00:00
|
|
|
/>
|
2020-07-24 21:11:10 +00:00
|
|
|
{username.touched && username.error && (
|
|
|
|
<span className="form-error">{username.error}</span>
|
|
|
|
)}
|
2016-06-27 17:54:50 +00:00
|
|
|
</p>
|
2021-01-27 21:14:21 +00:00
|
|
|
{/* <p className="form__field">
|
2020-08-17 09:51:59 +00:00
|
|
|
<label htmlFor="email" className="form__label">{props.t('SignupForm.Email')}</label>
|
2016-06-27 17:54:50 +00:00
|
|
|
<input
|
2016-12-15 23:43:58 +00:00
|
|
|
className="form__input"
|
2020-08-17 09:51:59 +00:00
|
|
|
aria-label={props.t('SignupForm.EmailARIA')}
|
2016-06-27 17:54:50 +00:00
|
|
|
type="text"
|
2016-12-15 23:43:58 +00:00
|
|
|
id="email"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(email)}
|
2016-06-27 17:54:50 +00:00
|
|
|
/>
|
2020-07-24 21:11:10 +00:00
|
|
|
{email.touched && email.error && (
|
|
|
|
<span className="form-error">{email.error}</span>
|
|
|
|
)}
|
2021-01-27 21:14:21 +00:00
|
|
|
</p> */}
|
2016-12-15 23:43:58 +00:00
|
|
|
<p className="form__field">
|
2020-08-17 09:51:59 +00:00
|
|
|
<label htmlFor="password" className="form__label">{props.t('SignupForm.Password')}</label>
|
2016-06-27 17:54:50 +00:00
|
|
|
<input
|
2016-12-15 23:43:58 +00:00
|
|
|
className="form__input"
|
2020-08-17 09:51:59 +00:00
|
|
|
aria-label={props.t('SignupForm.PasswordARIA')}
|
2016-06-27 17:54:50 +00:00
|
|
|
type="password"
|
2016-12-15 23:43:58 +00:00
|
|
|
id="password"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(password)}
|
2016-06-27 17:54:50 +00:00
|
|
|
/>
|
2020-07-24 21:11:10 +00:00
|
|
|
{password.touched && password.error && (
|
|
|
|
<span className="form-error">{password.error}</span>
|
|
|
|
)}
|
2016-06-27 17:54:50 +00:00
|
|
|
</p>
|
2016-12-15 23:43:58 +00:00
|
|
|
<p className="form__field">
|
2020-08-17 09:51:59 +00:00
|
|
|
<label htmlFor="confirm password" className="form__label">{props.t('SignupForm.ConfirmPassword')}</label>
|
2016-06-27 17:54:50 +00:00
|
|
|
<input
|
2016-12-15 23:43:58 +00:00
|
|
|
className="form__input"
|
2016-06-27 17:54:50 +00:00
|
|
|
type="password"
|
2020-08-17 09:51:59 +00:00
|
|
|
aria-label={props.t('SignupForm.ConfirmPasswordARIA')}
|
2016-12-15 23:43:58 +00:00
|
|
|
id="confirm password"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(confirmPassword)}
|
2016-06-27 17:54:50 +00:00
|
|
|
/>
|
2020-07-24 21:11:10 +00:00
|
|
|
{confirmPassword.touched && confirmPassword.error && (
|
2017-06-06 02:33:32 +00:00
|
|
|
<span className="form-error">{confirmPassword.error}</span>
|
2020-07-24 21:11:10 +00:00
|
|
|
)}
|
2016-06-27 17:54:50 +00:00
|
|
|
</p>
|
2020-04-19 20:45:09 +00:00
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
disabled={submitting || invalid || pristine}
|
2020-08-17 09:51:59 +00:00
|
|
|
>{props.t('SignupForm.SubmitSignup')}
|
2020-04-19 20:45:09 +00:00
|
|
|
</Button>
|
2016-06-27 17:54:50 +00:00
|
|
|
</form>
|
|
|
|
);
|
2016-06-23 22:29:55 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 17:54:50 +00:00
|
|
|
SignupForm.propTypes = {
|
|
|
|
fields: PropTypes.shape({
|
2020-07-24 21:11:10 +00:00
|
|
|
username: PropTypes.object.isRequired, // eslint-disable-line
|
2021-01-27 21:14:21 +00:00
|
|
|
// email: PropTypes.object.isRequired, // eslint-disable-line
|
2020-07-24 21:11:10 +00:00
|
|
|
password: PropTypes.object.isRequired, // eslint-disable-line
|
|
|
|
confirmPassword: PropTypes.object.isRequired, // eslint-disable-line
|
2016-06-27 17:54:50 +00:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
2016-09-02 18:51:30 +00:00
|
|
|
signUpUser: PropTypes.func.isRequired,
|
|
|
|
submitting: PropTypes.bool,
|
|
|
|
invalid: PropTypes.bool,
|
2016-11-10 21:13:00 +00:00
|
|
|
pristine: PropTypes.bool,
|
2020-07-24 21:11:10 +00:00
|
|
|
previousPath: PropTypes.string.isRequired,
|
2020-08-17 09:51:59 +00:00
|
|
|
t: PropTypes.func.isRequired
|
2016-06-27 17:54:50 +00:00
|
|
|
};
|
|
|
|
|
2017-02-22 19:29:35 +00:00
|
|
|
SignupForm.defaultProps = {
|
|
|
|
submitting: false,
|
|
|
|
pristine: true,
|
2020-07-24 21:11:10 +00:00
|
|
|
invalid: false,
|
2017-02-22 19:29:35 +00:00
|
|
|
};
|
|
|
|
|
2020-08-17 09:51:59 +00:00
|
|
|
export default withTranslation()(SignupForm);
|