'use client'; import React, { useState } from 'react'; import Link from 'next/link'; import { Card, CardContent } from '@/components/ui/Card'; import { Input } from '@/components/ui/Input'; import { Button } from '@/components/ui/Button'; import { useCsrf } from '@/hooks/useCsrf'; export default function ForgotPasswordPage() { const { fetchWithCsrf, loading: csrfLoading } = useCsrf(); const [email, setEmail] = useState(''); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); const [error, setError] = useState(''); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(''); try { const response = await fetchWithCsrf('/api/auth/forgot-password', { method: 'POST', body: JSON.stringify({ email }), }); const data = await response.json(); if (response.ok) { setSuccess(true); } else { setError(data.error || 'Failed to send reset email'); } } catch (err) { setError('An error occurred. Please try again.'); } finally { setLoading(false); } }; if (success) { return (
QR Master QR Master

Check Your Email

We've sent you a password reset link

We've sent a password reset link to {email}

Please check your email and click the link to reset your password. The link will expire in 1 hour.

); } return (
QR Master QR Master

Forgot Password?

No worries, we'll send you reset instructions

{error && (
{error}
)} setEmail(e.target.value)} placeholder="you@example.com" required disabled={loading || csrfLoading} />
← Back to Login

Remember your password?{' '} Sign in

); }