"use client"; import { useState } from "react"; import Link from "next/link"; export default function ForgotPasswordPage() { const [email, setEmail] = useState(''); const [loading, setLoading] = useState(false); const [submitted, setSubmitted] = useState(false); const [error, setError] = useState(''); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(''); try { const response = await fetch('/api/auth/forgot-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email }), }); const data = await response.json(); if (!response.ok) { throw new Error(data.error || 'Failed to send reset email'); } setSubmitted(true); } catch (err: any) { setError(err.message || 'An error occurred'); } finally { setLoading(false); } }; if (submitted) { return (
If an account exists with the email {email}, you will receive a password reset link shortly.
← Back to LoginEnter your email address and we'll send you a link to reset your password.
{error && (