@@ -16,13 +16,11 @@ import TableRow from '@mui/material/TableRow';
1616import TableBody from '@mui/material/TableBody' ;
1717import TableCell from '@mui/material/TableCell' ;
1818import Base from '../../src/components/Base.jsx'
19- import FilterListIcon from '@mui/icons-material/FilterList' ;
2019import SchoolIcon from '@mui/icons-material/School' ;
2120import DeleteIcon from '@mui/icons-material/Delete' ;
2221import EditIcon from '@mui/icons-material/Edit' ;
2322import render , { useAppContext } from '../../src/render.jsx' ;
2423import { getCookie } from '../../src/utils.js' ;
25- import FilterForm from './components/FilterForm.jsx' ;
2624import { lazy , Suspense } from "react" ;
2725
2826const CourseForm = lazy ( ( ) => import ( "./components/CourseForm.jsx" ) ) ;
@@ -38,6 +36,7 @@ function Courses() {
3836 const [ organizationId , setOrganizationId ] = useState ( null ) ;
3937 const [ queryParameters , setQueryParameters ] = useState ( "" ) ;
4038 const { direction, localeMessages, apiBaseUrl, platformBaseUrl, userRole, languageOptions = [ ] } = useAppContext ( ) ;
39+ const [ coursesAreLoaded , setCoursesAreLoaded ] = useState ( false ) ;
4140
4241 const getLanguageLabel = ( languageCode ) => {
4342 return languageOptions . find ( ( languageOption ) => languageOption . value === languageCode ) ?. label || languageCode ;
@@ -56,7 +55,10 @@ function Courses() {
5655 } ,
5756 } )
5857 . then ( response => response . json ( ) )
59- . then ( data => setCourses ( data . courses ) )
58+ . then ( data => {
59+ setCourses ( data . courses ) ;
60+ setCoursesAreLoaded ( true ) ;
61+ } )
6062 . catch ( error => console . error ( 'Error fetching courses:' , error ) ) ;
6163 } ;
6264
@@ -131,7 +133,7 @@ function Courses() {
131133 createMode = { true }
132134 /> </ Suspense > ) ;
133135 setDialogOpen ( true ) ; } } > { localeMessages [ "add_course" ] } </ Button > }
134- < TableContainer component = { Paper } >
136+ { coursesAreLoaded ? < TableContainer component = { Paper } >
135137 < Table aria-label = { localeMessages [ "courses" ] } >
136138 < TableHead >
137139 < TableRow >
@@ -183,7 +185,7 @@ function Courses() {
183185 ) }
184186 </ TableBody >
185187 </ Table >
186- </ TableContainer >
188+ </ TableContainer > : < LinearProgress /> }
187189 </ Box >
188190 </ Grid >
189191
0 commit comments