Add debug logging to FamilyProvider

Move admin check to top-level useEffect before any async calls.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Manohar Gupta 2026-05-17 11:13:01 +05:30
parent e7539468c1
commit 754a602e48

View file

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