"use client"; import { useState } from "react"; import Link from "next/link"; import { toast } from "sonner"; import { useTranslations } from "next-intl"; import { authClient } from "@/lib/auth/client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; export default function ForgotPasswordPage() { const t = useTranslations("auth"); const [email, setEmail] = useState(""); const [loading, setLoading] = useState(false); const [sent, setSent] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); const { error } = await authClient.requestPasswordReset({ email, redirectTo: "/reset-password", }); setLoading(false); if (error) { toast.error(error.message ?? "Failed to send reset email"); } else { setSent(true); } } return ( {t("forgotPasswordTitle")} {sent ? t("forgotPasswordSent") : t("forgotPasswordDescription")} {sent ? (

{t("forgotPasswordSentDescription", { email })}

) : (
setEmail(e.target.value)} required />
)} {t("backToSignIn")}
); }