From 313ab724b808ac349f2f82cf6912d734d19be8be Mon Sep 17 00:00:00 2001 From: CC Worker Date: Tue, 2 Jun 2026 23:28:26 +0000 Subject: [PATCH] fix(my-classes): add selectedInstituteId to fetch dependency, silence unhandled rejection Re-fetch classes when NeoInstitute context changes. Catch fetchMyClasses rejection with logger.warn so unhandled promise rejections don't break the component boundary silently. Use CircularProgress (MUI) for loading skeleton. Co-Authored-By: Claude Sonnet 4.6 --- src/pages/timetable/MyClassesPage.tsx | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/pages/timetable/MyClassesPage.tsx b/src/pages/timetable/MyClassesPage.tsx index d097ea4..b5f1628 100644 --- a/src/pages/timetable/MyClassesPage.tsx +++ b/src/pages/timetable/MyClassesPage.tsx @@ -3,9 +3,19 @@ import { Link } from 'react-router-dom'; import { AccessTime, KeyboardArrowRight, MenuBook, People, School } from '@mui/icons-material'; import useTimetableStore from '../../stores/timetableStore'; import { useUser } from '../../contexts/UserContext'; +import { useNeoInstitute } from '../../contexts/NeoInstituteContext'; +import { CircularProgress } from '@mui/material'; +import { logger } from '../../debugConfig'; + +const MyClassesSkeleton = () => ( +
+ +
+); const MyClassesPage: React.FC = () => { const { profile } = useUser(); + const { selectedInstituteId } = useNeoInstitute(); const { myClasses, classesLoading: myClassesLoading, @@ -14,8 +24,16 @@ const MyClassesPage: React.FC = () => { } = useTimetableStore(); useEffect(() => { - fetchMyClasses(); - }, [fetchMyClasses]); + fetchMyClasses().catch((error) => + logger.warn('my-classes', 'Fetch my classes failed', { + message: error instanceof Error ? error.message : String(error), + }) + ); + }, [fetchMyClasses, selectedInstituteId]); + + if (myClassesLoading) { + return ; + } const getRoleLabel = (role: string) => { switch (role) { @@ -36,14 +54,6 @@ const MyClassesPage: React.FC = () => { } }; - if (myClassesLoading) { - return ( -
-
-
- ); - } - if (myClassesError) { return (