@@ -194,11 +194,24 @@ const TimetableBuilder = () => {
194194 // Parse restrictions data (For startTime and endTime, we just care about the time, so we use the random date of 2025-01-01 so that the date can be parsed correctly)
195195 // We also add 1 hour (i.e. 60 * 60 * 1000 milliseconds) to the time to account for the timezone difference between the server and the client
196196 const parsedRestrictions = restrictionsData . map (
197- ( restriction : Restriction ) => ( {
197+ ( restriction : Restriction ) =>
198+ ( {
198199 days : JSON . parse ( restriction ?. days ) as string [ ] ,
199200 disabled : restriction ?. disabled ,
200- startTime : restriction ?. start_time ? new Date ( new Date ( `2025-01-01T${ restriction . start_time } .00Z` ) . getTime ( ) + 60 * 60 * 1000 ) : undefined ,
201- endTime : restriction ?. end_time ? new Date ( new Date ( `2025-01-01T${ restriction . end_time } .00Z` ) . getTime ( ) + 60 * 60 * 1000 ) : undefined ,
201+ startTime : restriction ?. start_time
202+ ? new Date (
203+ new Date (
204+ `2025-01-01T${ restriction . start_time } .00Z` ,
205+ ) . getTime ( ) +
206+ 60 * 60 * 1000 ,
207+ )
208+ : undefined ,
209+ endTime : restriction ?. end_time
210+ ? new Date (
211+ new Date ( `2025-01-01T${ restriction . end_time } .00Z` ) . getTime ( ) +
212+ 60 * 60 * 1000 ,
213+ )
214+ : undefined ,
202215 type : restriction ?. type ,
203216 numDays : restriction ?. num_days ,
204217 } ) as z . infer < typeof RestrictionSchema > ,
@@ -386,7 +399,8 @@ const TimetableBuilder = () => {
386399 { ! isEditingTimetable ||
387400 ( isEditingTimetable &&
388401 loadedCourses &&
389- loadedOfferingIds && selectedCourses ) ? (
402+ loadedOfferingIds &&
403+ selectedCourses ) ? (
390404 selectedCourses . map ( ( course , index ) => {
391405 return (
392406 < div key = { index } >
@@ -466,37 +480,40 @@ const TimetableBuilder = () => {
466480 ) }
467481 />
468482 < div className = "flex gap-2 flex-col" >
469- { enabledRestrictions && enabledRestrictions . map ( ( restric , index ) => (
470- < div
471- key = { index }
472- className = "flex p-2 justify-between bg-red-100/50 text-xs rounded-md w-[64%]"
473- >
474- { restric . type . startsWith ( "Restrict" ) ? (
475- < p >
476- < strong > { restric . type } :</ strong > { " " }
477- { restric . startTime
478- ? formatTime ( restric . startTime )
479- : "" } { " " }
480- { restric . type === "Restrict Between" ? " - " : "" } { " " }
481- { restric . endTime
482- ? formatTime ( restric . endTime )
483- : "" } { " " }
484- { restric . days ?. join ( " " ) }
485- </ p >
486- ) : (
487- < p >
488- < strong > { restric . type } :</ strong > At least{ " " }
489- { restric . numDays } days off
490- </ p >
491- ) }
492-
493- < X
494- size = { 16 }
495- className = "hover:text-red-500 cursor-pointer"
496- onClick = { ( ) => handleRemoveRestriction ( index ) }
497- />
498- </ div >
499- ) ) }
483+ { enabledRestrictions &&
484+ enabledRestrictions . map ( ( restric , index ) => (
485+ < div
486+ key = { index }
487+ className = "flex p-2 justify-between bg-red-100/50 text-xs rounded-md w-[64%]"
488+ >
489+ { restric . type . startsWith ( "Restrict" ) ? (
490+ < p >
491+ < strong > { restric . type } :</ strong > { " " }
492+ { restric . startTime
493+ ? formatTime ( restric . startTime )
494+ : "" } { " " }
495+ { restric . type === "Restrict Between"
496+ ? " - "
497+ : "" } { " " }
498+ { restric . endTime
499+ ? formatTime ( restric . endTime )
500+ : "" } { " " }
501+ { restric . days ?. join ( " " ) }
502+ </ p >
503+ ) : (
504+ < p >
505+ < strong > { restric . type } :</ strong > At least{ " " }
506+ { restric . numDays } days off
507+ </ p >
508+ ) }
509+
510+ < X
511+ size = { 16 }
512+ className = "hover:text-red-500 cursor-pointer"
513+ onClick = { ( ) => handleRemoveRestriction ( index ) }
514+ />
515+ </ div >
516+ ) ) }
500517 </ div >
501518 </ div >
502519
0 commit comments