RC-4: add authService sendPasswordResetEmail method to forgot password page

This commit is contained in:
2023-06-22 20:00:40 +01:00
parent 9fe7ccd1a3
commit d8a597e615

View File

@@ -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 (