import { msg } from "@lingui/core/macro" import { useLingui } from "@lingui/react" import { Trans } from "@lingui/react/macro" import { Anchor, Box, Button, Center, Container, Group, Paper, Stack, TextInput, Title } from "@mantine/core" import { useForm } from "@mantine/form" import { client, errorToStrings } from "app/client" import type { PasswordResetRequest } from "app/types" import { Alert } from "components/Alert" import { PageTitle } from "pages/PageTitle" import { useState } from "react" import { useAsyncCallback } from "react-async-hook" import { Link } from "react-router-dom" export function PasswordRecoveryPage() { const [message, setMessage] = useState("") const { _ } = useLingui() const form = useForm({ initialValues: { email: "", }, }) const recoverPassword = useAsyncCallback(client.user.passwordReset, { onSuccess: () => { setMessage(_(msg`An email has been sent if this address was registered. Check your inbox.`)) }, }) return ( <Trans>Password Recovery</Trans> {recoverPassword.error && ( )} {message && ( )}
{ setMessage("") recoverPassword.execute(req) })} > E-mail} placeholder={_(msg`E-mail`)} {...form.getInputProps("email")} size="md" required />
Back to log in
) }