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 { authService } from "@/lib/api/example/auth/service";
|
||||
import { useState } from "react";
|
||||
import { signIn } from "next-auth/react";
|
||||
import { toaster } from "@/components/ui/feedback/toaster";
|
||||
|
||||
const schema = yup.object({
|
||||
name: yup.string().required(),
|
||||
@@ -53,9 +55,26 @@ function SignUpPage() {
|
||||
firstName: formData.name,
|
||||
lastName: "",
|
||||
});
|
||||
router.replace("/signin");
|
||||
} catch {
|
||||
// Error handled by api-service interceptor (toast + 422 display)
|
||||
|
||||
const res = await signIn("credentials", {
|
||||
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 {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user