import { useState } from 'react'; import Form from 'antd/es/form'; import Input from 'antd/es/input'; import Button from 'antd/es/button'; import Typography from 'antd/es/typography'; import Card from 'antd/es/card'; import Alert from 'antd/es/alert'; import { Link } from 'react-router-dom'; import { requestPasswordReset } from './customerApi'; const { Title, Paragraph, Text } = Typography; export default function ForgotPassword() { const [sent, setSent] = useState(false); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); async function onFinish(values: { email: string }) { setLoading(true); setError(null); try { await requestPasswordReset(values.email); setSent(true); } catch (err) { setError((err as Error).message); } finally { setLoading(false); } } return ( Reset your password {sent ? ( <> {/* Worded so it reveals nothing about whether the address has an account — the server deliberately answers the same either way. */} Back to sign in ) : ( <> Enter the email address for your account and we'll send you a link to choose a new password. {error && }
Remembered it? Sign in )}
); }