2025-07-23 22:26:54 -04:00
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
|
import { useAuth } from '../lib/auth-context.js';
|
|
|
|
|
|
2025-07-23 10:32:31 -04:00
|
|
|
export default function Home() {
|
2025-07-23 22:26:54 -04:00
|
|
|
const { user, loading } = useAuth();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!loading) {
|
|
|
|
|
if (user) {
|
|
|
|
|
router.push('/dashboard');
|
|
|
|
|
} else {
|
|
|
|
|
router.push('/login');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [user, loading, router]);
|
|
|
|
|
|
|
|
|
|
// Show loading while determining redirect
|
2025-07-23 10:32:31 -04:00
|
|
|
return (
|
2025-07-23 22:26:54 -04:00
|
|
|
<div className="min-h-screen bg-gray-50 flex items-center justify-center">
|
2025-07-23 10:32:31 -04:00
|
|
|
<div className="text-center">
|
2025-07-23 22:26:54 -04:00
|
|
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto"></div>
|
|
|
|
|
<p className="mt-4 text-gray-600">Loading...</p>
|
2025-07-23 10:32:31 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|