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

24 lines
663 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, isOrgMember, isLoading } = useAuth();
2026-01-06 14:46:23 +00:00
useEffect(() => {
if (isLoading) return; // Wait for auth check to complete
if (isAuthenticated) {
// If the user has no org yet, send them to the org-setup page first
navigate(isOrgMember ? "/profile" : "/org-setup", { replace: true });
} else {
navigate("/login");
}
}, [isLoading, isAuthenticated, isOrgMember, navigate]);
2026-01-06 14:46:23 +00:00
return null;
2025-01-01 00:00:00 +00:00
};
export default Index;