import React, { FC, useState, useCallback } from 'react'; import { useTranslation } from 'next-i18next'; import Link from 'next/link'; import { apiv3Post } from '~/client/util/apiv3-client'; import { toastSuccess, toastError } from '~/client/util/toastr'; import { useIsMailerSetup } from '~/stores/context'; const PasswordResetRequestForm: FC = () => { const { t } = useTranslation(); const { data: isMailerSetup } = useIsMailerSetup(); const [email, setEmail] = useState(''); const changeEmail = useCallback((inputValue) => { setEmail(inputValue); }, []); const sendPasswordResetRequestMail = useCallback(async(e) => { e.preventDefault(); if (email === '') { toastError(t('forgot_password.email_is_required')); return; } try { await apiv3Post('/forgot-password', { email }); toastSuccess(t('forgot_password.success_to_send_email')); } catch (err) { toastError(err); } }, [t, email]); return (
{!isMailerSetup ? (
{t('forgot_password.please_enable_mailer_alert')}
) : ( <> {/* lock-icon large */}

lock

{ t('forgot_password.forgot_password') }

{t('forgot_password.password_reset_request_desc')}

changeEmail(e.target.value)} />
)} login{t('forgot_password.return_to_login')}
); }; export default PasswordResetRequestForm;