import { Alert, Button, Card, Flex, PasswordInput, Stack, Text, TextInput, Title, } from '@mantine/core'; import { useForm, zodResolver } from '@mantine/form'; import { showNotification, updateNotification } from '@mantine/notifications'; import { IconAlertCircle, IconAlertTriangle, IconCheck, IconX } from '@tabler/icons-react'; import axios from 'axios'; import { setCookie } from 'cookies-next'; import { signIn } from 'next-auth/react'; import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useRouter } from 'next/router'; import { z } from 'zod'; import { signInSchema } from '~/validations/user'; import { loginNamespaces } from '../tools/server/translation-namespaces'; export default function LoginPage() { const { t } = useTranslation('authentication/login'); const queryParams = useRouter().query as { error?: 'CredentialsSignin' | (string & {}) }; const form = useForm>({ validateInputOnChange: true, validateInputOnBlur: true, validate: zodResolver(signInSchema), }); const handleSubmit = (values: z.infer) => { signIn('credentials', { redirect: true, name: values.name, password: values.password, callbackUrl: '/', }); }; return ( {t('title')} {t('text')}
{queryParams.error === 'CredentialsSignin' && ( } color="red"> {t('alert')} )}
); } export async function getServerSideProps({ locale }: { locale: string }) { return { props: { ...(await serverSideTranslations(locale, loginNamespaces)), // Will be passed to the page component as props }, }; }