2018-02-07 18:06:07 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2020-08-13 12:25:57 +00:00
|
|
|
import { withTranslation } from 'react-i18next';
|
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-10-18 20:07:25 +00:00
|
|
|
|
|
|
|
function NewPasswordForm(props) {
|
2018-05-05 00:22:39 +00:00
|
|
|
const {
|
2020-08-13 12:25:57 +00:00
|
|
|
fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine,
|
|
|
|
t
|
2018-05-05 00:22:39 +00:00
|
|
|
} = props;
|
2016-10-18 20:07:25 +00:00
|
|
|
return (
|
2020-07-24 21:11:10 +00:00
|
|
|
<form
|
|
|
|
className="form"
|
|
|
|
onSubmit={handleSubmit(props.updatePassword.bind(this, props.params.reset_password_token))}
|
|
|
|
>
|
2016-12-19 21:49:37 +00:00
|
|
|
<p className="form__field">
|
2020-08-13 12:25:57 +00:00
|
|
|
<label htmlFor="password" className="form__label">{t('NewPasswordForm.Title')}</label>
|
2016-10-18 20:07:25 +00:00
|
|
|
<input
|
2016-12-19 21:49:37 +00:00
|
|
|
className="form__input"
|
2020-08-13 12:25:57 +00:00
|
|
|
aria-label={t('NewPasswordForm.TitleARIA')}
|
2016-10-18 20:07:25 +00:00
|
|
|
type="password"
|
2016-12-19 21:49:37 +00:00
|
|
|
id="Password"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(password)}
|
2016-10-18 20:07:25 +00:00
|
|
|
/>
|
2020-07-24 21:11:10 +00:00
|
|
|
{password.touched && password.error && (
|
|
|
|
<span className="form-error">{password.error}</span>
|
|
|
|
)}
|
2016-10-18 20:07:25 +00:00
|
|
|
</p>
|
2016-12-19 21:49:37 +00:00
|
|
|
<p className="form__field">
|
2020-08-13 12:25:57 +00:00
|
|
|
<label htmlFor="confirm password" className="form__label">{t('NewPasswordForm.ConfirmPassword')}</label>
|
2016-10-18 20:07:25 +00:00
|
|
|
<input
|
2016-12-19 21:49:37 +00:00
|
|
|
className="form__input"
|
2016-10-18 20:07:25 +00:00
|
|
|
type="password"
|
2020-08-13 12:25:57 +00:00
|
|
|
aria-label={t('NewPasswordForm.ConfirmPasswordARIA')}
|
2016-12-19 21:49:37 +00:00
|
|
|
id="confirm password"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(confirmPassword)}
|
2016-10-18 20:07:25 +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-10-18 20:07:25 +00:00
|
|
|
</p>
|
2020-08-13 12:25:57 +00:00
|
|
|
<Button type="submit" disabled={submitting || invalid || pristine}>{t('NewPasswordForm.SubmitSetNewPassword')}</Button>
|
2016-10-18 20:07:25 +00:00
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
NewPasswordForm.propTypes = {
|
|
|
|
fields: PropTypes.shape({
|
2020-07-24 21:11:10 +00:00
|
|
|
password: PropTypes.object.isRequired, // eslint-disable-line
|
|
|
|
confirmPassword: PropTypes.object.isRequired, // eslint-disable-line
|
2016-10-18 20:07:25 +00:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
|
|
updatePassword: PropTypes.func.isRequired,
|
|
|
|
submitting: PropTypes.bool,
|
|
|
|
invalid: PropTypes.bool,
|
|
|
|
pristine: PropTypes.bool,
|
2016-12-19 21:49:37 +00:00
|
|
|
params: PropTypes.shape({
|
|
|
|
reset_password_token: PropTypes.string,
|
2017-02-22 19:29:35 +00:00
|
|
|
}).isRequired,
|
2020-08-13 12:25:57 +00:00
|
|
|
t: PropTypes.func.isRequired
|
2017-02-22 19:29:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
NewPasswordForm.defaultProps = {
|
|
|
|
invalid: false,
|
|
|
|
pristine: true,
|
2020-07-24 21:11:10 +00:00
|
|
|
submitting: false,
|
2016-10-18 20:07:25 +00:00
|
|
|
};
|
|
|
|
|
2020-08-13 12:25:57 +00:00
|
|
|
export default withTranslation()(NewPasswordForm);
|