refactor: add success notification on register, remove success from route form and auto login call

This commit is contained in:
Derrick Hammer 2024-03-20 13:42:21 -04:00
parent 6fbbe4975c
commit 729414c45a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 14 additions and 23 deletions

View File

@ -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<AuthActionResponse> {

View File

@ -47,11 +47,11 @@ export default function Register() {
const login = useLogin<AuthFormRequest>();
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 (
<div className="p-10 h-screen relative">