Skip to content

Commit

Permalink
fix: colour can be null in zod schema
Browse files Browse the repository at this point in the history
  • Loading branch information
debater-coder committed Oct 13, 2024
1 parent 7e05c90 commit 4423c57
Show file tree
Hide file tree
Showing 8 changed files with 5,548 additions and 4,345 deletions.
5 changes: 5 additions & 0 deletions apps/client/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
You can open release notes by going to Settings -> About -> Release notes.

## 1.9.13-beta

- Hotfix: Fix zod schema to fix strange loading state
- TODO: solve this problem properly in the data-providers branch

## 1.9.11-beta

- Hotfix: don't rely on SBHS OAuth discovery endpoint (which is currently dead)
Expand Down
2 changes: 1 addition & 1 deletion apps/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client",
"version": "1.9.12-beta",
"version": "1.9.13-beta",
"type": "module",
"scripts": {
"dev": "npm-run-all --parallel dev:*",
Expand Down
4 changes: 2 additions & 2 deletions apps/client/src/consumers/sbhsApi/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const bellSchema = z.object({
});

const subjectSchema = z.object({
colour: z.string(),
colour: z.string().nullish(),
fullTeacher: z.string(),
subject: z.string(),
title: z.string(),
Expand Down Expand Up @@ -350,7 +350,7 @@ const timetableSubjectSchema = z.object({
teacher: z.string().nullish(),
fullTeacher: z.string().nullish(),
year: z.coerce.string().nullish(),
colour: z.string(),
colour: z.string().nullish(),
});
export type TimetableSubject = z.infer<typeof timetableSubjectSchema>;

Expand Down
8 changes: 7 additions & 1 deletion apps/client/src/consumers/sbhsApi/useDtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export const useDtt = (date?: string) => {
: undefined
),
queryFn: () => queryFn(authActions, date),
select: (data) => dttSchema.parse(data),
select: (data) => {
try {
return dttSchema.parse(data);
} catch (error) {
console.error(error);
}
},
});
};

Expand Down
8 changes: 7 additions & 1 deletion apps/client/src/consumers/sbhsApi/useTimetable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ export const useTimetable = () => {
return useQuery({
queryKey: getQueryKey(),
queryFn: () => queryFn(authActions),
select: (data) => timetableSchema.parse(data),
select: (data) => {
try {
return timetableSchema.parse(data);
} catch (error) {
console.error(error);
}
},
});
};

Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/routes/Main/Home/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function generateLoadingPeriods() {

export default function Schedule({ date }: { date?: string }) {
const { data: dtt } = useDtt(date);

console.log(dtt);
const activeKey = dtt?.periods.find(
({ startTime, endTime }) =>
DateTime.fromISO(startTime) < DateTime.now() &&
Expand Down
Loading

0 comments on commit 4423c57

Please sign in to comment.