From 729414c45a89d0337c7f827b4c549668e236f86b Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 20 Mar 2024 13:42:21 -0400 Subject: [PATCH] refactor: add success notification on register, remove success from route form and auto login call --- app/data/auth-provider.ts | 7 ++++++- app/routes/register.tsx | 30 ++++++++---------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/app/data/auth-provider.ts b/app/data/auth-provider.ts index 9b94720..05b1021 100644 --- a/app/data/auth-provider.ts +++ b/app/data/auth-provider.ts @@ -124,7 +124,12 @@ export const createPortalAuthProvider = (sdk: Sdk): AuthProvider => { first_name: params.firstName, last_name: params.lastName, }); - return handleResponse({ret, redirectToSuccess: "/login"}); + return handleResponse({ + ret, redirectToSuccess: "/login", successNotification: { + message: "Registration Successful", + description: "You have successfully registered. Please check your email to verify your account.", + } + }); }, async forgotPassword(params: any): Promise { diff --git a/app/routes/register.tsx b/app/routes/register.tsx index 8690270..fa15ba9 100644 --- a/app/routes/register.tsx +++ b/app/routes/register.tsx @@ -47,11 +47,11 @@ export default function Register() { const login = useLogin(); const { open } = useNotification(); const [form, fields] = useForm({ - id: "register", - constraint: getZodConstraint(RegisterSchema), - onValidate({ formData }) { - return parseWithZod(formData, { schema: RegisterSchema }); - }, + id: "register", + constraint: getZodConstraint(RegisterSchema), + onValidate({formData}) { + return parseWithZod(formData, {schema: RegisterSchema}); + }, onSubmit(e) { e.preventDefault(); @@ -61,23 +61,9 @@ export default function Register() { password: data.password.toString(), firstName: data.firstName.toString(), lastName: data.lastName.toString(), - }, { - onSuccess: () => { - open?.({ - type: "success", - message: "Verify your Email", - description: "An Email was sent to your email address. Please verify your email address to activate your account.", - key: "register-success" - }) - login.mutate({ - email: data.email.toString(), - password: data.password.toString(), - rememberMe: false, - }) - } - }) - } - }); + }) + } + }); return (