Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 12f04a0

Browse files
committed
add: docs, clarity
1 parent 2d8959d commit 12f04a0

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

app/(with-layout)/event/schedule/page.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@ import type { Event } from "@/data/schedule";
66
import {
77
saturdayTimes,
88
sundayTimes,
9-
SATURDAY_START,
10-
SUNDAY_START
119
} from "@/data/schedule";
1210

1311
import Schedule from "@/components/schedule/schedule";
1412
import 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 = {
3026
const DEFAULT_WIDTH = 1;
3127
const 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+
}

app/api/mongodb.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ dotenv.config({path:"./config.env"});
55

66
const MONGO_URI = process.env.MONGO_URI;
77

8+
// connect to DB
9+
// being called twice, see https://github.com/vercel/next.js/issues/37715
810
export async function connectDB() {
911
if (MONGO_URI) {
1012
const connectDB = mongoose

0 commit comments

Comments
 (0)