diff --git a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx index a1ef5910f..5ac2e23f3 100644 --- a/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx +++ b/apps/antalmanac/src/components/RightPane/CoursePane/CourseRenderPane.tsx @@ -18,6 +18,7 @@ import AppStore from '$stores/AppStore'; import { isDarkMode, queryWebsoc, queryWebsocMultiple } from '$lib/helpers'; import Grades from '$lib/grades'; import analyticsEnum from '$lib/analytics'; +import { openSnackbar } from '$actions/AppStoreActions'; function flattenSOCObject(SOCObject: WebsocAPIResponse): (WebsocSchool | WebsocDepartment | AACourse)[] { const courseColors = AppStore.getAddedCourses().reduce((accumulator, { section }) => { @@ -196,7 +197,9 @@ export function CourseRenderPane() { setError(false); setCourseData(flattenSOCObject(websocJsonResp)); } catch (error) { + console.error(error); setError(true); + openSnackbar('error', 'We ran into an error while looking up class info'); } finally { setLoading(false); } diff --git a/apps/antalmanac/src/stores/ColumnStore.ts b/apps/antalmanac/src/stores/ColumnStore.ts index 78707c3ca..936fe8434 100644 --- a/apps/antalmanac/src/stores/ColumnStore.ts +++ b/apps/antalmanac/src/stores/ColumnStore.ts @@ -1,5 +1,6 @@ import { create } from 'zustand'; import analyticsEnum, { logAnalytics } from '$lib/analytics'; +import useTabStore from './TabStore'; /** * Search results are displayed in a tabular format. @@ -50,14 +51,23 @@ interface ColumnStore { setColumnEnabled: (column: SectionTableColumn, state: boolean) => void; } +// Don't enable GPA column if the user is on the Added tab +const enabledColumnsInitial = SECTION_TABLE_COLUMNS.map( + (col) => !(window.location.pathname.split('/').slice(1)[0] === 'added' && col === 'gpa') +); +const selectedColumnsInitial = SECTION_TABLE_COLUMNS.map(() => true); +const activeColumnsInitial = SECTION_TABLE_COLUMNS.filter( + (_, index) => enabledColumnsInitial[index] && selectedColumnsInitial[index] +); + /** * Store of columns that are currently being displayed in the search results. */ export const useColumnStore = create((set, get) => { return { - enabledColumns: SECTION_TABLE_COLUMNS.map(() => true), - selectedColumns: SECTION_TABLE_COLUMNS.map(() => true), - activeColumns: Array.from(SECTION_TABLE_COLUMNS), + enabledColumns: enabledColumnsInitial, + selectedColumns: selectedColumnsInitial, + activeColumns: activeColumnsInitial, setSelectedColumns: (columns: SectionTableColumn[]) => { set(() => { const selectedColumns = SECTION_TABLE_COLUMNS.map((column) => columns.includes(column));