"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 (

Check Your Email

If an account exists with the email {email}, you will receive a password reset link shortly.

← Back to Login
); } return (

Forgot Password

Enter your email address and we'll send you a link to reset your password.

{error && (
{error}
)}
setEmail(e.target.value)} className="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="your-email@example.com" />
← Back to Login
); }