diff --git a/packages/website/src/components/Timetable.tsx b/packages/website/src/components/Timetable.tsx index e20c7f2..e18e11e 100644 --- a/packages/website/src/components/Timetable.tsx +++ b/packages/website/src/components/Timetable.tsx @@ -5,10 +5,43 @@ const Timetable: Component = (props) => { const today = new Date(); const today_index = today.getDate(); + console.log(props.lessons) + // is the lesson is for today (look at the day) const lessons_of_today = () => props.lessons.filter( lesson => new Date(lesson.start_date).getDate() === today_index - ); + ).filter(lesson => { + let isForG1A = false; + + switch (lesson.type) { + case "TP": + // We only want to keep the TP lessons that are + // for the subgroup A and the group 1. + if (lesson.group.sub === 0 && lesson.group.main === 1) { + isForG1A = true; + } + break; + + // Since TD lessons are the whole group, we don't + // need to check the subgroup. + case "TD": + // We only want to keep the TD lessons that are + // for the group 1. + if (lesson.group.main === 1) { + isForG1A = true; + } + break; + + // Since CM lessons are for the whole year, we don't + // need to check the group and subgroup. + case "CM": + isForG1A = true; + break; + } + + return isForG1A; + + }) const start_date = () => new Date(props.header.start_date); const end_date = () => new Date(props.header.end_date) @@ -18,8 +51,9 @@ const Timetable: Component = (props) => { {lesson => (
-

{new Date(lesson.start_date).getHours()}:{new Date(lesson.start_date).getMinutes()}

-

{lesson.content.room}

+ {lesson.start_date} +

{new Date(lesson.start_date).getHours()}:{new Date(lesson.start_date).getMinutes().toString().padStart(2, "0")}

+

{lesson.type}: {lesson.content.room}

)}
diff --git a/packages/website/src/routes/index.tsx b/packages/website/src/routes/index.tsx index 56b67a5..0a2e4d1 100644 --- a/packages/website/src/routes/index.tsx +++ b/packages/website/src/routes/index.tsx @@ -14,7 +14,7 @@ const Page: Component = () => { const [latest, setLatest] = createSignal(null); onMount(async () => { - const response = await fetch("/api/latest/" + state.year); + const response = await fetch("/api/A1/3"); const json = await response.json(); setLatest(json.data as ITimetable); });