'use client'; import { useMutation } from '@tanstack/react-query'; import { useRouter } from '@/i18n/navigation'; import { useT } from '@/i18n/t'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { authClient } from '@/lib/auth-client'; export function LoginForm() { const t = useT(); const router = useRouter(); const signIn = useMutation({ mutationFn: async (form: { email: string; password: string }) => { const { error } = await authClient.signIn.email(form); if (error) throw new Error(error.message ?? 'sign_in_failed'); }, onSuccess: () => router.push('/inicio'), }); return (

{t('auth.login.title')}

{ event.preventDefault(); const data = new FormData(event.currentTarget); signIn.mutate({ email: String(data.get('email') ?? ''), password: String(data.get('password') ?? ''), }); }} >
{signIn.isError ? (

{t('auth.login.failed')}

) : null}
); }