Fix FamilyProvider admin check - move inside useEffect

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Manohar Gupta 2026-05-17 11:03:54 +05:30
parent 70376d2e96
commit e7539468c1

View file

@ -49,13 +49,14 @@ export function FamilyProvider({ children: providerChildren }: { children: React
const [memberCount, setMemberCount] = useState(2); const [memberCount, setMemberCount] = useState(2);
useEffect(() => { useEffect(() => {
async function fetchFamilyData() {
// Skip family check for admin pages // Skip family check for admin pages
if (typeof window !== "undefined" && window.location.pathname.startsWith("/admin")) { const path = window.location.pathname;
if (path.startsWith("/admin") || path === "/admin-login") {
setLoading(false); setLoading(false);
return; return;
} }
async function fetchFamilyData() {
try { try {
// Get current session from database // Get current session from database
const sessionRes = await fetch("/api/auth/signin"); const sessionRes = await fetch("/api/auth/signin");