From 147410df77c0919ffa29f8778871eeedffc6cd3b Mon Sep 17 00:00:00 2001 From: Leo Jeong <80350771+33tm@users.noreply.github.com> Date: Thu, 22 Aug 2024 13:18:59 -0700 Subject: [PATCH] account for null alternate --- shared/util/schedule.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/util/schedule.ts b/shared/util/schedule.ts index 515c903..522117f 100644 --- a/shared/util/schedule.ts +++ b/shared/util/schedule.ts @@ -8,8 +8,9 @@ import schedule, {SCHOOL_START, SCHOOL_END, SCHOOL_END_EXCLUSIVE, PeriodObj} fro export const numToWeekday = (num: number) => ['S', 'M', 'T', 'W', 'R', 'F', 'A'][num]; // Account for how the weekly SELF/SH rotation aren't necessarily alternates -export function isAlternate(normal: PeriodObj[], alternate: PeriodObj[]) { - const selfShFilter = ({ n }) => !['S', 'H'].includes(n); +export function isAlternate(normal: PeriodObj[], alternate: PeriodObj[] | null) { + if (!alternate) return true + const selfShFilter = ({ n }: { n: PeriodObj["n"] }) => !['S', 'H'].includes(n); return JSON.stringify(normal.filter(selfShFilter)) !== JSON.stringify(alternate.filter(selfShFilter)); }