This commit is contained in:
2025-11-14 14:47:26 +00:00
parent 69ecf2c7c1
commit 3b4876793e
104 changed files with 231517 additions and 1029 deletions
+16 -7
View File
@@ -29,6 +29,13 @@ export const NeoInstituteProvider: React.FC<{ children: ReactNode }> = ({ childr
const [error, setError] = useState<string | null>(null);
useEffect(() => {
logger.debug('neo-institute-context', '🔄 useEffect triggered', {
isUserInitialized,
hasProfile: !!profile,
hasUser: !!user,
isInitialized
});
// Wait for user profile to be ready
if (!isUserInitialized) {
logger.debug('neo-institute-context', '⏳ Waiting for user initialization...');
@@ -39,6 +46,7 @@ export const NeoInstituteProvider: React.FC<{ children: ReactNode }> = ({ childr
if (!profile || !profile.school_db_name) {
setIsLoading(false);
setIsInitialized(true);
logger.debug('neo-institute-context', '️ No school database; marking institute context ready');
return;
}
@@ -54,7 +62,7 @@ export const NeoInstituteProvider: React.FC<{ children: ReactNode }> = ({ childr
if (node) {
setSchoolNode(node);
logger.debug('neo-institute-context', '✅ School node loaded', {
schoolId: node.unique_id,
schoolId: node.uuid_string,
dbName: profile.school_db_name
});
} else {
@@ -68,14 +76,15 @@ export const NeoInstituteProvider: React.FC<{ children: ReactNode }> = ({ childr
schoolDbName: profile.school_db_name
});
setError(errorMessage);
} finally {
setIsLoading(false);
setIsInitialized(true);
}
};
} finally {
setIsLoading(false);
setIsInitialized(true);
logger.debug('neo-institute-context', '✅ Institute context initialization complete');
}
};
loadSchoolNode();
}, [user?.email, profile, isUserInitialized]);
}, [user, profile, isUserInitialized, isInitialized]);
return (
<NeoInstituteContext.Provider value={{