diff --git a/src/components/AuthUser/SignInForm/SignInForm.tsx b/src/components/AuthUser/SignInForm/SignInForm.tsx index 765d9a5861f2817901109632808342ae51907092..833d4cd74322eac277d3a9295a0136c464173e80 100644 --- a/src/components/AuthUser/SignInForm/SignInForm.tsx +++ b/src/components/AuthUser/SignInForm/SignInForm.tsx @@ -37,7 +37,7 @@ export const SignInForm: FC = () => { password: '', }; - const { control, errors, handleSubmit } = useForm<FormData>({ + const { control, errors, setError, handleSubmit } = useForm<FormData>({ defaultValues, }); @@ -55,8 +55,19 @@ export const SignInForm: FC = () => { }, }, ) - .then(() => { - history.replace(AuthRoutes.dashboard); + .then((response) => { + if (response.data.status === 'fail') { + setError('email', { + type: 'server', + message: 'Something went wrong with email', + }); + setError('password', { + type: 'server', + message: 'Something went wrong with password', + }); + } else if (response.data.status === 'success') { + history.replace(AuthRoutes.dashboard); + } }); };