2018-02-07 19:06:07 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2020-04-19 22:45:09 +02:00
|
|
|
|
2016-11-16 19:12:36 +01:00
|
|
|
import { domOnlyProps } from '../../../utils/reduxFormUtils';
|
2020-04-19 22:45:09 +02:00
|
|
|
import Button from '../../../common/Button';
|
2016-10-18 22:07:25 +02:00
|
|
|
|
|
|
|
function NewPasswordForm(props) {
|
2018-05-05 02:22:39 +02:00
|
|
|
const {
|
|
|
|
fields: { password, confirmPassword }, handleSubmit, submitting, invalid, pristine
|
|
|
|
} = props;
|
2016-10-18 22:07:25 +02:00
|
|
|
return (
|
2016-12-19 22:49:37 +01:00
|
|
|
<form className="form" onSubmit={handleSubmit(props.updatePassword.bind(this, props.params.reset_password_token))}>
|
|
|
|
<p className="form__field">
|
|
|
|
<label htmlFor="password" className="form__label">Password</label>
|
2016-10-18 22:07:25 +02:00
|
|
|
<input
|
2016-12-19 22:49:37 +01:00
|
|
|
className="form__input"
|
2016-10-18 22:07:25 +02:00
|
|
|
aria-label="password"
|
|
|
|
type="password"
|
2016-12-19 22:49:37 +01:00
|
|
|
id="Password"
|
2016-11-16 19:12:36 +01:00
|
|
|
{...domOnlyProps(password)}
|
2016-10-18 22:07:25 +02:00
|
|
|
/>
|
|
|
|
{password.touched && password.error && <span className="form-error">{password.error}</span>}
|
|
|
|
</p>
|
2016-12-19 22:49:37 +01:00
|
|
|
<p className="form__field">
|
|
|
|
<label htmlFor="confirm password" className="form__label">Confirm Password</label>
|
2016-10-18 22:07:25 +02:00
|
|
|
<input
|
2016-12-19 22:49:37 +01:00
|
|
|
className="form__input"
|
2016-10-18 22:07:25 +02:00
|
|
|
type="password"
|
|
|
|
aria-label="confirm password"
|
2016-12-19 22:49:37 +01:00
|
|
|
id="confirm password"
|
2016-11-16 19:12:36 +01:00
|
|
|
{...domOnlyProps(confirmPassword)}
|
2016-10-18 22:07:25 +02:00
|
|
|
/>
|
2017-06-06 04:33:32 +02:00
|
|
|
{
|
|
|
|
confirmPassword.touched &&
|
|
|
|
confirmPassword.error &&
|
|
|
|
<span className="form-error">{confirmPassword.error}</span>
|
|
|
|
}
|
2016-10-18 22:07:25 +02:00
|
|
|
</p>
|
2020-05-26 18:36:07 +02:00
|
|
|
<Button type="submit" disabled={submitting || invalid || pristine}>Set New Password</Button>
|
2016-10-18 22:07:25 +02:00
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
NewPasswordForm.propTypes = {
|
|
|
|
fields: PropTypes.shape({
|
2020-07-24 22:01:48 +02:00
|
|
|
password: PropTypes.object.isRequired, // eslint-disable-line
|
|
|
|
confirmPassword: PropTypes.object.isRequired // eslint-disable-line
|
2016-10-18 22:07:25 +02:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
|
|
updatePassword: PropTypes.func.isRequired,
|
|
|
|
submitting: PropTypes.bool,
|
|
|
|
invalid: PropTypes.bool,
|
|
|
|
pristine: PropTypes.bool,
|
2016-12-19 22:49:37 +01:00
|
|
|
params: PropTypes.shape({
|
|
|
|
reset_password_token: PropTypes.string,
|
2017-02-22 20:29:35 +01:00
|
|
|
}).isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
NewPasswordForm.defaultProps = {
|
|
|
|
invalid: false,
|
|
|
|
pristine: true,
|
|
|
|
submitting: false
|
2016-10-18 22:07:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default NewPasswordForm;
|