'use client'; import { signIn } from 'next-auth/react'; import { useState } from 'react'; export default function SignIn() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const handleCredentialsLogin = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(''); try { const result = await signIn('credentials', { email, password, redirect: false }); if (result?.error) { setError('Invalid credentials'); } else { window.location.href = '/'; } } catch (err) { setError('Login failed'); } finally { setLoading(false); } }; return (
Sign in to your account
{error && (Don't have an account?{' '} Sign up