27 lines
676 B
TypeScript
27 lines
676 B
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
import { useAuth } from '@/context/AuthContext';
|
|
|
|
export default function Home() {
|
|
const { isAuthenticated, isLoading } = useAuth();
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
if (!isLoading) {
|
|
if (isAuthenticated) {
|
|
router.push('/dashboard');
|
|
} else {
|
|
router.push('/login');
|
|
}
|
|
}
|
|
}, [isAuthenticated, isLoading, router]);
|
|
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-[#f5f9f8]">
|
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-[#f5a623]"></div>
|
|
</div>
|
|
);
|
|
}
|