From b4d762b2f42a89d47edaf3801eccceacea71ffbf Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Tue, 3 Nov 2026 20:10:04 -0500 Subject: [PATCH 01/15] refactor grid CourseEntry into ts react component --- js/components/grid/course_entry.tsx | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 js/components/grid/course_entry.tsx diff --git a/js/components/grid/course_entry.tsx b/js/components/grid/course_entry.tsx new file mode 100644 index 000000000..0946f3561 --- /dev/null +++ b/js/components/grid/course_entry.tsx @@ -0,0 +1,37 @@ +import { useCallback } from "react" + +export interface CourseEntryProps { + course: string + selectCourse: (courseCode: string) => void + removeCourse: (courseCode: string) => void + selectedCourses: string[] +} + +/** + * Describes a course based on its course code, and whether or not it has been selected + * (If the course is selected, it is a "starred-course"). + */ + +export function CourseEntry({ + course, + selectCourse, + removeCourse, + selectedCourses, +}: CourseEntryProps) { + // Check whether the course is already in the selectCourses list. + // Remove the course if it is, or add the course if it is not. + const select = useCallback(() => { + if (selectedCourses.indexOf(course) != -1) { + removeCourse(course) + } else { + selectCourse(course) + } + }, [course, selectedCourses, selectCourse, removeCourse]) + + const classes = selectedCourses.indexOf(course) != -1 ? "starred-course" : "" + return ( +
  • + {course} +
  • + ) +} From 8d1b3eac95be215855bda6212fc3705ac31ba9c6 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Tue, 3 Nov 2026 20:15:52 -0500 Subject: [PATCH 02/15] refactor grid CourseList into ts react component --- js/components/grid/course_list.tsx | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 js/components/grid/course_list.tsx diff --git a/js/components/grid/course_list.tsx b/js/components/grid/course_list.tsx new file mode 100644 index 000000000..c3d09b656 --- /dev/null +++ b/js/components/grid/course_list.tsx @@ -0,0 +1,68 @@ +import { useState, useEffect } from "react" +import { CourseEntry } from "./course_entry" + +export interface CourseListProps { + courseFilter: string + selectedCourses: string[] + selectCourse: (courseCode: string) => void + removeCourse: (courseCode: string) => void +} + +/** + * A list of courses in column flow + * Composed of many CourseEntry + */ + +export function CourseList({ + courseFilter, + selectedCourses, + selectCourse, + removeCourse, +}: CourseListProps) { + const [courses, setCourses] = useState([]) + + useEffect(() => { + // AJAX requests allow the programmer to: + // 1. update a webpage without refreshing + // 2. Request data from a server AFTER the webpage is loaded + // 3. Send data to the server - in the background + + // This makes an AJAX call to retrieve courses from the database + fetch( + "/courses" // url to which the AJAX request is sent to + ) + .then(response => response.text()) + .then(data => { + // searches through all of the courses in "data", + // and stores each individual course code name + // into 'courses' list + const courses = data.split("\n").map(course => course.substring(0, 8)) + setCourses(courses) + }) + }, []) + + let searchList: React.ReactElement[] = [] + // If there are courses to be filtered + if (courseFilter !== "") { + // From the "courses" list, filter out elements based off of the prop "courseFilter" passed to + // CourseList by SearchPanel + searchList = courses + .filter(course => course.indexOf(courseFilter) > -1) + .map(course => ( + + )) + } + + // Return all the unfiltered courses in the "courses" list in a list + return ( +
    +
      {searchList}
    +
    + ) +} From d3e83ca3cc3de90bb89eee4e3a33bbe1a615e75c Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Tue, 3 Nov 2026 20:51:15 -0500 Subject: [PATCH 03/15] refactor grid LectureSection into ts react component --- js/components/grid/lecture_section.tsx | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 js/components/grid/lecture_section.tsx diff --git a/js/components/grid/lecture_section.tsx b/js/components/grid/lecture_section.tsx new file mode 100644 index 000000000..10400cf54 --- /dev/null +++ b/js/components/grid/lecture_section.tsx @@ -0,0 +1,36 @@ +import { SelectedLecture } from "./types" + +export interface LectureSectionProps { + session: string + courseCode: string + lecture: SelectedLecture + hoverLecture: (lecture: SelectedLecture) => void + unhoverLecture: () => void + selectLecture: (lecture: SelectedLecture) => void +} + +/** + * A lecture, tutorial or practical section for the specified course in the specified + * session. The section is added to or removed from a list of selected lecture upon click. + */ + +export function LectureSection({ + session, + courseCode, + lecture, + hoverLecture, + unhoverLecture, + selectLecture, +}: LectureSectionProps) { + return ( +
  • selectLecture(lecture)} + onMouseOver={() => hoverLecture(lecture)} + onMouseOut={() => unhoverLecture()} + data-satisfied={"true"} + > + {lecture.lectureCode} +
  • + ) +} From cd73ef6c702b97cbba407b0b49a474a962d0e96b Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Tue, 3 Nov 2026 21:30:04 -0500 Subject: [PATCH 04/15] refactor grid SectionList into ts react component --- js/components/grid/section_list.tsx | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 js/components/grid/section_list.tsx diff --git a/js/components/grid/section_list.tsx b/js/components/grid/section_list.tsx new file mode 100644 index 000000000..2a4223f5a --- /dev/null +++ b/js/components/grid/section_list.tsx @@ -0,0 +1,42 @@ +import { SelectedLecture } from "./types" +import { LectureSection } from "./lecture_section" + +export interface SectionListProps { + courseCode: string + session: string + lectures: SelectedLecture[] + hoverLecture: (lecture: SelectedLecture) => void + unhoverLecture: () => void + selectLecture: (lecture: SelectedLecture) => void +} + +/** + * A list of lecture, tutorial and practical sections for the specified course for the specified + * session. + */ + +export function SectionList({ + courseCode, + session, + lectures, + hoverLecture, + unhoverLecture, + selectLecture, +}: SectionListProps) { + const lectureSections = lectures.map(lecture => ( + + )) + return ( +
      + {lectureSections} +
    + ) +} From 635d2d101947a8da9179429968d46e69b54f747e Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 8 Nov 2026 14:10:13 -0500 Subject: [PATCH 05/15] add missing frontend common type fields --- js/components/common/types.ts | 2 ++ js/components/common/utils.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/components/common/types.ts b/js/components/common/types.ts index 62892d082..c013310a6 100644 --- a/js/components/common/types.ts +++ b/js/components/common/types.ts @@ -46,6 +46,8 @@ export interface MeetingItem { cap: number enrol: number wait: number + code: string + extra?: number } timeData: TimeData[] } diff --git a/js/components/common/utils.ts b/js/components/common/utils.ts index bec066c19..dad402f70 100644 --- a/js/components/common/utils.ts +++ b/js/components/common/utils.ts @@ -1,11 +1,11 @@ -import type { ProgramData, ProgramNotModified } from "./types" +import type { ProgramData, ProgramNotModified, RawCourseData } from "./types" /** * Retrieves a course from file. * @param courseName The course code. This + '.txt' is the name of the file. * @returns Promise object representing the JSON object containing course information * or null if not found. */ -export function getCourse(courseName: string): Promise { +export function getCourse(courseName: string): Promise { "use strict" return fetch("course?name=" + courseName).then(response => { From 4097ca98b54dd07e15a4db1d16d4944998427e71 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 8 Nov 2026 15:13:43 -0500 Subject: [PATCH 06/15] refactor grid Course into ts react component --- js/components/grid/course.tsx | 210 ++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 js/components/grid/course.tsx diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx new file mode 100644 index 000000000..7c1cfcbb2 --- /dev/null +++ b/js/components/grid/course.tsx @@ -0,0 +1,210 @@ +import { useState, useEffect, useCallback } from "react" +import { getCourse } from "../common/utils" +import { SelectedLecture } from "./types" +import { MeetingItem, TimeData } from "../common/types" +import { SectionList } from "./section_list" + +export interface CourseProps { + selectedLectures: SelectedLecture[] + courseCode: string + removeCourse: (courseCode: string) => void + hoverLecture: (lecture: SelectedLecture) => void + unhoverLecture: () => void + selectLecture: (lecture: SelectedLecture) => void + displayInfo: (courseId: any) => void +} + +interface ParsedLecture { + courseCode: string + lectureCode: string + session: string + times: TimeData[] +} + +interface ParsedCourse { + courseCode: string + F: ParsedLecture[] + S: ParsedLecture[] + Y: ParsedLecture[] +} + +/** + * A selected course with a delete button, and info button, which displays information + * about the course when clicked. + * Also retrieves the course information. It holds list of F, S and Y lecture, tutorial + * and practical sections for the course. + */ + +export function Course({ + selectedLectures, + courseCode, + removeCourse, + hoverLecture, + unhoverLecture, + selectLecture, + displayInfo, +}: CourseProps) { + const [selected, setSelected] = useState(false) + const [courseInfo, setCourseInfo] = useState({ + courseCode: "", + F: [], + S: [], + Y: [], + }) + + const filterLectureList = useCallback( + (lectures: ParsedLecture[], session: string): ParsedLecture[] => { + return lectures + .filter(lec => lec.session === session) + .sort((firstLec, secondLec) => + firstLec.lectureCode > secondLec.lectureCode ? 1 : -1 + ) + }, + [] + ) + + const toggleSelect = useCallback(() => { + setSelected(s => !s) + }, []) + + const removeCourseCallback = useCallback(() => { + removeCourse(courseCode) + }, [removeCourse, courseCode]) + + const parseLectures = useCallback((lectures: MeetingItem[]): ParsedLecture[] => { + const parsedLectures: ParsedLecture[] = [] + + // Loop through the lecture sections to get each section's session code and lecture times + lectures.forEach(lectureInfo => { + // Check to make sure its not an online section (online sections have course codes beginning with 9) or + // restricted section. Restricted sections have enrollment restricted for a particular group of students, + // but happens at the same time and place as a regular lecture/tutorial section. + if ( + lectureInfo.meetData.section.charAt(3) !== "2" && + lectureInfo.meetData.section.charAt(3) !== "9" + ) { + const lecture: ParsedLecture = { + courseCode: + lectureInfo.meetData.code + + " (" + + lectureInfo.meetData.section.substring(0, 1) + + ")", + lectureCode: + lectureInfo.meetData.section.substring(0, 1) + + lectureInfo.meetData.section.substring(3), + session: lectureInfo.meetData.session, + times: lectureInfo.timeData, + } + parsedLectures.push(lecture) + } + }) + return parsedLectures + }, []) + + const containsSelectedLecture = useCallback(() => { + // Only use method subString on the value of courseInfo.courseCode if + // if the courseInfo.courseCode exists (ie the course information has already been fetched) + if (courseInfo.courseCode) { + const lectures = selectedLectures.map(lecture => + lecture.courseCode.substring(0, 6) + ) + const courseCode = courseInfo.courseCode + return lectures.indexOf(courseCode.substring(0, 6)) >= 0 + } + return false + }, [selectedLectures]) + + useEffect(() => { + getCourse(courseCode) + .then(data => { + const course: ParsedCourse = { + courseCode: "", + F: [], + S: [], + Y: [], + } + + course.courseCode = data.name ? data.name : "" + + const parsedLectures = parseLectures(data.allMeetingTimes) + // Split the lecture sections into Fall, Spring and Years + course.F = filterLectureList(parsedLectures, "F") + course.S = filterLectureList(parsedLectures, "S") + course.Y = filterLectureList(parsedLectures, "Y") + setCourseInfo(course) + }) + .catch(_ => { + console.error(`Course with code ${courseCode} not found`) + setCourseInfo({ + courseCode: "", + F: [], + S: [], + Y: [], + }) + }) + }, []) + + return ( +
  • +
    +
    + + displayInfo(courseCode)} + /> +
    +

    + {courseCode} +

    +
    + {selected && ( +
    + + + +
    + )} +
  • + ) +} From 65e660b77dd8077b991ba4b7d806c586fac4ab36 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 8 Nov 2026 15:17:17 -0500 Subject: [PATCH 07/15] update grid course_panel component --- js/components/grid/course_panel.js.jsx | 283 +------------------------ 1 file changed, 3 insertions(+), 280 deletions(-) diff --git a/js/components/grid/course_panel.js.jsx b/js/components/grid/course_panel.js.jsx index bf7b42f2a..7ac24864a 100644 --- a/js/components/grid/course_panel.js.jsx +++ b/js/components/grid/course_panel.js.jsx @@ -1,6 +1,7 @@ -import { useCallback, useState, useEffect } from "react" +import { useCallback, useState } from "react" import { CourseModal } from "../common/CourseModal" -import { getCourse } from "../common/utils" +import { CourseList } from "./course_list" +import { Course } from "./course" /** * Creates a search box and stores the current user input that is in the search box @@ -79,281 +80,3 @@ export function CoursePanel(props) { ) } - -/** - * A selected course with a delete button, and info button, which displays information - * about the course when clicked. - * Also retrieves the course information. It holds list of F, S and Y lecture, tutorial - * and practical sections for the course. - */ -function Course(props) { - const [selected, setSelected] = useState(false) - const [courseInfo, setCourseInfo] = useState({}) - - const filterLectureList = useCallback((lectures, session) => { - return lectures - .filter(lec => lec.session === session) - .sort((firstLec, secondLec) => - firstLec.lectureCode > secondLec.lectureCode ? 1 : -1 - ) - }, []) - - const toggleSelect = useCallback(() => { - setSelected(s => !s) - }, []) - - const removeCourse = useCallback(() => { - props.removeCourse(props.courseCode) - }, [props.removeCourse, props.courseCode]) - - const parseLectures = useCallback(lectures => { - const parsedLectures = [] - - // Loop through the lecture sections to get each section's session code and lecture times - lectures.forEach(lectureInfo => { - // Check to make sure its not an online section (online sections have course codes beginning with 9) or - // restricted section. Restricted sections have enrollment restricted for a particular group of students, - // but happens at the same time and place as a regular lecture/tutorial section. - if ( - lectureInfo.meetData.section.charAt(3) !== "2" && - lectureInfo.meetData.section.charAt(3) !== "9" - ) { - const lecture = { - courseCode: - lectureInfo.meetData.code + - " (" + - lectureInfo.meetData.section.substring(0, 1) + - ")", - lectureCode: - lectureInfo.meetData.section.substring(0, 1) + - lectureInfo.meetData.section.substring(3), - session: lectureInfo.meetData.session, - times: lectureInfo.timeData, - } - parsedLectures.push(lecture) - } - }) - return parsedLectures - }, []) - - const containsSelectedLecture = useCallback(() => { - // Only use method subString on the value of courseInfo.courseCode if - // if the courseInfo.courseCode exists (ie the course information has already been fetched) - if (courseInfo.courseCode) { - const lectures = props.selectedLectures.map(lecture => - lecture.courseCode.substring(0, 6) - ) - const courseCode = courseInfo.courseCode - return lectures.indexOf(courseCode.substring(0, 6)) >= 0 - } - return false - }, [props.selectedLectures]) - - useEffect(() => { - getCourse(props.courseCode) - .then(data => { - const course = { - courseCode: "", - F: [], - S: [], - Y: [], - } - - course.courseCode = data.name - - const parsedLectures = parseLectures(data.allMeetingTimes) - // Split the lecture sections into Fall, Spring and Years - course.F = filterLectureList(parsedLectures, "F") - course.S = filterLectureList(parsedLectures, "S") - course.Y = filterLectureList(parsedLectures, "Y") - setCourseInfo(course) - }) - .catch(error => { - console.error(`Course with code ${props.courseCode} not found`) - setCourseInfo({ - courseCode: "", - F: [], - S: [], - Y: [], - }) - }) - }, []) - - return ( -
  • -
    -
    - - props.displayInfo(props.courseCode)} - /> -
    -

    - {props.courseCode} -

    -
    - {selected && ( -
    - - - -
    - )} -
  • - ) -} - -/** - * A list of lecture, tutorial and practical sections for the specified course for the specified - * session. - */ -function SectionList(props) { - const lectureSections = props.lectures.map(lecture => ( - - )) - return ( -
      - {lectureSections} -
    - ) -} - -/** - * A lecture, tutorial or practical section for the specified course in the specified - * session. The section is added to or removed from a list of selected lecture upon click. - */ -const LectureSection = props => { - return ( -
  • props.selectLecture(props.lecture)} - onMouseOver={() => props.hoverLecture(props.lecture)} - onMouseOut={() => props.unhoverLecture()} - data-satisfied={"true"} - > - {props.lecture.lectureCode} -
  • - ) -} - -function CourseList(props) { - const [courses, setCourses] = useState([]) - - useEffect(() => { - // AJAX requests allow the programmer to: - // 1. update a webpage without refreshing - // 2. Request data from a server AFTER the webpage is loaded - // 3. Send data to the server - in the background - - // This makes an AJAX call to retrieve courses from the database - fetch( - "/courses" // url to which the AJAX request is sent to - ) - .then(response => response.text()) - .then(data => { - // searches through all of the courses in "data", - // and stores each individual course code name - // into 'courses' list - const courses = data.split("\n").map(course => course.substring(0, 8)) - setCourses(courses) - }) - }, []) - - let searchList = [] - // If there are courses to be filtered - if (props.courseFilter !== "") { - // From the "courses" list, filter out elements based off of the prop "courseFilter" passed to - // CourseList by SearchPanel - searchList = courses - .filter(course => course.indexOf(props.courseFilter) > -1) - .map(course => ( - - )) - } - - // Return all the unfiltered courses in the "courses" list in a list - return ( -
    -
      {searchList}
    -
    - ) -} - -/** - * Describes a course based on its course code, and whether or not it has been selected - * (If the course is selected, it is a "starred-course"). - */ -function CourseEntry(props) { - // Check whether the course is already in the selectCourses list. - // Remove the course if it is, or add the course if it is not. - const select = useCallback(() => { - if (props.selectedCourses.indexOf(props.course) != -1) { - props.removeCourse(props.course) - } else { - props.selectCourse(props.course) - } - }, [props.course, props.selectedCourses, props.selectCourse, props.removeCourse]) - - const classes = - props.selectedCourses.indexOf(props.course) != -1 ? "starred-course" : "" - return ( -
  • - {props.course} -
  • - ) -} From 21e1b4ce4e549f110b6a3a6a0675eff6f36a9499 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Mon, 9 Nov 2026 18:58:43 -0500 Subject: [PATCH 08/15] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad073a450..3b63ca27d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ - Refactored the `Times` table to `Time` with a database migration - Extracted `loadGraphData.ts` and `util.ts` (both TypeScript) out of `js/components/graph/Graph.js`, and moved `js/util/util.ts` to `js/components/graph/requirementParser.ts` - Changed SVG parsing to leave the `fill` column empty when inserting hybrid nodes into the database +- Refactored `js/components/grid/course_panel.js.jsx` into separate typescript react components ## [0.8.1] - 2026-08-10 From 5ebb08ac64fa97d2b49cab28b412791b86991bde Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Mon, 9 Nov 2026 22:10:11 -0500 Subject: [PATCH 09/15] refactor grid CoursePanel into ts --- .../grid/__tests__/CoursePanel.test.js | 2 +- js/components/grid/course.tsx | 2 +- .../{course_panel.js.jsx => course_panel.tsx} | 53 +++++++++++++------ js/components/grid/grid.tsx | 2 +- 4 files changed, 40 insertions(+), 19 deletions(-) rename js/components/grid/{course_panel.js.jsx => course_panel.tsx} (57%) diff --git a/js/components/grid/__tests__/CoursePanel.test.js b/js/components/grid/__tests__/CoursePanel.test.js index 03473209f..b3ae73427 100644 --- a/js/components/grid/__tests__/CoursePanel.test.js +++ b/js/components/grid/__tests__/CoursePanel.test.js @@ -1,6 +1,6 @@ import { render, screen, cleanup, waitFor } from "@testing-library/react" import userEvent from "@testing-library/user-event" -import { CoursePanel } from "../course_panel.js.jsx" +import { CoursePanel } from "../course_panel" import fetchMock from "fetch-mock" describe("CoursePanel", () => { diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx index 7c1cfcbb2..49863ab84 100644 --- a/js/components/grid/course.tsx +++ b/js/components/grid/course.tsx @@ -11,7 +11,7 @@ export interface CourseProps { hoverLecture: (lecture: SelectedLecture) => void unhoverLecture: () => void selectLecture: (lecture: SelectedLecture) => void - displayInfo: (courseId: any) => void + displayInfo: (courseId: string) => void } interface ParsedLecture { diff --git a/js/components/grid/course_panel.js.jsx b/js/components/grid/course_panel.tsx similarity index 57% rename from js/components/grid/course_panel.js.jsx rename to js/components/grid/course_panel.tsx index 7ac24864a..90b422d3b 100644 --- a/js/components/grid/course_panel.js.jsx +++ b/js/components/grid/course_panel.tsx @@ -2,17 +2,38 @@ import { useCallback, useState } from "react" import { CourseModal } from "../common/CourseModal" import { CourseList } from "./course_list" import { Course } from "./course" +import { SelectedLecture } from "./types" + +export interface CoursePanelProps { + selectedCourses: string[] + selectedLectures: SelectedLecture[] + removeCourse: (courseCode: string) => void + clearCourses: () => void + hoverLecture: (lecture: SelectedLecture) => void + unhoverLecture: () => void + selectLecture: (lecture: SelectedLecture) => void + selectCourse: (courseCode: string) => void +} /** * Creates a search box and stores the current user input that is in the search box * Holds courses selected from the search box, and lists of their F, S and Y lecture, tutorial, * and practical sections. */ -export function CoursePanel(props) { +export function CoursePanel({ + selectedCourses, + selectedLectures, + removeCourse, + clearCourses, + hoverLecture, + unhoverLecture, + selectLecture, + selectCourse, +}: CoursePanelProps) { const [value, setValue] = useState("") - const [courseInfoId, setCourseInfoId] = useState(null) // The course code to display in the CourseModal + const [courseInfoId, setCourseInfoId] = useState(undefined) // The course code to display in the CourseModal - const handleInput = useCallback(event => { + const handleInput = useCallback((event: React.ChangeEvent) => { setValue(event.target.value) }, []) @@ -20,23 +41,23 @@ export function CoursePanel(props) { // pop up window. const clearAllCourses = useCallback(() => { if (window.confirm("Clear all selected courses?")) { - props.clearCourses() + clearCourses() } - }, [props.clearCourses]) + }, [clearCourses]) - const displayInfo = useCallback(courseId => { + const displayInfo = useCallback((courseId: string) => { setCourseInfoId(courseId) }, []) - const courses = props.selectedCourses.map(course => ( + const courses = selectedCourses.map(course => ( )) @@ -59,9 +80,9 @@ export function CoursePanel(props) {
    @@ -75,7 +96,7 @@ export function CoursePanel(props) { setCourseInfoId(null)} + onClose={() => setCourseInfoId(undefined)} />
    ) diff --git a/js/components/grid/grid.tsx b/js/components/grid/grid.tsx index 19961a69a..7028b5f84 100644 --- a/js/components/grid/grid.tsx +++ b/js/components/grid/grid.tsx @@ -1,6 +1,6 @@ import { useEffect, useState, useRef } from "react" -import { CoursePanel } from "./course_panel.js.jsx" +import { CoursePanel } from "./course_panel" import { Row } from "./calendar.js.jsx" import { ExportModal, ExportModalHandle } from "../common/export" import Disclaimer from "../common/Disclaimer" From fbfd6bc68b2e2ff49f7f5624e66d986a22385037 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 15 Nov 2026 00:43:40 -0500 Subject: [PATCH 10/15] remove blank line in Grid components headers --- js/components/grid/course.tsx | 1 - js/components/grid/course_entry.tsx | 1 - js/components/grid/course_list.tsx | 1 - js/components/grid/lecture_section.tsx | 1 - js/components/grid/section_list.tsx | 1 - 5 files changed, 5 deletions(-) diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx index 49863ab84..54cc37b3a 100644 --- a/js/components/grid/course.tsx +++ b/js/components/grid/course.tsx @@ -34,7 +34,6 @@ interface ParsedCourse { * Also retrieves the course information. It holds list of F, S and Y lecture, tutorial * and practical sections for the course. */ - export function Course({ selectedLectures, courseCode, diff --git a/js/components/grid/course_entry.tsx b/js/components/grid/course_entry.tsx index 0946f3561..dc296d081 100644 --- a/js/components/grid/course_entry.tsx +++ b/js/components/grid/course_entry.tsx @@ -11,7 +11,6 @@ export interface CourseEntryProps { * Describes a course based on its course code, and whether or not it has been selected * (If the course is selected, it is a "starred-course"). */ - export function CourseEntry({ course, selectCourse, diff --git a/js/components/grid/course_list.tsx b/js/components/grid/course_list.tsx index c3d09b656..ada59f47a 100644 --- a/js/components/grid/course_list.tsx +++ b/js/components/grid/course_list.tsx @@ -12,7 +12,6 @@ export interface CourseListProps { * A list of courses in column flow * Composed of many CourseEntry */ - export function CourseList({ courseFilter, selectedCourses, diff --git a/js/components/grid/lecture_section.tsx b/js/components/grid/lecture_section.tsx index 10400cf54..c4e07ea10 100644 --- a/js/components/grid/lecture_section.tsx +++ b/js/components/grid/lecture_section.tsx @@ -13,7 +13,6 @@ export interface LectureSectionProps { * A lecture, tutorial or practical section for the specified course in the specified * session. The section is added to or removed from a list of selected lecture upon click. */ - export function LectureSection({ session, courseCode, diff --git a/js/components/grid/section_list.tsx b/js/components/grid/section_list.tsx index 2a4223f5a..fa85ae590 100644 --- a/js/components/grid/section_list.tsx +++ b/js/components/grid/section_list.tsx @@ -14,7 +14,6 @@ export interface SectionListProps { * A list of lecture, tutorial and practical sections for the specified course for the specified * session. */ - export function SectionList({ courseCode, session, From b8f2e886b7d8b9beb1dddacac54526754208c042 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 15 Nov 2026 00:47:55 -0500 Subject: [PATCH 11/15] update to type-only imports for Grid components --- js/components/grid/course.tsx | 4 ++-- js/components/grid/course_panel.tsx | 2 +- js/components/grid/lecture_section.tsx | 2 +- js/components/grid/section_list.tsx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx index 54cc37b3a..cc08f7650 100644 --- a/js/components/grid/course.tsx +++ b/js/components/grid/course.tsx @@ -1,7 +1,7 @@ import { useState, useEffect, useCallback } from "react" import { getCourse } from "../common/utils" -import { SelectedLecture } from "./types" -import { MeetingItem, TimeData } from "../common/types" +import type { SelectedLecture } from "./types" +import type { MeetingItem, TimeData } from "../common/types" import { SectionList } from "./section_list" export interface CourseProps { diff --git a/js/components/grid/course_panel.tsx b/js/components/grid/course_panel.tsx index 90b422d3b..93321fd13 100644 --- a/js/components/grid/course_panel.tsx +++ b/js/components/grid/course_panel.tsx @@ -2,7 +2,7 @@ import { useCallback, useState } from "react" import { CourseModal } from "../common/CourseModal" import { CourseList } from "./course_list" import { Course } from "./course" -import { SelectedLecture } from "./types" +import type { SelectedLecture } from "./types" export interface CoursePanelProps { selectedCourses: string[] diff --git a/js/components/grid/lecture_section.tsx b/js/components/grid/lecture_section.tsx index c4e07ea10..119bf9911 100644 --- a/js/components/grid/lecture_section.tsx +++ b/js/components/grid/lecture_section.tsx @@ -1,4 +1,4 @@ -import { SelectedLecture } from "./types" +import type { SelectedLecture } from "./types" export interface LectureSectionProps { session: string diff --git a/js/components/grid/section_list.tsx b/js/components/grid/section_list.tsx index fa85ae590..42fe7dd64 100644 --- a/js/components/grid/section_list.tsx +++ b/js/components/grid/section_list.tsx @@ -1,4 +1,4 @@ -import { SelectedLecture } from "./types" +import type { SelectedLecture } from "./types" import { LectureSection } from "./lecture_section" export interface SectionListProps { From 09c447874d17445ced6b0f09b6a389c0e9c9ca51 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 15 Nov 2026 00:49:58 -0500 Subject: [PATCH 12/15] remove redundant data field in Grid Course --- js/components/grid/course.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx index cc08f7650..568e1e750 100644 --- a/js/components/grid/course.tsx +++ b/js/components/grid/course.tsx @@ -165,11 +165,7 @@ export function Course({ onClick={() => displayInfo(courseCode)} /> -

    +

    {courseCode}

    From 2fdba113a8508ff7a21a530b7af2686ed798e697 Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 15 Nov 2026 01:01:26 -0500 Subject: [PATCH 13/15] update Grid component return types --- js/components/grid/course.tsx | 4 ++-- js/components/grid/course_entry.tsx | 4 ++-- js/components/grid/course_list.tsx | 4 ++-- js/components/grid/course_panel.tsx | 4 ++-- js/components/grid/lecture_section.tsx | 3 ++- js/components/grid/section_list.tsx | 3 ++- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx index 568e1e750..29c77f7ee 100644 --- a/js/components/grid/course.tsx +++ b/js/components/grid/course.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, useCallback } from "react" +import { type JSX, useState, useEffect, useCallback } from "react" import { getCourse } from "../common/utils" import type { SelectedLecture } from "./types" import type { MeetingItem, TimeData } from "../common/types" @@ -42,7 +42,7 @@ export function Course({ unhoverLecture, selectLecture, displayInfo, -}: CourseProps) { +}: CourseProps): JSX.Element { const [selected, setSelected] = useState(false) const [courseInfo, setCourseInfo] = useState({ courseCode: "", diff --git a/js/components/grid/course_entry.tsx b/js/components/grid/course_entry.tsx index dc296d081..b9581e501 100644 --- a/js/components/grid/course_entry.tsx +++ b/js/components/grid/course_entry.tsx @@ -1,4 +1,4 @@ -import { useCallback } from "react" +import { type JSX, useCallback } from "react" export interface CourseEntryProps { course: string @@ -16,7 +16,7 @@ export function CourseEntry({ selectCourse, removeCourse, selectedCourses, -}: CourseEntryProps) { +}: CourseEntryProps): JSX.Element { // Check whether the course is already in the selectCourses list. // Remove the course if it is, or add the course if it is not. const select = useCallback(() => { diff --git a/js/components/grid/course_list.tsx b/js/components/grid/course_list.tsx index ada59f47a..8ee950834 100644 --- a/js/components/grid/course_list.tsx +++ b/js/components/grid/course_list.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from "react" +import { type JSX, useState, useEffect } from "react" import { CourseEntry } from "./course_entry" export interface CourseListProps { @@ -17,7 +17,7 @@ export function CourseList({ selectedCourses, selectCourse, removeCourse, -}: CourseListProps) { +}: CourseListProps): JSX.Element { const [courses, setCourses] = useState([]) useEffect(() => { diff --git a/js/components/grid/course_panel.tsx b/js/components/grid/course_panel.tsx index 93321fd13..0a02dbe3c 100644 --- a/js/components/grid/course_panel.tsx +++ b/js/components/grid/course_panel.tsx @@ -1,4 +1,4 @@ -import { useCallback, useState } from "react" +import { type JSX, useCallback, useState } from "react" import { CourseModal } from "../common/CourseModal" import { CourseList } from "./course_list" import { Course } from "./course" @@ -29,7 +29,7 @@ export function CoursePanel({ unhoverLecture, selectLecture, selectCourse, -}: CoursePanelProps) { +}: CoursePanelProps): JSX.Element { const [value, setValue] = useState("") const [courseInfoId, setCourseInfoId] = useState(undefined) // The course code to display in the CourseModal diff --git a/js/components/grid/lecture_section.tsx b/js/components/grid/lecture_section.tsx index 119bf9911..da0ddbc38 100644 --- a/js/components/grid/lecture_section.tsx +++ b/js/components/grid/lecture_section.tsx @@ -1,3 +1,4 @@ +import type { JSX } from "react" import type { SelectedLecture } from "./types" export interface LectureSectionProps { @@ -20,7 +21,7 @@ export function LectureSection({ hoverLecture, unhoverLecture, selectLecture, -}: LectureSectionProps) { +}: LectureSectionProps): JSX.Element { return (
  • ( Date: Sun, 15 Nov 2026 01:03:20 -0500 Subject: [PATCH 14/15] remove redundant function from Grid Course --- js/components/grid/course.tsx | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx index 29c77f7ee..11f9d0c19 100644 --- a/js/components/grid/course.tsx +++ b/js/components/grid/course.tsx @@ -100,19 +100,6 @@ export function Course({ return parsedLectures }, []) - const containsSelectedLecture = useCallback(() => { - // Only use method subString on the value of courseInfo.courseCode if - // if the courseInfo.courseCode exists (ie the course information has already been fetched) - if (courseInfo.courseCode) { - const lectures = selectedLectures.map(lecture => - lecture.courseCode.substring(0, 6) - ) - const courseCode = courseInfo.courseCode - return lectures.indexOf(courseCode.substring(0, 6)) >= 0 - } - return false - }, [selectedLectures]) - useEffect(() => { getCourse(courseCode) .then(data => { From 16fd9036d6b9c849522759521bf36e4be7276e6f Mon Sep 17 00:00:00 2001 From: PeanutPiglet Date: Sun, 15 Nov 2026 01:20:10 -0500 Subject: [PATCH 15/15] remove redundant prop from CoursePanel --- js/components/grid/__tests__/CoursePanel.test.js | 1 - js/components/grid/course.tsx | 2 -- js/components/grid/course_panel.tsx | 3 --- js/components/grid/grid.tsx | 1 - 4 files changed, 7 deletions(-) diff --git a/js/components/grid/__tests__/CoursePanel.test.js b/js/components/grid/__tests__/CoursePanel.test.js index b3ae73427..fb95af293 100644 --- a/js/components/grid/__tests__/CoursePanel.test.js +++ b/js/components/grid/__tests__/CoursePanel.test.js @@ -6,7 +6,6 @@ import fetchMock from "fetch-mock" describe("CoursePanel", () => { const coursePanelProps = { selectedCourses: [], - selectedLectures: [], removeCourse: jest.fn(), clearCourses: jest.fn(), hoverLecture: jest.fn(), diff --git a/js/components/grid/course.tsx b/js/components/grid/course.tsx index 11f9d0c19..d59afbe83 100644 --- a/js/components/grid/course.tsx +++ b/js/components/grid/course.tsx @@ -5,7 +5,6 @@ import type { MeetingItem, TimeData } from "../common/types" import { SectionList } from "./section_list" export interface CourseProps { - selectedLectures: SelectedLecture[] courseCode: string removeCourse: (courseCode: string) => void hoverLecture: (lecture: SelectedLecture) => void @@ -35,7 +34,6 @@ interface ParsedCourse { * and practical sections for the course. */ export function Course({ - selectedLectures, courseCode, removeCourse, hoverLecture, diff --git a/js/components/grid/course_panel.tsx b/js/components/grid/course_panel.tsx index 0a02dbe3c..c3987c282 100644 --- a/js/components/grid/course_panel.tsx +++ b/js/components/grid/course_panel.tsx @@ -6,7 +6,6 @@ import type { SelectedLecture } from "./types" export interface CoursePanelProps { selectedCourses: string[] - selectedLectures: SelectedLecture[] removeCourse: (courseCode: string) => void clearCourses: () => void hoverLecture: (lecture: SelectedLecture) => void @@ -22,7 +21,6 @@ export interface CoursePanelProps { */ export function CoursePanel({ selectedCourses, - selectedLectures, removeCourse, clearCourses, hoverLecture, @@ -52,7 +50,6 @@ export function CoursePanel({ const courses = selectedCourses.map(course => (