'use client'; import { useState } from 'react'; import { useAuth } from '@/contexts/AuthContext'; import { useRouter } from 'next/navigation'; import { useEffect } from 'react'; export default function LoginPage() { const [auth, setAuth] = useState(''); const [password, setPassword] = useState(''); const [localError, setLocalError] = useState(''); const { login, isLoading, error, token } = useAuth(); const router = useRouter(); useEffect(() => { if (token) { router.push('/admin/dashboard'); } }, [token, router]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLocalError(''); if (!auth || !password) { setLocalError('Please fill in all fields'); return; } try { await login({ auth, password }); } catch (err) { // Error is handled by context } }; return (

پنل ادمین اپروایجنسی

setAuth(e.target.value)} disabled={isLoading} />
setPassword(e.target.value)} disabled={isLoading} />
{(error || localError) && (

{localError || error}

)}
); }