// Author: Shiv // Date: April 2026 "use client"; import dynamic from "next/dynamic"; import Link from "next/link"; import { useState } from "react"; const labelCls = "flex flex-col gap-[0.35rem] text-[0.9rem] font-semibold text-[#444]"; const inputCls = "px-[0.85rem] py-[0.6rem] border border-[#ddd] rounded-lg text-base outline-none transition-all focus:border-[#e68672] focus:shadow-[0_0_0_3px_rgba(230,134,114,0.2)]"; const submitBtnCls = "mt-2 py-3 bg-[#e68672] text-white border-none rounded-lg text-base font-bold cursor-pointer transition-all hover:bg-[#d4705e] active:scale-[0.98] disabled:opacity-60 disabled:cursor-not-allowed"; //Forgot password page, sends a reset link to the user's email function ForgotPasswordPage() { const [usernameOrEmail, setUsernameOrEmail] = useState(""); const [message, setMessage] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const [submitted, setSubmitted] = useState(false); //Sends the forgot password request and hides the form on success async function handleSubmit(e) { e.preventDefault(); setError(""); setMessage(""); setLoading(true); try { const res = await fetch("/api/v1/auth/forgot-password", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ usernameOrEmail }), }); const data = await res.json(); if (!res.ok) { throw new Error(data.message || "Something went wrong. Please try again."); } setMessage(data.message || "If an account matches, a reset link has been sent to your email."); setSubmitted(true); } catch (err) { setError(err.message); } finally { setLoading(false); } } return (

Forgot Password

{!submitted ? ( <>

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

{error &&

{error}

}
) : (

{message}

)}

Remember your password?{" "} Log in here

Don't have an account?{" "} Register here

); } export default dynamic(() => Promise.resolve(ForgotPasswordPage), { ssr: false, });