"use client"; import { useState } from "react"; import Link from "next/link"; import { api, AdminError } from "@/lib/api"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { AuthShell, Field } from "@/app/login/page"; export default function ForgotPasswordPage() { const [email, setEmail] = useState(""); const [busy, setBusy] = useState(false); const [sent, setSent] = useState(false); const [error, setError] = useState(null); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setBusy(true); try { await api.forgotPassword(email.trim()); // The BFF always responds 200 (it doesn't reveal whether an account // exists), so we show the same confirmation regardless. setSent(true); } catch (err) { setError(err instanceof AdminError ? err.message : "Something went wrong."); } finally { setBusy(false); } } return ( {sent ? (

If an account exists for {email}, we've sent a password-reset link. Check your inbox.

Back to sign in
) : (
setEmail(e.target.value)} /> {error ?

{error}

: null}

Back to sign in

)}
); }