'use client'; import { useState } from 'react'; import { Box, TextField, Button, Typography, Paper, Alert, CircularProgress, Link as MuiLink, } from '@mui/material'; import { Email, ArrowBack } from '@mui/icons-material'; import { motion } from 'framer-motion'; import Link from 'next/link'; import apiClient from '@/lib/api/client'; export default function ForgotPasswordPage() { const [email, setEmail] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const [success, setSuccess] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!email.trim()) { setError('Please enter your email address'); return; } setLoading(true); setError(''); try { await apiClient.post('/api/v1/auth/password/forgot', { email }); setSuccess(true); } catch (err: any) { console.error('Forgot password error:', err); setError(err.response?.data?.message || 'Failed to send reset email. Please try again.'); } finally { setLoading(false); } }; return ( {!success ? ( <> Forgot Password? No worries! Enter your email address and we'll send you a link to reset your password. {error && ( {error} )}
setEmail(e.target.value)} disabled={loading} required autoFocus sx={{ mb: 3, '& .MuiOutlinedInput-root': { borderRadius: 3, }, }} /> Back to Login ) : ( Check Your Email 📧 If an account with that email exists, we've sent you a password reset link. Please check your inbox and follow the instructions. Didn't receive the email? • Check your spam or junk folder
• Make sure you entered the correct email
• The link expires in 1 hour
Back to Login
)}
); }