"use client" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { ArrowLeft, CheckCircle2 } from "lucide-react" import Link from "next/link" import { useState } from "react" import { Logo } from "@/components/Logo" export default function ForgotPasswordPage() { const [email, setEmail] = useState("") const [error, setError] = useState("") const [isSubmitted, setIsSubmitted] = useState(false) const [loading, setLoading] = useState(false) const handleReset = async (e: React.FormEvent) => { e.preventDefault() setError("") setLoading(true) try { // Calling the backend proxy endpoint const res = await fetch("/api/auth/forgot-password", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email }) }) const data = await res.json() if (data.success) { setIsSubmitted(true) } else { setError(data.error || "Failed to process request.") } } catch (err) { setError("An error occurred. Please try again.") } finally { setLoading(false) } } return (
Back to Login
{isSubmitted ? (

Check your email

We've sent password reset instructions to {email}.

) : ( Reset Password Enter your email and we'll send you instructions.
setEmail(e.target.value)} placeholder="student@example.com" required suppressHydrationWarning className="w-full bg-background border border-border rounded-xl px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-[var(--cyan-ai)] focus:border-transparent transition-all" />
{error && (
{error}
)}
)}
) }