Skip to content

Commit ee2c129

Browse files
authored
fix(export): Fix TA export service failing (#3947)
1 parent 454c882 commit ee2c129

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

export/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

export/src/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function validateExportData(data: ExportData) {
6767
);
6868
const taModulesConfigSchema = Joi.object().pattern(
6969
Joi.string(),
70-
Joi.array().length(2).ordered(Joi.string(), Joi.string()),
70+
Joi.array().items(Joi.array().length(2).ordered(Joi.string(), Joi.string())),
7171
);
7272
const themeSchema = Joi.object({
7373
id: Joi.string(),

export/src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ export type TaModulesConfig = {
2626
};
2727

2828
// `ExportData` is duplicated from `website/src/types/export.ts`.
29-
export interface ExportData {
29+
export type ExportData = {
3030
readonly semester: Semester;
3131
readonly timetable: SemTimetableConfig;
3232
readonly colors: ColorMapping;
3333
readonly hidden: ModuleCode[];
34+
readonly ta: TaModulesConfig;
3435
readonly theme: ThemeState;
3536
readonly settings: {
3637
colorScheme: ColorScheme;
3738
};
38-
}
39+
};
3940

4041
export interface State {
4142
data: ExportData;

website/src/entry/export/TimetableOnly.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,16 @@ import { Component } from 'react';
33
import { MemoryRouter } from 'react-router-dom';
44
import { Provider } from 'react-redux';
55

6-
import { ModuleCode, Semester } from 'types/modules';
7-
import { SemTimetableConfig } from 'types/timetables';
86
import { fillColorMapping } from 'utils/colors';
97
import TimetableContent from 'views/timetable/TimetableContent';
10-
import { ColorMapping } from 'types/reducers';
118
import { State as StoreState } from 'types/state';
9+
import { ExportData } from 'types/export';
1210

1311
type Props = {
1412
store: Store<StoreState>;
1513
};
1614

17-
type State = {
18-
semester: Semester;
19-
timetable: SemTimetableConfig;
20-
colors: ColorMapping;
21-
hidden: ModuleCode[];
22-
};
15+
type State = Omit<ExportData, 'theme' | 'settings'>;
2316

2417
export default class TimetableOnly extends Component<Props, State> {
2518
override state = {

website/src/entry/export/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ window.store = store;
2929
// For Puppeteer to import data
3030
const timetableRef = createRef<TimetableOnly>();
3131
window.setData = function setData(modules, data, callback) {
32-
const { semester, timetable, colors, hidden } = data;
32+
const { semester, timetable, colors, hidden, ta } = data;
3333

3434
if (document.body) {
3535
document.body.classList.toggle('mode-dark', data.settings.colorScheme === DARK_COLOR_SCHEME);
@@ -44,6 +44,7 @@ window.setData = function setData(modules, data, callback) {
4444
timetable,
4545
colors,
4646
hidden,
47+
ta,
4748
},
4849
callback,
4950
);

0 commit comments

Comments
 (0)