diff --git a/src/app/main/authPages/forgot-password/ForgotPasswordPage.js b/src/app/main/authPages/forgot-password/ForgotPasswordPage.js index 550507c..14412c9 100644 --- a/src/app/main/authPages/forgot-password/ForgotPasswordPage.js +++ b/src/app/main/authPages/forgot-password/ForgotPasswordPage.js @@ -7,6 +7,7 @@ import Typography from '@mui/material/Typography'; import { Controller, useForm } from 'react-hook-form'; import { withTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; +import { authService } from 'src/app/services'; import * as yup from 'yup'; import LeftSideCanvas from '../shared-components/LeftSideCanvas'; @@ -19,7 +20,7 @@ function ForgotPasswordPage({ t }) { email: yup.string().email(t('email_error')).required(t('email_error')), }); - const { control, formState, handleSubmit, reset } = useForm({ + const { control, formState, handleSubmit, setError } = useForm({ mode: 'onChange', defaultValues, resolver: yupResolver(schema), @@ -27,8 +28,13 @@ function ForgotPasswordPage({ t }) { const { isValid, dirtyFields, errors } = formState; - function onSubmit() { - reset(defaultValues); + function onSubmit({ email }) { + authService.sendPasswordResetEmail(email).catch((error) => { + setError('root', { + type: 'manual', + message: error.message, + }); + }); } return (