// tslint:disable:no-magic-numbers /* istanbul ignore next */ import { Grid } from '@material-ui/core'; import Avatar from '@material-ui/core/Avatar'; import Button from '@material-ui/core/Button'; import Container from '@material-ui/core/Container'; import Typography from '@material-ui/core/Typography'; import LockOutlinedIcon from '@material-ui/icons/LockOutlined'; import { Formik } from 'formik'; import _defaultTo from 'ramda/src/defaultTo'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; import PasswordField from '../../atoms/PasswordField'; import { ResetPasswordOptions, resetPasswordRequested, } from '../../redux/auth/actionCreators'; import { State } from '../../redux/rootReducer'; import resetPasswordSchema from '../../utils/schemas/resetPassword'; import useStyles from './styles'; const ResetPasswordForm = () => { const classes = useStyles(); const { t } = useTranslation(); const { resetPasswordLoading } = useSelector(({ auth }: State) => auth); const dispatch = useDispatch(); const resetPassword = (options: ResetPasswordOptions) => dispatch(resetPasswordRequested(options)); const params = // TODO: add polyfill location !== undefined ? new URLSearchParams(location.search) : null; const tokenParam = params !== null ? params.get('token') : ''; const token = _defaultTo('')(tokenParam); return (
{t('auth.resetPassword')} resetPassword({ ...values, token })} render={({ handleSubmit, handleChange, handleBlur, values, errors, touched, }) => { const hasPasswordError = Boolean( errors.password && touched.password ); const hasPasswordConfirmationError = Boolean( errors.passwordConfirmation && touched.passwordConfirmation ); return (
); }} />
); }; // tslint:disable-next-line:max-file-line-count export default ResetPasswordForm;