diff --git a/layout/Speakers/components/Schedule/index.jsx b/layout/Speakers/components/Schedule/index.jsx index e8842698..0ec96ad9 100644 --- a/layout/Speakers/components/Schedule/index.jsx +++ b/layout/Speakers/components/Schedule/index.jsx @@ -3,6 +3,8 @@ import { useState, useEffect } from "react"; import Day from "./Day"; import Table from "./Table"; +import scheduleData from "/data/schedule.json"; + function isAfter(date1, date2) { // equivalent to date1 > date2 const arr1 = date1.split("/"); @@ -61,8 +63,10 @@ function addDate(date, days) { } export default function Schedule(props) { - const min_date = "2023/2/14"; - const max_date = "2023/2/17"; + /* Fetch first and last day of the event from schedule data */ + const eventDates = scheduleData.map((day) => day.date).sort(); + const min_date = eventDates[0]; + const max_date = eventDates[eventDates.length - 1]; //calculate default date const _today = new Date(); diff --git a/layout/shared/Leaderboard/Leaderboard.tsx b/layout/shared/Leaderboard/Leaderboard.tsx index 26a3d7af..03f0d747 100644 --- a/layout/shared/Leaderboard/Leaderboard.tsx +++ b/layout/shared/Leaderboard/Leaderboard.tsx @@ -11,6 +11,9 @@ import ErrorMessage from "@components/ErrorMessage"; import { getLeaderboard } from "@lib/api"; +import scheduleData from "@data/schedule.json"; +import dayjs from "dayjs"; + function leapYear(year) { return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; } @@ -72,8 +75,12 @@ function addDate(date, days) { } function Leaderboard() { - const min_date = "2023/02/14"; - const max_date = "2023/02/17"; + /* Fetch first and last day of the event from schedule data */ + const eventDates = scheduleData.map((day) => day.date).sort(); + const min_date = dayjs(eventDates[0]).format("YYYY/MM/DD"); + const max_date = dayjs(eventDates[eventDates.length - 1]).format( + "YYYY/MM/DD" + ); const _today = new Date().toISOString().split("T")[0]; const today = _today.replace(/-/g, "/");