"use client"; import Link from "next/link"; import { useState } from "react"; import { Background } from "../../components/background"; import { SiteFooter } from "../../components/site-footer"; import { SiteHeader } from "../../components/site-header"; type ApiResponse = { data: T; meta: { timestamp: string; version: "v1" }; error: null | { message: string; code?: string }; }; export default function ForgotPasswordPage() { const [email, setEmail] = useState(""); const [status, setStatus] = useState(""); const [sent, setSent] = useState(false); const [isError, setIsError] = useState(false); const onSubmit = async (event: React.FormEvent) => { event.preventDefault(); setStatus("Sending reset link..."); setIsError(false); try { const res = await fetch("/api/auth/forgot-password", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email }), }); const payload = (await res.json()) as ApiResponse<{ message: string }>; if (!res.ok && payload.error) { setStatus(payload.error.message ?? "Something went wrong."); setIsError(true); return; } setSent(true); setStatus(payload.data?.message ?? "If that email exists, a reset link has been sent."); } catch { setStatus("Something went wrong. Please try again."); setIsError(true); } }; return (
L1

Reset your password

Back to sign in

{sent ? (

{status}

Check your email inbox and spam folder.

Back to sign in
) : (

We'll send a reset link to this address if it has an account.

setEmail(e.target.value)} className="block w-full appearance-none rounded-lg border border-border bg-background/50 px-3 py-2 text-foreground placeholder-muted-foreground shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/20 sm:text-sm transition-all" />
{isError && status && (

{status}

)}
)}
); }