Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 4423c57

Browse files
committed
fix: colour can be null in zod schema
1 parent 7e05c90 commit 4423c57

File tree

8 files changed

+5548
-4345
lines changed

8 files changed

+5548
-4345
lines changed

apps/client/RELEASE_NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
You can open release notes by going to Settings -> About -> Release notes.
22

3+
## 1.9.13-beta
4+
5+
- Hotfix: Fix zod schema to fix strange loading state
6+
- TODO: solve this problem properly in the data-providers branch
7+
38
## 1.9.11-beta
49

510
- Hotfix: don't rely on SBHS OAuth discovery endpoint (which is currently dead)

apps/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "client",
3-
"version": "1.9.12-beta",
3+
"version": "1.9.13-beta",
44
"type": "module",
55
"scripts": {
66
"dev": "npm-run-all --parallel dev:*",

apps/client/src/consumers/sbhsApi/schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const bellSchema = z.object({
107107
});
108108

109109
const subjectSchema = z.object({
110-
colour: z.string(),
110+
colour: z.string().nullish(),
111111
fullTeacher: z.string(),
112112
subject: z.string(),
113113
title: z.string(),
@@ -350,7 +350,7 @@ const timetableSubjectSchema = z.object({
350350
teacher: z.string().nullish(),
351351
fullTeacher: z.string().nullish(),
352352
year: z.coerce.string().nullish(),
353-
colour: z.string(),
353+
colour: z.string().nullish(),
354354
});
355355
export type TimetableSubject = z.infer<typeof timetableSubjectSchema>;
356356

apps/client/src/consumers/sbhsApi/useDtt.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ export const useDtt = (date?: string) => {
3030
: undefined
3131
),
3232
queryFn: () => queryFn(authActions, date),
33-
select: (data) => dttSchema.parse(data),
33+
select: (data) => {
34+
try {
35+
return dttSchema.parse(data);
36+
} catch (error) {
37+
console.error(error);
38+
}
39+
},
3440
});
3541
};
3642

apps/client/src/consumers/sbhsApi/useTimetable.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ export const useTimetable = () => {
1515
return useQuery({
1616
queryKey: getQueryKey(),
1717
queryFn: () => queryFn(authActions),
18-
select: (data) => timetableSchema.parse(data),
18+
select: (data) => {
19+
try {
20+
return timetableSchema.parse(data);
21+
} catch (error) {
22+
console.error(error);
23+
}
24+
},
1925
});
2026
};
2127

apps/client/src/routes/Main/Home/Schedule.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function generateLoadingPeriods() {
1717

1818
export default function Schedule({ date }: { date?: string }) {
1919
const { data: dtt } = useDtt(date);
20-
20+
console.log(dtt);
2121
const activeKey = dtt?.periods.find(
2222
({ startTime, endTime }) =>
2323
DateTime.fromISO(startTime) < DateTime.now() &&

0 commit comments

Comments
 (0)