2025-12-20 19:22:20 +05:30
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
import { useRouter } from 'next/navigation';
|
|
|
|
|
import { useAuth } from '@/context/AuthContext';
|
2025-12-19 01:18:25 +05:30
|
|
|
|
|
|
|
|
export default function Home() {
|
2025-12-20 19:22:20 +05:30
|
|
|
const { isAuthenticated, isLoading } = useAuth();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!isLoading) {
|
|
|
|
|
if (isAuthenticated) {
|
|
|
|
|
router.push('/dashboard');
|
|
|
|
|
} else {
|
|
|
|
|
router.push('/login');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [isAuthenticated, isLoading, router]);
|
|
|
|
|
|
2025-12-19 01:18:25 +05:30
|
|
|
return (
|
2025-12-20 19:22:20 +05:30
|
|
|
<div className="min-h-screen flex items-center justify-center bg-gray-100">
|
|
|
|
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
|
2025-12-19 01:18:25 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|