Files
gatehouse-ui/src/pages/Index.tsx
T

23 lines
514 B
TypeScript
Raw Normal View History

2026-01-06 14:46:23 +00:00
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useAuth } from "@/contexts/AuthContext";
2025-01-01 00:00:00 +00:00
const Index = () => {
2026-01-06 14:46:23 +00:00
const navigate = useNavigate();
const { isAuthenticated, isLoading } = useAuth();
2026-01-06 14:46:23 +00:00
useEffect(() => {
if (isLoading) return; // Wait for auth check to complete
if (isAuthenticated) {
navigate("/profile");
} else {
navigate("/login");
}
}, [isLoading, isAuthenticated, navigate]);
2026-01-06 14:46:23 +00:00
return null;
2025-01-01 00:00:00 +00:00
};
export default Index;