import { t, Trans } from "@lingui/macro" import { Anchor, Box, Button, Center, Container, Group, Paper, PasswordInput, Stack, TextInput, Title } from "@mantine/core" import { useForm } from "@mantine/form" import { client, errorToStrings } from "app/client" import { redirectToRootCategory } from "app/slices/redirect" import { useAppDispatch, useAppSelector } from "app/store" import { RegistrationRequest } from "app/types" import { Alert } from "components/Alert" import { PageTitle } from "pages/PageTitle" import { useAsyncCallback } from "react-async-hook" import { Link } from "react-router-dom" export function RegistrationPage() { const serverInfos = useAppSelector(state => state.server.serverInfos) const dispatch = useAppDispatch() const form = useForm({ initialValues: { name: "", password: "", email: "", }, }) const register = useAsyncCallback(client.user.register, { onSuccess: () => { dispatch(redirectToRootCategory()) }, }) return ( <Trans>Sign up</Trans> {serverInfos && !serverInfos.allowRegistrations && ( )} {serverInfos?.allowRegistrations && ( <> {register.error && ( )}
E-mail address} placeholder={t`E-mail address`} {...form.getInputProps("email")} size="md" required /> Password} placeholder={t`Password`} {...form.getInputProps("password")} size="md" required />
Have an account? Log in!
)}
) }