Skip to content

Commit 6203251

Browse files
committed
Add null value check and fix linting errors in TimetableBuilder.tsx
1 parent 229117f commit 6203251

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

course-matrix/frontend/src/pages/TimetableBuilder/TimetableBuilder.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,19 @@ import {
1313
TimetableFormSchema,
1414
baseTimetableForm,
1515
} from "@/models/timetable-form";
16-
import { Edit, X } from "lucide-react";
16+
import { X } from "lucide-react";
1717
import { createContext, useEffect, useState } from "react";
1818
import { useForm, UseFormReturn } from "react-hook-form";
1919
import { zodResolver } from "@hookform/resolvers/zod";
2020
import { z } from "zod";
2121
import {
2222
Select,
2323
SelectContent,
24-
SelectGroup,
2524
SelectItem,
26-
SelectLabel,
2725
SelectTrigger,
2826
SelectValue,
2927
} from "@/components/ui/select";
3028
import CourseSearch from "@/pages/TimetableBuilder/CourseSearch";
31-
import { mockSearchData } from "./mockSearchData";
3229
import CreateCustomSetting from "./CreateCustomSetting";
3330
import { formatTime } from "@/utils/format-date-time";
3431
import { FilterForm, FilterFormSchema } from "@/models/filter-form";
@@ -48,7 +45,6 @@ import {
4845
import { useSearchParams } from "react-router-dom";
4946
import OfferingInfo from "./OfferingInfo";
5047
import { Checkbox } from "@/components/ui/checkbox";
51-
import { time } from "console";
5248

5349
type FormContextType = UseFormReturn<z.infer<typeof TimetableFormSchema>>;
5450
export const FormContext = createContext<FormContextType | null>(null);
@@ -117,7 +113,7 @@ const TimetableBuilder = () => {
117113
resolver: zodResolver(FilterFormSchema),
118114
});
119115

120-
const [queryParams, setQueryParams] = useSearchParams();
116+
const [queryParams] = useSearchParams();
121117
const isEditingTimetable = queryParams.has("edit");
122118
const timetableId = parseInt(queryParams.get("edit") || "0");
123119

@@ -145,7 +141,6 @@ const TimetableBuilder = () => {
145141
const {
146142
data: coursesData,
147143
isLoading,
148-
error,
149144
refetch,
150145
} = useGetCoursesQuery({
151146
limit: noSearchAndFilter() ? SEARCH_LIMIT : 10000,
@@ -201,7 +196,7 @@ const TimetableBuilder = () => {
201196
const parsedRestrictions = restrictionsData.map(
202197
(restriction: Restriction) => ({
203198
...restriction,
204-
days: JSON.parse(restriction.days),
199+
days: JSON.parse(restriction?.days),
205200
}),
206201
);
207202
console.log("Parsed restrictions", parsedRestrictions);
@@ -432,7 +427,7 @@ const TimetableBuilder = () => {
432427
<FormField
433428
control={form.control}
434429
name="restrictions"
435-
render={({ field }) => (
430+
render={() => (
436431
<FormItem className="pb-2">
437432
<p className="text-sm">
438433
Enabled Restrictions: {enabledRestrictions.length}

0 commit comments

Comments
 (0)