(true);
useEffect(() => {
const checkPageBlockState = async () => {
try {
const state = await PageBlockService.getPageBlockState();
setIsPageBlocked(state.isPageBlocked);
} catch (error) {
console.error('Error checking page block state:', error);
setIsPageBlocked(false); // Default to unblocked on error
} finally {
setIsLoading(false);
}
};
checkPageBlockState();
}, []);
useEffect(() => {
// Set up a listener for authentication state changes
const unsubscribe = onAuthStateChanged(auth, (user) => {
setIsAuthenticated(!!user);
});
// Clean up the listener on component unmount
return () => unsubscribe();
}, []);
if (isLoading) {
return Cargando configuración...
;
}
// If page is blocked and user is not authenticated, show login page
if (isPageBlocked && !isAuthenticated) {
return (
} />
} />
);
}
// If user is authenticated, unlock all pages
if (isAuthenticated) {
return (
} />
} />
} />
} />
} />
} />
);
}
// Normal routes without protection (page not blocked, user not authenticated)
return (
} />
} />
} />
} />
} />
} />
);
};
const rootElement = document.getElementById('root');
if (rootElement) {
createRoot(rootElement).render(
);
}