From bc2efe379b326f8e3ebe9fd6c0b97102a0fc48e8 Mon Sep 17 00:00:00 2001 From: SophiaSun18 Date: Mon, 11 Mar 2024 00:55:36 -0400 Subject: [PATCH] Split part of original courseSectionCallback() into courseCallback() to fix the error of "cannot read properties of undefined" --- .../src/utilities/helpers/caseFunctions.ts | 14 ++++++++------ .../src/utilities/helpers/readCSV.ts | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/client-course-schedulizer/src/utilities/helpers/caseFunctions.ts b/client-course-schedulizer/src/utilities/helpers/caseFunctions.ts index f926938e..acaed158 100644 --- a/client-course-schedulizer/src/utilities/helpers/caseFunctions.ts +++ b/client-course-schedulizer/src/utilities/helpers/caseFunctions.ts @@ -99,13 +99,15 @@ export const instructorCallback = (value: string, { section }: CaseCallbackParam section.instructors = instructorCase(value); }; +export const courseCallback = (value: string, { course }: CaseCallbackParams) => { + course.department = value.split(" ")[0]; + course.prefixes = [value.split(" ")[0]]; + course.number = value.split(" ")[1]; +} + export const courseSectionCallback = (value: string, { course, section }: CaseCallbackParams) => { - var origin = value.split(" "); - course.department = origin[0]; - course.prefixes = [origin[0]]; - course.number = origin[1].split("-")[0]; - section.letter = origin[1].split("-")[1]; - course.name = origin.slice(3).join(" "); + section.letter = value.split("-")[1]; + course.name = value.split("-")[2]; } export const prefixCallback = (value: string, { course }: CaseCallbackParams) => { diff --git a/client-course-schedulizer/src/utilities/helpers/readCSV.ts b/client-course-schedulizer/src/utilities/helpers/readCSV.ts index 5864efc5..6895e254 100644 --- a/client-course-schedulizer/src/utilities/helpers/readCSV.ts +++ b/client-course-schedulizer/src/utilities/helpers/readCSV.ts @@ -48,6 +48,7 @@ const registrarSpreadsheetFields: ValidFields = { AcademicPeriod: cf.termCallback, AcademicYear: cf.yearCallback, Comments: cf.commentsCallback, + Course: cf.courseCallback, CourseNum: cf.numberCallback, CourseSection: cf.courseSectionCallback, // Day10Used: cf.day10UsedCallback,