'use client' import React, { useState } from 'react' import { Label } from '../ui/label' import { Input } from '../ui/input' import Link from 'next/link' import { Button } from '../ui/button' import { signIn } from 'next-auth/react' import { useRouter } from 'next/navigation' export default function LoginForm() { const [email, setEmail] = useState(''); const [password, setPassword] = useState('') const [error, setError] = useState(''); const router = useRouter(); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); const result = await signIn('credentials', { redirect: false, email, password, }) console.log('[CLIENT] signIn result:', result) if (result?.error) { setError(result.error) } else { router.push('/dashboard') } } return (
setEmail(e.target.value)} required />
Forgot your password?
setPassword(e.target.value)} required />
{error &&

{error}

}
) }