'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 (
); }