This commit is contained in:
@@ -24,6 +24,8 @@ import { PasswordInput } from "@/components/ui/forms/password-input";
|
|||||||
import { Skeleton } from "@/components/ui/feedback/skeleton";
|
import { Skeleton } from "@/components/ui/feedback/skeleton";
|
||||||
import { authService } from "@/lib/api/example/auth/service";
|
import { authService } from "@/lib/api/example/auth/service";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { signIn } from "next-auth/react";
|
||||||
|
import { toaster } from "@/components/ui/feedback/toaster";
|
||||||
|
|
||||||
const schema = yup.object({
|
const schema = yup.object({
|
||||||
name: yup.string().required(),
|
name: yup.string().required(),
|
||||||
@@ -53,9 +55,26 @@ function SignUpPage() {
|
|||||||
firstName: formData.name,
|
firstName: formData.name,
|
||||||
lastName: "",
|
lastName: "",
|
||||||
});
|
});
|
||||||
router.replace("/signin");
|
|
||||||
} catch {
|
const res = await signIn("credentials", {
|
||||||
// Error handled by api-service interceptor (toast + 422 display)
|
redirect: false,
|
||||||
|
email: formData.email,
|
||||||
|
password: formData.password,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res?.error) {
|
||||||
|
throw new Error(res.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
router.replace("/home");
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error && error.message) {
|
||||||
|
toaster.error({
|
||||||
|
title: error.message,
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// other errors are handled by api-service interceptor (toast + 422 display)
|
||||||
} finally {
|
} finally {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user