'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 (
); } return (
{/* Header */}

Re-Quest Admin

Re-Quest Platform Administration

{/* Error Alert */} {error && (
{error}
)} {/* Login Form */}
setEmail(e.target.value)} required className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors text-gray-900 placeholder:text-gray-400 bg-white" placeholder="admin@realestate.com" />
setPassword(e.target.value)} required className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors text-gray-900 placeholder:text-gray-400 bg-white" placeholder="Enter your password" />
{/* Footer */}

Only administrators can access this portal

); }