Skip to content

Commit

Permalink
Consistently dosable gpa column on added tab
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhxNguyen7 committed Oct 19, 2023
1 parent 0617b46 commit f1b4dc9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions apps/antalmanac/src/stores/ColumnStore.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -50,14 +51,24 @@ 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')
);
console.log(window.location.pathname.split('/').slice(1)[0] === 'added')
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<ColumnStore>((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));
Expand Down

0 comments on commit f1b4dc9

Please sign in to comment.