"use client"; import { useState } from "react"; import { useI18n } from "../../components/I18nProvider"; export default function ForgotPasswordPage() { const { t } = useI18n(); const [email, setEmail] = useState(""); const [sent, setSent] = useState(false); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setSent(false); setLoading(true); try { const res = await fetch("/api/auth/forgot", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email }), }); if (!res.ok) { const data = await res.json(); setError(data.error || t("forgotError")); } else { setSent(true); } } catch (err) { setError(t("forgotError")); } finally { setLoading(false); } } return (

{t("forgotTitle")}

{t("forgotLead")}

{sent ? (

{t("forgotSuccess")}

) : null} {error ?

{error}

: null}
); }