mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 17:26:24 +00:00
62 lines
2.6 KiB
TypeScript
62 lines
2.6 KiB
TypeScript
import { CheckCircle2 } from 'lucide-react';
|
|
import { useTranslation } from '../../i18n';
|
|
import { AppAuthScreen, Field, Notice } from '../login/AppAuthScreen';
|
|
import type { useForgotPassword } from './useForgotPassword';
|
|
|
|
export default function AppForgotPassword({ forgot }: { forgot: ReturnType<typeof useForgotPassword> }) {
|
|
const { t } = useTranslation();
|
|
const back = () => void forgot.navigate('/login');
|
|
const smtpOff = forgot.smtpConfigured === false;
|
|
const smtpNotice = smtpOff && <Notice tone="warn">{t('login.forgotPasswordSmtpHintOff')}</Notice>;
|
|
|
|
return (
|
|
<AppAuthScreen>
|
|
{forgot.submitted && !forgot.deliveryIssue ? (
|
|
<div className="al-form">
|
|
<div className="al-recovery-feedback" role="status">
|
|
{!smtpOff && <CheckCircle2 className="al-recovery-icon" size={28} aria-hidden="true" />}
|
|
<h1 className="al-title">{t(smtpOff ? 'login.forgotPasswordTitle' : 'login.forgotPasswordSentTitle')}</h1>
|
|
{!smtpOff && <p className="al-sub">{t('login.forgotPasswordSentBody')}</p>}
|
|
</div>
|
|
{smtpNotice}
|
|
<button type="button" className="al-cta" onClick={back}>
|
|
{t('login.backToLogin')}
|
|
</button>
|
|
</div>
|
|
) : (
|
|
<>
|
|
<form className="al-form" onSubmit={(event) => void forgot.handleSubmit(event)}>
|
|
<h1 className="al-title">{t('login.forgotPasswordTitle')}</h1>
|
|
<p className="al-sub">{t('login.forgotPasswordBody')}</p>
|
|
{smtpNotice}
|
|
{forgot.deliveryIssue && (
|
|
<Notice>
|
|
{t(forgot.deliveryIssue === 'rateLimit' ? 'common.tooManyAttempts' : 'native.connect.errorUnreachable')}
|
|
</Notice>
|
|
)}
|
|
<Field
|
|
label={t('common.email')}
|
|
name="email"
|
|
type="email"
|
|
autoComplete="email"
|
|
autoCapitalize="none"
|
|
enterKeyHint="send"
|
|
value={forgot.email}
|
|
onChange={(event) => forgot.setEmail(event.target.value)}
|
|
placeholder={t('login.emailPlaceholder')}
|
|
required
|
|
/>
|
|
<button type="submit" className="al-cta" disabled={forgot.isLoading}>
|
|
{forgot.isLoading && <span className="al-spin" aria-hidden="true" />}
|
|
{forgot.isLoading ? t('common.loading') : t('login.forgotPasswordSubmit')}
|
|
</button>
|
|
</form>
|
|
<button type="button" className="al-forgot" onClick={back}>
|
|
{t('login.backToLogin')}
|
|
</button>
|
|
</>
|
|
)}
|
|
</AppAuthScreen>
|
|
);
|
|
}
|