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 { LoginRequest } 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 LoginPage() { const serverInfos = useAppSelector(state => state.server.serverInfos) const dispatch = useAppDispatch() const form = useForm({ initialValues: { name: "", password: "", }, }) const [login, loginResult] = useMutation(client.user.login, { onSuccess: () => { dispatch(redirectToRootCategory()) }, }) const errors = errorToStrings(loginResult.error) return (
CommaFeed
<Trans>Log in</Trans> {errors.length > 0 && ( )}
{serverInfos?.smtpEnabled && ( Forgot password? )} {serverInfos?.allowRegistrations && (
Need an account? Sign up!
)}
) }