@@ -3,6 +3,8 @@ import Period from "./Period";
33import { DateTime } from "luxon" ;
44import { useDtt } from "../../../services/sbhsApi/useDtt" ;
55import { TimetablPeriod } from "../../../services/sbhsApi/schemas" ;
6+ import Empty from "../../../components/Empty" ;
7+ import { GiFrenchFries } from "react-icons/gi" ;
68
79export default function Schedule ( { date } : { date ?: string } ) {
810 const { data : dtt } = useDtt ( date ) ;
@@ -22,27 +24,37 @@ export default function Schedule({ date }: { date?: string }) {
2224
2325 return (
2426 < Flex direction = { "column" } >
25- { periods
26- . filter ( ( period ) => ! period . name . startsWith ( "Transition" ) )
27- . map ( ( period ) => {
28- const startTime = DateTime . fromISO ( period . startTime ) ;
29- const endTime = DateTime . fromISO ( period . endTime ) ;
27+ { periods . length ? (
28+ periods
29+ . filter ( ( period ) => ! period . name . startsWith ( "Transition" ) )
30+ . map ( ( period ) => {
31+ const startTime = DateTime . fromISO ( period . startTime ) ;
32+ const endTime = DateTime . fromISO ( period . endTime ) ;
3033
31- const duration = endTime . diff ( startTime ) . as ( "minutes" ) ;
34+ const duration = endTime . diff ( startTime ) . as ( "minutes" ) ;
3235
33- if ( duration <= 10 ) {
34- return null ;
35- }
36+ if ( duration <= 10 ) {
37+ return null ;
38+ }
3639
37- return (
38- // eslint-disable-next-line react/jsx-key -- because key is included in period
39- < Period
40- isLoaded = { ! ! dtt }
41- { ...period }
42- active = { period . key === activeKey }
43- />
44- ) ;
45- } ) }
40+ return (
41+ // eslint-disable-next-line react/jsx-key -- because key is included in period
42+ < Period
43+ isLoaded = { ! ! dtt }
44+ { ...period }
45+ active = { period . key === activeKey }
46+ />
47+ ) ;
48+ } )
49+ ) : (
50+ < Empty
51+ icon = { GiFrenchFries }
52+ colour = "yellow.500"
53+ size = "lg"
54+ heading = "No periods on this day"
55+ text = "Chill out, grab some snacks, and enjoy your day off!"
56+ />
57+ ) }
4658 </ Flex >
4759 ) ;
4860}
0 commit comments