Skip to content
Snippets Groups Projects
Verified Commit ddd66cf9 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Attach serverside error onSubmit

parent ac93b7e7
No related branches found
No related tags found
1 merge request!39is_authenticated, hide password and move styles
...@@ -37,7 +37,7 @@ export const SignInForm: FC = () => { ...@@ -37,7 +37,7 @@ export const SignInForm: FC = () => {
password: '', password: '',
}; };
const { control, errors, handleSubmit } = useForm<FormData>({ const { control, errors, setError, handleSubmit } = useForm<FormData>({
defaultValues, defaultValues,
}); });
...@@ -55,8 +55,19 @@ export const SignInForm: FC = () => { ...@@ -55,8 +55,19 @@ export const SignInForm: FC = () => {
}, },
}, },
) )
.then(() => { .then((response) => {
history.replace(AuthRoutes.dashboard); 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);
}
}); });
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment