2018-02-07 18:06:07 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2020-08-13 10:12:02 +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-12 18:25:24 +00:00
|
|
|
|
|
|
|
function ResetPasswordForm(props) {
|
2018-05-05 00:22:39 +00:00
|
|
|
const {
|
2020-08-13 10:12:02 +00:00
|
|
|
fields: { email }, handleSubmit, submitting, invalid, pristine, t
|
2018-05-05 00:22:39 +00:00
|
|
|
} = props;
|
2016-10-12 18:25:24 +00:00
|
|
|
return (
|
2020-07-24 21:11:10 +00:00
|
|
|
<form
|
|
|
|
className="form"
|
|
|
|
onSubmit={handleSubmit(props.initiateResetPassword.bind(this))}
|
|
|
|
>
|
2016-12-19 21:49:37 +00:00
|
|
|
<p className="form__field">
|
2020-08-13 10:12:02 +00:00
|
|
|
<label htmlFor="email" className="form__label">{t('ResetPasswordForm.Email')}</label>
|
2016-10-12 18:25:24 +00:00
|
|
|
<input
|
2016-12-19 21:49:37 +00:00
|
|
|
className="form__input"
|
2020-08-13 10:12:02 +00:00
|
|
|
aria-label={t('ResetPasswordForm.EmailARIA')}
|
2016-10-12 18:25:24 +00:00
|
|
|
type="text"
|
2016-12-19 21:49:37 +00:00
|
|
|
id="email"
|
2016-11-16 18:12:36 +00:00
|
|
|
{...domOnlyProps(email)}
|
2016-10-12 18:25:24 +00:00
|
|
|
/>
|
2020-07-24 21:11:10 +00:00
|
|
|
{email.touched && email.error && (
|
|
|
|
<span className="form-error">{email.error}</span>
|
|
|
|
)}
|
2016-10-12 18:25:24 +00:00
|
|
|
</p>
|
2020-04-19 20:45:09 +00:00
|
|
|
<Button
|
2017-06-06 02:33:32 +00:00
|
|
|
type="submit"
|
|
|
|
disabled={submitting || invalid || pristine || props.user.resetPasswordInitiate}
|
2020-08-13 10:12:02 +00:00
|
|
|
>{t('ResetPasswordForm.Submit')}
|
2020-04-19 20:45:09 +00:00
|
|
|
</Button>
|
2016-10-12 18:25:24 +00:00
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-10-12 21:19:43 +00:00
|
|
|
ResetPasswordForm.propTypes = {
|
2016-10-12 18:25:24 +00:00
|
|
|
fields: PropTypes.shape({
|
2020-07-28 14:17:49 +00:00
|
|
|
email: PropTypes.object.isRequired
|
2016-10-12 18:25:24 +00:00
|
|
|
}).isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
|
|
initiateResetPassword: PropTypes.func.isRequired,
|
|
|
|
submitting: PropTypes.bool,
|
|
|
|
invalid: PropTypes.bool,
|
2016-10-19 15:34:08 +00:00
|
|
|
pristine: PropTypes.bool,
|
|
|
|
user: PropTypes.shape({
|
|
|
|
resetPasswordInitiate: PropTypes.bool
|
2020-07-24 21:11:10 +00:00
|
|
|
}).isRequired,
|
2020-08-13 10:12:02 +00:00
|
|
|
t: PropTypes.func.isRequired
|
2017-02-22 19:29:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ResetPasswordForm.defaultProps = {
|
|
|
|
submitting: false,
|
|
|
|
pristine: true,
|
2020-07-24 21:11:10 +00:00
|
|
|
invalid: false,
|
2016-10-12 21:19:43 +00:00
|
|
|
};
|
2016-10-12 18:25:24 +00:00
|
|
|
|
2020-08-13 10:12:02 +00:00
|
|
|
export default withTranslation()(ResetPasswordForm);
|