import { Alert, Button, Card, Checkbox, Paper, PasswordInput, Text, TextInput, Title, } from '@pikku/mantine/core'; import { useForm } from 'react-hook-form'; import { useI18n } from '@/context/i18n-provider'; import classes from './LoginComponent.module.css'; export type LoginFormData = { email: string; password: string; rememberMe: boolean; }; export interface LoginComponentProps { namespace: 'backoffice' | 'company'; mutation: { mutateAsync: (data: { email: string; password: string }) => Promise; isPending: boolean; error: Error | null; }; } export function LoginComponent({ namespace, mutation }: LoginComponentProps) { const t = useI18n(); const { register, handleSubmit, formState: { errors }, } = useForm({ defaultValues: { email: '', password: '', rememberMe: false, }, }); const onSubmit = async (data: LoginFormData) => { await mutation.mutateAsync({ email: data.email, password: data.password, }) }; return (
{t(`login.${namespace}.title` as any)}
{mutation.error && ( {t('login.error.message')} )}
); }