latest
This commit is contained in:
@@ -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={{
|
||||
|
||||
Reference in New Issue
Block a user