"use client"; import { useState } from "react"; import { Mail, Fingerprint, ArrowLeft, ArrowRight, CheckCircle } from "lucide-react"; import { useLanguage } from "@/components/language-provider"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; export default function ForgotPasswordPage() { const { t, lang, dir } = useLanguage(); const Arrow = lang === "fa" ? ArrowRight : ArrowLeft; const [email, setEmail] = useState(""); const [step, setStep] = useState<"request" | "sent">("request"); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setLoading(true); try { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/auth/password/reset/`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email }), }); const data = await res.json(); if (!res.ok) { throw new Error(data.detail || data.error || "Request failed"); } setStep("sent"); } catch (err) { setError(err instanceof Error ? err.message : "Request failed"); } finally { setLoading(false); } }; return (
{process.env.NEXT_PUBLIC_SITE_NAME || "MyAccount Hamsoo"} {step === "request" ? ( <>

{lang === "fa" ? "بازیابی رمز عبور" : "Reset Password"}

{lang === "fa" ? "ایمیل خود را وارد کنید تا لینک بازیابی ارسال شود" : "Enter your email to receive a reset link"}

) : ( <>

{lang === "fa" ? "ایمیل ارسال شد" : "Email Sent"}

{lang === "fa" ? "اگر ایمیل در سیستم ثبت باشد، لینک بازیابی ارسال می‌شود" : "If the email exists in our system, a reset link has been sent"}

)}
{error && (
{error}
)} {step === "request" && (
setEmail(e.target.value)} required className="w-full pl-10 pr-4 py-2.5 rounded-lg border border-white/10 bg-white/5 text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-brand-500/50 focus:border-transparent" placeholder={lang === "fa" ? "you@example.com" : "you@example.com"} dir="ltr" />
)} {step === "sent" && (

{lang === "fa" ? "ایمیل را پیدا نکردید؟" : "Didn't receive the email?"}{" "} {lang === "fa" ? "ارسال مجدد" : "Resend"}

)}
{lang === "fa" ? "مرکز حساب همسو" : "MyAccount Hamsoo"}
); } function Link({ href, children, className }: { href: string; children: React.ReactNode; className?: string }) { return {children}; }