From adfc51927ee479633990bdf220c959d977502484 Mon Sep 17 00:00:00 2001 From: eipmavinna <146777395+eipmavinna@users.noreply.github.com> Date: Mon, 20 Apr 2026 12:56:09 -0400 Subject: [PATCH 1/2] added frontend and route code to allow the schedule page to present different terms in the schedule --- .../src/main/java/edu/gcc/hallmonitor/Schedule.java | 2 +- .../java/edu/gcc/hallmonitor/ScheduleController.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/edu/gcc/hallmonitor/Schedule.java b/backend/src/main/java/edu/gcc/hallmonitor/Schedule.java index 09cc94d..e2d84f7 100644 --- a/backend/src/main/java/edu/gcc/hallmonitor/Schedule.java +++ b/backend/src/main/java/edu/gcc/hallmonitor/Schedule.java @@ -34,7 +34,7 @@ public Schedule() { } //helper method to prevent duplicate code - private List getCoursesForTerm(Course course) { + public List getCoursesForTerm(Course course) { String semester = course.semester(); if (semester.contains("Fall")) return fallCourses; diff --git a/backend/src/main/java/edu/gcc/hallmonitor/ScheduleController.java b/backend/src/main/java/edu/gcc/hallmonitor/ScheduleController.java index 9e9ddec..f9eb443 100644 --- a/backend/src/main/java/edu/gcc/hallmonitor/ScheduleController.java +++ b/backend/src/main/java/edu/gcc/hallmonitor/ScheduleController.java @@ -210,7 +210,15 @@ public static void registerRoutes(Javalin app) { // Get the schedule that is saved app.get("/schedule/items", ctx -> { - ctx.json(Schedule.loadSchedule().getCourses()); // Return the loaded schedule as a json + String term = ctx.queryParam("term"); // Fall, Winter, Spring, Summer + Schedule schedule = Schedule.loadSchedule(); + if (term == null || term.isBlank()) { + ctx.json(schedule.getCourses()); + return; + } + ctx.json(schedule.getCourses().stream() + .filter(course -> course.semester() != null && course.semester().contains(term)) + .toList()); }); //returns the byte array of the schedules for the pdf From aff1da8630d47e170853871d3d9da9ed203cb79e Mon Sep 17 00:00:00 2001 From: eipmavinna <146777395+eipmavinna@users.noreply.github.com> Date: Mon, 20 Apr 2026 12:56:51 -0400 Subject: [PATCH 2/2] frontend --- frontend/src/SchedulePage.tsx | 88 +++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/frontend/src/SchedulePage.tsx b/frontend/src/SchedulePage.tsx index fcd872d..444c02f 100644 --- a/frontend/src/SchedulePage.tsx +++ b/frontend/src/SchedulePage.tsx @@ -3,6 +3,13 @@ import FullCalendar from '@fullcalendar/react' import timeGridPlugin from '@fullcalendar/timegrid' import { useRef } from 'react' + +//for sending into the /schedule/items endpoint +type Term = 'Fall' | 'Winter' | 'Spring' | 'Summer'; +const TERMS: Term[] = ['Fall', 'Winter', 'Spring', 'Summer']; + + + interface CourseTime { day: string start_time: string @@ -20,9 +27,12 @@ interface Course { export default function SchedulePage() { const [courses, setCourses] = useState([]); + const [activeTerm, setActiveTerm] = useState('Fall'); + //const calendarRef = useRef(null); - const loadCourses = async () => { - const res = await fetch('/schedule/items'); + + const loadCourses = async (term: Term) => { + const res = await fetch(`/schedule/items?term=${encodeURIComponent(term)}`); const items: Course[] = await res.json(); setCourses(items); @@ -52,12 +62,12 @@ export default function SchedulePage() { await fetch('/schedule/items', { method: 'POST', body: courseId }); //remove from calendar removeEvents(courseId); - loadCourses(); + loadCourses(activeTerm); }; useEffect(() => { - loadCourses(); - }, []); + loadCourses(activeTerm); + }, [activeTerm]); const calendarRef = useRef(null) @@ -114,7 +124,53 @@ export default function SchedulePage() { return (
-

User Schedule

+

User Schedule — {activeTerm}

+
+ {TERMS.map(term => ( + + ))} +
+ {(activeTerm === 'Fall' || activeTerm === 'Spring') && ( +
+ +
+ )}
    {courses.map(course => { const courseId = `${course.subject}${course.number}${course.section}${course.semester}`; @@ -128,25 +184,7 @@ export default function SchedulePage() {
-
- -
+
);