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/redirect/thunks" import { useAppDispatch, useAppSelector } from "app/store" import { type LoginRequest } 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 LoginPage() { const serverInfos = useAppSelector(state => state.server.serverInfos) const dispatch = useAppDispatch() const form = useForm({ initialValues: { name: "", password: "", }, }) const login = useAsyncCallback(client.user.login, { onSuccess: () => { dispatch(redirectToRootCategory()) }, }) return ( <Trans>Log in</Trans> {login.error && ( )}
User Name or E-mail} placeholder={t`User Name or E-mail`} {...form.getInputProps("name")} description={ serverInfos?.demoAccountEnabled ? Try out CommaFeed with the demo account: demo/demo : "" } size="md" required /> Password} placeholder={t`Password`} {...form.getInputProps("password")} size="md" required /> {serverInfos?.smtpEnabled && ( Forgot password? )} {serverInfos?.allowRegistrations && (
Need an account? Sign up!
)}
) }