MCPcopy Create free account
hub / github.com/WardAnalytics/WardGraph / ForgotPasswordForm

Function ForgotPasswordForm

src/components/auth/ForgotPasswordForm.tsx:12–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10import { zodResolver } from "@hookform/resolvers/zod";
11
12const ForgotPasswordForm: FC = () => {
13 const { onResetPasswordSuccess, onResetPasswordError, setAuthDialogState } =
14 useContext(AuthContext);
15
16 const formSchema = z.object({
17 email: z.string({
18 required_error: "Email is required",
19 invalid_type_error: "Email should be a string",
20 }).email("Invalid email address"),
21 });
22
23 type ResetPasswordSchema = z.infer<typeof formSchema>;
24
25 const methods = useForm<ResetPasswordSchema>({
26 mode: "onBlur",
27 resolver: zodResolver(formSchema)
28 });
29
30 const { handleSubmit } = methods;
31
32 const handleResetPassword = (data: ResetPasswordSchema) => {
33 const email = data.email;
34
35 authService.resetUserPassword(
36 email,
37 onResetPasswordSuccess,
38 onResetPasswordError,
39 );
40 };
41
42 return (
43 <>
44 <div className="w-full">
45 <FormProvider {...methods}>
46 <form className=" space-y-4" onSubmit={handleSubmit(handleResetPassword)}>
47 <div>
48 <AuthInput
49 label="Email"
50 type="email"
51 name="email"
52 id="email"
53 placeholder="name@company.com"
54 />
55 </div>
56 <button
57 type="submit"
58 className="w-full rounded-lg bg-blue-500 px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-blue-400 focus:outline-none focus:ring-4 focus:ring-primary-300 dark:bg-blue-700 dark:hover:bg-blue-600 dark:focus:ring-blue-800"
59 >
60 Reset password
61 </button>
62 </form>
63 </FormProvider>
64 </div>
65 <p className="mt-10 text-center text-sm text-gray-500 dark:text-white">
66 Remembered your password?{" "}
67 <button
68 className="font-semibold leading-6 text-blue-500 hover:text-blue-400 dark:text-white dark:hover:text-slate-100"
69 onClick={() => setAuthDialogState(AuthDialogState.LOGIN)}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected