import { zodResolver } from "@hookform/resolvers/zod"; import { t } from "@lingui/macro"; import { ArrowLeftIcon } from "@phosphor-icons/react"; import { forgotPasswordSchema } from "@reactive-resume/dto"; import { Alert, AlertDescription, Button, Form, FormControl, FormField, FormItem, FormLabel, FormMessage, Input, } from "@reactive-resume/ui"; import { useState } from "react"; import { Helmet } from "react-helmet-async"; import { useForm } from "react-hook-form"; import { useNavigate } from "react-router"; import type { z } from "zod"; import { useForgotPassword } from "@/client/services/auth"; type FormValues = z.infer; export const ForgotPasswordPage = () => { const navigate = useNavigate(); const [submitted, setSubmitted] = useState(false); const { forgotPassword, loading } = useForgotPassword(); const form = useForm({ resolver: zodResolver(forgotPasswordSchema), defaultValues: { email: "" }, }); const onSubmit = async (data: FormValues) => { await forgotPassword(data); setSubmitted(true); form.reset(); }; if (submitted) { return (
{t`You've got mail!`} - {t`Reactive Resume`}

{t`You've got mail!`}

{t`A password reset link should have been sent to your inbox, if an account existed with the email you provided.`}
); } return (

{t`Forgot your password?`}

{t`Enter your email address and we will send you a link to reset your password if the account exists.`}
( {t`Email`} )} />
); };