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 { Logo } from "components/Logo" import { Link } from "react-router-dom" import useMutation from "use-mutation" export function RegistrationPage() { const serverInfos = useAppSelector(state => state.server.serverInfos) const dispatch = useAppDispatch() const form = useForm({ initialValues: { name: "", password: "", email: "", }, }) const [register, registerResult] = useMutation(client.user.register, { onSuccess: () => { dispatch(redirectToRootCategory()) }, }) const errors = errorToStrings(registerResult.error) return (
CommaFeed
<Trans>Sign up</Trans> {serverInfos && !serverInfos.allowRegistrations && ( )} {serverInfos?.allowRegistrations && ( <> {errors.length > 0 && ( )}
Have an account? Log in!
)}
) }