'use client' import { useState } from 'react' import { signIn } from 'next-auth/react' import { useRouter } from 'next/navigation' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Button } from '@/components/ui/button' export default function LoginPage() { const router = useRouter() const [error, setError] = useState('') const [loading, setLoading] = useState(false) async function handleSubmit(e: React.FormEvent) { e.preventDefault() setError('') setLoading(true) const form = new FormData(e.currentTarget) const result = await signIn('credentials', { email: form.get('email') as string, password: form.get('password') as string, redirect: false, }) if (result?.error) { setError('Invalid email or password') setLoading(false) } else { router.push('/dashboard') } } return (
Sign in
{error && (

{error}

)}
) }