import * as React from 'react'; import { Link } from 'react-router-dom'; import requestPasswordResetEmail from '@/api/auth/requestPasswordResetEmail'; import { httpErrorToHuman } from '@/api/http'; import LoginFormContainer from '@/components/auth/LoginFormContainer'; import { Actions, useStoreActions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; import Field from '@/components/elements/Field'; import { Formik, FormikHelpers } from 'formik'; import { object, string } from 'yup'; interface Values { email: string; } export default () => { const { clearFlashes, addFlash } = useStoreActions((actions: Actions) => actions.flashes); const handleSubmission = ({ email }: Values, { setSubmitting, resetForm }: FormikHelpers) => { setSubmitting(true); clearFlashes(); requestPasswordResetEmail(email) .then(response => { resetForm(); addFlash({ type: 'success', title: 'Success', message: response }); }) .catch(error => { console.error(error); addFlash({ type: 'error', title: 'Error', message: httpErrorToHuman(error) }); }) .then(() => setSubmitting(false)); }; return ( {({ isSubmitting }) => (
Return to Login
)}
); };