11import { useEffect } from 'react' ;
22import Link from 'next/link' ;
3+ import { isValidTimetableFrameId } from 'api/timetable/queries' ;
34import ErrorBoundary from 'components/boundary/ErrorBoundary' ;
45import Timetable from 'components/TimetablePage/components/Timetable' ;
56import useSemesterOptionList from 'components/TimetablePage/hooks/useSemesterOptionList' ;
@@ -19,34 +20,34 @@ export default function IndexTimeTable() {
1920 const token = useTokenState ( ) ;
2021 const { data : timetableFrameList } = useTimetableFrameList ( token , semester ) ;
2122
22- const currentFrameId = timetableFrameList ?. find ( ( frame ) => frame . is_main ) ?. id ?? 0 ;
23+ const currentFrameId = timetableFrameList ?. find ( ( frame ) => frame . is_main ) ?. id ;
24+ const hasValidCurrentFrameId = isValidTimetableFrameId ( currentFrameId ) ;
2325 const isClient = useMount ( ) ;
2426
2527 useEffect ( ( ) => {
2628 if ( semesterOptionList . length > 0 ) updateSemester ( semesterOptionList [ 0 ] . value ) ;
2729 } , [ semesterOptionList , updateSemester ] ) ;
2830
29- const renderTimetable = (
31+ const renderPlaceholder = (
3032 < Timetable
31- timetableFrameId = { currentFrameId }
33+ timetableFrameId = { 0 }
3234 columnWidth = { 44 }
3335 firstColumnWidth = { 29 }
3436 rowHeight = { 17.3 }
3537 totalHeight = { 369 }
3638 />
3739 ) ;
3840
39- const renderPlaceholder = (
40- < div
41- aria-hidden
42- style = { {
43- height : 369 ,
44- width : '100%' ,
45- borderRadius : 12 ,
46- backgroundColor : '#f7f8fa' ,
47- border : '1px solid #e4e8ee' ,
48- } }
41+ const renderTimetable = hasValidCurrentFrameId ? (
42+ < Timetable
43+ timetableFrameId = { currentFrameId }
44+ columnWidth = { 44 }
45+ firstColumnWidth = { 29 }
46+ rowHeight = { 17.3 }
47+ totalHeight = { 369 }
4948 />
49+ ) : (
50+ renderPlaceholder
5051 ) ;
5152
5253 return (
0 commit comments