'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { motion, AnimatePresence } from 'framer-motion'; import { forgotPassword } from '@/lib/api'; import { showToast } from '@/lib/toast'; import { Mail, ChevronRight, Loader2, CheckCircle } from 'lucide-react'; export default function ForgotPasswordForm() { const [email, setEmail] = useState(''); const [error, setError] = useState(''); const [success, setSuccess] = useState(false); const [loading, setLoading] = useState(false); const router = useRouter(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setLoading(true); if (!email || !email.includes('@')) { setError('Invalid identity mail provided.'); setLoading(false); return; } try { await forgotPassword(email); setSuccess(true); showToast.success('Recovery Signal Dispatched'); } catch (err: any) { setError(err.message || 'Dispatch failed. Verification error.'); } finally { setLoading(false); } }; return (
{error && (

{error}

)} {success && (

Signal Sent

Verify your mail to override the existing cipher.

router.push('/reset-password')} className="w-full py-4 bg-white text-black font-black rounded-2xl uppercase tracking-widest text-[10px]" > Enter Reset Protocol
)} {!success && ( <>
setEmail(e.target.value)} className="w-full bg-white/[0.03] border border-white/5 rounded-2xl py-4 pl-12 pr-4 text-white placeholder-white/10 focus:outline-none focus:border-indigo-500/50 focus:bg-white/[0.05] transition-all font-bold" placeholder="operator@matrix.net" />
{loading ? ( ) : ( <> Dispatch Reset Signal )} )} ); }