1 import { useState } from 'react';
2 import { Link, useHistory } from 'react-router-dom';
4 import { c } from 'ttag';
6 import Alert from '@proton/components/components/alert/Alert';
7 import PrimaryButton from '@proton/components/components/button/PrimaryButton';
8 import EmailInput from '@proton/components/components/input/EmailInput';
9 import useApi from '@proton/components/hooks/useApi';
10 import useNotifications from '@proton/components/hooks/useNotifications';
11 import { useLoading } from '@proton/hooks';
12 import { requestUsername } from '@proton/shared/lib/api/reset';
14 const MinimalForgotUsernameContainer = () => {
16 const history = useHistory();
17 const [loading, withLoading] = useLoading();
18 const { createNotification } = useNotifications();
19 const [email, setEmail] = useState('');
21 const handleSubmit = async () => {
22 await api(requestUsername({ Email: email }));
25 .t`If you entered a valid notification email we will send you an email with your usernames in the next minute`,
27 history.push('/login');
34 withLoading(handleSubmit());
37 <Alert className="mb-4">{c('Info')
38 .t`Enter your recovery email address, and we'll send you your username(s). (This is usually the email address you provided during signup.)`}</Alert>
39 <div className="mb-4">
46 placeholder={c('Placeholder').t`Email`}
48 onChange={({ target }) => setEmail(target.value)}
52 <div className="flex flex-nowrap justify-space-between mb-4">
53 <Link to="/login">{c('Link').t`Back to login`}</Link>
54 <PrimaryButton loading={loading} type="submit">{c('Action').t`Email me my username(s)`}</PrimaryButton>
60 export default MinimalForgotUsernameContainer;