refactor(nestjs): hook up auth endpoints

This commit is contained in:
Ahmed Bouhuolia
2025-05-08 18:10:02 +02:00
parent 401b3dc111
commit f78d6efe27
26 changed files with 304 additions and 111 deletions

View File

@@ -29,22 +29,19 @@ export default function Login() {
const handleSubmit = (values, { setSubmitting }) => {
loginMutate({
crediential: values.crediential,
email: values.crediential,
password: values.password,
}).catch(
({
response: {
data: { errors },
},
}) => {
const toastBuilders = transformLoginErrorsToToasts(errors);
}).catch(({ response }) => {
const {
data: { errors },
} = response;
const toastBuilders = transformLoginErrorsToToasts(errors);
toastBuilders.forEach((builder) => {
Toaster.show(builder);
});
setSubmitting(false);
},
);
toastBuilders.forEach((builder) => {
Toaster.show(builder);
});
setSubmitting(false);
});
};
return (
@@ -70,7 +67,10 @@ function LoginFooterLinks() {
<AuthFooterLinks>
{!signupDisabled && (
<AuthFooterLink>
<T id={'dont_have_an_account'} /> <Link to={'/auth/register'}><T id={'sign_up'} /></Link>
<T id={'dont_have_an_account'} />{' '}
<Link to={'/auth/register'}>
<T id={'sign_up'} />
</Link>
</AuthFooterLink>
)}
<AuthFooterLink>

View File

@@ -53,22 +53,20 @@ export default function RegisterUserForm() {
},
);
})
.catch(
({
response: {
data: { errors },
},
}) => {
const formErrors = transformRegisterErrorsToForm(errors);
const toastMessages = transformRegisterToastMessages(errors);
.catch(({ response }) => {
const {
data: { errors },
} = response;
const formErrors = transformRegisterErrorsToForm(errors);
const toastMessages = transformRegisterToastMessages(errors);
toastMessages.forEach((toastMessage) => {
AppToaster.show(toastMessage);
});
setErrors(formErrors);
setSubmitting(false);
},
);
toastMessages.forEach((toastMessage) => {
AppToaster.show(toastMessage);
});
setErrors(formErrors);
setSubmitting(false);
});
};
return (