'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { useAuth } from './contexts/AuthContext' export default function LoginPage() { const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState('') const { login } = useAuth() const router = useRouter() const handleSubmit = (e: React.FormEvent) => { e.preventDefault() setError('') if (login(username, password)) { router.push('/dashboard') } else { setError('Invalid credentials') } } return (

Login

setUsername(e.target.value)} className="w-full rounded-md border border-gray-300 px-3 py-2 text-black focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-zinc-50" required />
setPassword(e.target.value)} className="w-full rounded-md border border-gray-300 px-3 py-2 text-black focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-zinc-50" required />
{error && (

{error}

)}
) }