import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Link } from 'react-router'; import { Wordmark } from '../components/Logo'; import { Button } from '../components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../components/ui/card'; import { Input } from '../components/ui/input'; import { authClient } from '../lib/auth-client'; import { unwrap } from '../lib/auth-errors'; export default function ForgotPassword() { const { t } = useTranslation(); const [email, setEmail] = useState(''); const [error, setError] = useState(''); const [success, setSuccess] = useState(false); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setLoading(true); try { // The emailed link lands on /reset-password?token=... (or ?error=). unwrap(await authClient.requestPasswordReset({ email, redirectTo: '/reset-password' })); // The same answer whether or not the account exists (no enumeration). setSuccess(true); } catch { setError(t('auth.reset.sendFailed')); } finally { setLoading(false); } }; return (
{t('auth.reset.didntReceive')}{' '}
{t('auth.reset.remember')}{' '} {t('auth.signIn')}