From 34a4088fa0ec945519c1f4d4ba647079d902fe0c Mon Sep 17 00:00:00 2001 From: Isaac Nguyen <58119262+IsaacNguyen@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:19:06 -0800 Subject: [PATCH] Fixed "Error loading grades information" with empty course code (#1056) --- .../components/RightPane/CoursePane/CourseRenderPane.tsx | 1 + apps/antalmanac/src/lib/grades.ts | 7 +++++-- apps/backend/{.env.sample => .env.example} | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) rename apps/backend/{.env.sample => .env.example} (92%) diff --git a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx index b787ceb5f..d539c5006 100644 --- a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx +++ b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx @@ -213,6 +213,7 @@ export default function CourseRenderPane(props: { id?: number }) { department: formData.deptValue, ge: formData.ge as GE, instructor: formData.instructor, + sectionCode: formData.sectionCode, }; try { diff --git a/apps/antalmanac/src/lib/grades.ts b/apps/antalmanac/src/lib/grades.ts index a6fcff70f..1319c260b 100644 --- a/apps/antalmanac/src/lib/grades.ts +++ b/apps/antalmanac/src/lib/grades.ts @@ -48,17 +48,20 @@ class _Grades { department, ge, instructor, + sectionCode, }: { department?: string; ge?: GE; instructor?: string; + sectionCode?: string; }): Promise => { department = department != 'ALL' ? department : undefined; ge = ge != 'ANY' ? ge : undefined; instructor = instructor != '' ? instructor : undefined; + sectionCode = sectionCode != '' ? sectionCode : undefined; - if (!department && !ge && !instructor) - throw new Error('populateGradesCache: Must provide either department, ge, or instructor'); + if (!department && !ge && !instructor && !sectionCode) + throw new Error('populateGradesCache: Must provide either department, ge, instructor, or section code'); const queryKey = `${department ?? ''}${ge ?? ''}`; diff --git a/apps/backend/.env.sample b/apps/backend/.env.example similarity index 92% rename from apps/backend/.env.sample rename to apps/backend/.env.example index ef94bb420..78dbaa4d7 100644 --- a/apps/backend/.env.sample +++ b/apps/backend/.env.example @@ -15,4 +15,4 @@ MAPBOX_ACCESS_TOKEN=pk.abc123 # Anteater API key. # If you don't have a key, you can get one at https://dashboard.anteaterapi.com -ANTEATER_API_KEY=placeholder +ANTEATER_API_KEY=placeholder \ No newline at end of file