@@ -6,16 +6,12 @@ import type { Event } from "@/data/schedule";
66import {
77 saturdayTimes ,
88 sundayTimes ,
9- SATURDAY_START ,
10- SUNDAY_START
119} from "@/data/schedule" ;
1210
1311import Schedule from "@/components/schedule/schedule" ;
1412import HackRPILink from "@/components/themed-components/hackrpi-link" ;
15- import scheduleData from "@/data/scheduleData.json" ;
16- import { GET } from "@/app/api/schedule/route" ;
1713
18- type MongoEvent = {
14+ type RawEvent = {
1915 _id : string ;
2016 name : string ;
2117 location : string ;
@@ -30,7 +26,8 @@ type MongoEvent = {
3026const DEFAULT_WIDTH = 1 ;
3127const isSaturday = ( date : Date ) => date . getDay ( ) === 6 ; // Saturday is day 6 (0=Sun, 6=Sat)
3228
33- function convertToEvent ( ev : MongoEvent ) : Event {
29+ // convert fetched data from DB to Event Type
30+ function convertToEvent ( ev : RawEvent ) : Event {
3431 const startTime = new Date ( ev . start_time ) . getTime ( ) ;
3532 const endTime = new Date ( ev . end_time ) . getTime ( ) ;
3633
@@ -81,8 +78,7 @@ export default function Page() {
8178 throw new Error ( "Failed to fetch schedule data" ) ;
8279 }
8380
84- const rawEvents : MongoEvent [ ] = await response . json ( ) ;
85-
81+ const rawEvents : RawEvent [ ] = await response . json ( ) ;
8682 const satEvents : Event [ ] = [ ] ;
8783 const sunEvents : Event [ ] = [ ] ;
8884
@@ -99,9 +95,11 @@ export default function Page() {
9995 }
10096 } ) ;
10197
102- // TODO: fix infinite loop
98+ // TODO: investigate possibility of infinite re-rendering
99+ // update saturdayEvents and sundayEvents arrays
103100 setSaturdayEvents ( satEvents ) ;
104101 setSundayEvents ( sunEvents ) ;
102+
105103 setState ( "loaded" ) ;
106104 } catch ( e ) {
107105 console . error ( e ) ;
@@ -229,4 +227,4 @@ export default function Page() {
229227 </ div >
230228 </ div >
231229 ) ;
232- }
230+ }
0 commit comments