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 Modal from 'antd/es/modal'; import Alert from 'antd/es/alert'; import { requestPasswordReset } from './customerApi'; const { Paragraph, Text } = Typography; interface Props { onClose: () => void; // Steps back to sign-in without leaving a history entry behind, the same way // the auth modal switches between its own tabs. onBackToSignIn: () => void; } export default function ForgotPassword({ onClose, onBackToSignIn }: Props) { 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 ( {sent ? ( <> {/* Worded so it reveals nothing about whether the address has an account — the server deliberately answers the same either way. */} ) : ( <> Enter the email address for your account and we'll send you a link to choose a new password. {error && }
Remembered it?{' '} )}
); }