Skip to content

Commit

Permalink
timetables: add customisedModules prop when migrating to V2 schema
Browse files Browse the repository at this point in the history
  • Loading branch information
zwliew committed Aug 4, 2023
1 parent 4ce23c1 commit 3d05c4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion website/src/reducers/timetables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createMigrate, PersistedState } from 'redux-persist';
import { PersistConfig } from 'storage/persistReducer';
import { ModuleCode } from 'types/modules';
import { ModuleLessonConfig, SemTimetableConfig, TimetableConfig } from 'types/timetables';
import { ColorMapping, TimetablesState } from 'types/reducers';
import { ColorMapping, CustomisedModulesMap, TimetablesState } from 'types/reducers';

import config from 'config';
import {
Expand Down Expand Up @@ -35,8 +35,11 @@ export function migrateV1toV2(
): TimetablesState & PersistedState {
const newLessons: TimetableConfig = {};
const oldLessons = oldState.lessons;
const newCustomisedModules: CustomisedModulesMap = {};

Object.entries(oldLessons).forEach(([semester, modules]) => {
newCustomisedModules[semester] = [];

Object.entries(modules).forEach(([moduleCode, lessons]) => {
const newSemester: { [moduleCode: string]: { [lessonType: string]: string[] } } = {
[moduleCode]: {},
Expand All @@ -56,6 +59,7 @@ export function migrateV1toV2(
return {
...oldState,
lessons: newLessons,
customisedModules: newCustomisedModules,
};
}

Expand Down

0 comments on commit 3d05c4f

Please sign in to comment.