'use client'; import { useState } from 'react'; import { useAuth } from '@/context/AuthContext'; import { useRouter } from 'next/navigation'; import { useEffect } from 'react'; export default function LoginPage() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const { login, isAuthenticated, isLoading } = useAuth(); const router = useRouter(); useEffect(() => { if (!isLoading && isAuthenticated) { router.push('/dashboard'); } }, [isAuthenticated, isLoading, router]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setIsSubmitting(true); try { await login(email, password); } catch (err) { setError(err instanceof Error ? err.message : 'Login failed'); } finally { setIsSubmitting(false); } }; if (isLoading) { return (
Platform Administration
Only administrators can access this portal