Skip to content

Commit e63232c

Browse files
Austin-Xgithub-actions[bot]
authored andcommitted
Auto-formatted the code using Prettier
1 parent 2963943 commit e63232c

File tree

3 files changed

+77
-42
lines changed

3 files changed

+77
-42
lines changed

course-matrix/backend/src/controllers/restrictionsController.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export default {
3333
}
3434

3535
// Function to construct date in local time
36-
if (!["Restrict Day", "Days Off"].includes(type) && !start_time && !end_time) {
36+
if (
37+
!["Restrict Day", "Days Off"].includes(type) &&
38+
!start_time &&
39+
!end_time
40+
) {
3741
return res
3842
.status(400)
3943
.json({ error: "Start time or end time must be provided" });
@@ -353,7 +357,9 @@ export default {
353357
return res.status(400).json({ error: restrictionError.message });
354358
}
355359

356-
return res.status(200).json({ message: "Restriction succesfully deleted" });
360+
return res
361+
.status(200)
362+
.json({ message: "Restriction succesfully deleted" });
357363
} catch (error) {
358364
return res.status(500).send({ error });
359365
}

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import {
2929
useGetTimetablesQuery,
3030
useCreateTimetableMutation,
3131
} from "@/api/timetableApiSlice";
32-
import { useGetRestrictionsQuery, useCreateRestrictionMutation, useDeleteRestrictionMutation} from "@/api/restrictionsApiSlice";
32+
import {
33+
useGetRestrictionsQuery,
34+
useCreateRestrictionMutation,
35+
useDeleteRestrictionMutation,
36+
} from "@/api/restrictionsApiSlice";
3337
import { z } from "zod";
3438
import React, { useEffect, useRef } from "react";
3539
import { useGetNumberOfCourseSectionsQuery } from "@/api/coursesApiSlice";
@@ -40,7 +44,12 @@ import {
4044
} from "@/api/eventsApiSlice";
4145
import { useGetOfferingEventsQuery } from "@/api/offeringsApiSlice";
4246
import { useNavigate, useSearchParams } from "react-router-dom";
43-
import { Event, Timetable, TimetableEvents, Restriction } from "@/utils/type-utils";
47+
import {
48+
Event,
49+
Timetable,
50+
TimetableEvents,
51+
Restriction,
52+
} from "@/utils/type-utils";
4453
import { TimetableForm } from "@/models/timetable-form";
4554
import { getSemesterStartAndEndDates } from "@/utils/semester-utils";
4655

@@ -153,9 +162,12 @@ const Calendar = React.memo<CalendarProps>(
153162
),
154163
].sort((a, b) => a - b);
155164

156-
const { data: restrictionsData } = useGetRestrictionsQuery(editingTimetableId, {
157-
skip: !isEditingTimetable,
158-
}) as {
165+
const { data: restrictionsData } = useGetRestrictionsQuery(
166+
editingTimetableId,
167+
{
168+
skip: !isEditingTimetable,
169+
},
170+
) as {
159171
data: Restriction[];
160172
};
161173

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

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,24 @@ const TimetableBuilder = () => {
194194
// Parse restrictions data (For startTime and endTime, we just care about the time, so we use the random date of 2025-01-01 so that the date can be parsed correctly)
195195
// We also add 1 hour (i.e. 60 * 60 * 1000 milliseconds) to the time to account for the timezone difference between the server and the client
196196
const parsedRestrictions = restrictionsData.map(
197-
(restriction: Restriction) => ({
197+
(restriction: Restriction) =>
198+
({
198199
days: JSON.parse(restriction?.days) as string[],
199200
disabled: restriction?.disabled,
200-
startTime: restriction?.start_time ? new Date(new Date(`2025-01-01T${restriction.start_time}.00Z`).getTime() + 60 * 60 * 1000) : undefined,
201-
endTime: restriction?.end_time ? new Date(new Date(`2025-01-01T${restriction.end_time}.00Z`).getTime() + 60 * 60 * 1000) : undefined,
201+
startTime: restriction?.start_time
202+
? new Date(
203+
new Date(
204+
`2025-01-01T${restriction.start_time}.00Z`,
205+
).getTime() +
206+
60 * 60 * 1000,
207+
)
208+
: undefined,
209+
endTime: restriction?.end_time
210+
? new Date(
211+
new Date(`2025-01-01T${restriction.end_time}.00Z`).getTime() +
212+
60 * 60 * 1000,
213+
)
214+
: undefined,
202215
type: restriction?.type,
203216
numDays: restriction?.num_days,
204217
}) as z.infer<typeof RestrictionSchema>,
@@ -386,7 +399,8 @@ const TimetableBuilder = () => {
386399
{!isEditingTimetable ||
387400
(isEditingTimetable &&
388401
loadedCourses &&
389-
loadedOfferingIds && selectedCourses) ? (
402+
loadedOfferingIds &&
403+
selectedCourses) ? (
390404
selectedCourses.map((course, index) => {
391405
return (
392406
<div key={index}>
@@ -466,37 +480,40 @@ const TimetableBuilder = () => {
466480
)}
467481
/>
468482
<div className="flex gap-2 flex-col">
469-
{enabledRestrictions && enabledRestrictions.map((restric, index) => (
470-
<div
471-
key={index}
472-
className="flex p-2 justify-between bg-red-100/50 text-xs rounded-md w-[64%]"
473-
>
474-
{restric.type.startsWith("Restrict") ? (
475-
<p>
476-
<strong>{restric.type}:</strong>{" "}
477-
{restric.startTime
478-
? formatTime(restric.startTime)
479-
: ""}{" "}
480-
{restric.type === "Restrict Between" ? " - " : ""}{" "}
481-
{restric.endTime
482-
? formatTime(restric.endTime)
483-
: ""}{" "}
484-
{restric.days?.join(" ")}
485-
</p>
486-
) : (
487-
<p>
488-
<strong>{restric.type}:</strong> At least{" "}
489-
{restric.numDays} days off
490-
</p>
491-
)}
492-
493-
<X
494-
size={16}
495-
className="hover:text-red-500 cursor-pointer"
496-
onClick={() => handleRemoveRestriction(index)}
497-
/>
498-
</div>
499-
))}
483+
{enabledRestrictions &&
484+
enabledRestrictions.map((restric, index) => (
485+
<div
486+
key={index}
487+
className="flex p-2 justify-between bg-red-100/50 text-xs rounded-md w-[64%]"
488+
>
489+
{restric.type.startsWith("Restrict") ? (
490+
<p>
491+
<strong>{restric.type}:</strong>{" "}
492+
{restric.startTime
493+
? formatTime(restric.startTime)
494+
: ""}{" "}
495+
{restric.type === "Restrict Between"
496+
? " - "
497+
: ""}{" "}
498+
{restric.endTime
499+
? formatTime(restric.endTime)
500+
: ""}{" "}
501+
{restric.days?.join(" ")}
502+
</p>
503+
) : (
504+
<p>
505+
<strong>{restric.type}:</strong> At least{" "}
506+
{restric.numDays} days off
507+
</p>
508+
)}
509+
510+
<X
511+
size={16}
512+
className="hover:text-red-500 cursor-pointer"
513+
onClick={() => handleRemoveRestriction(index)}
514+
/>
515+
</div>
516+
))}
500517
</div>
501518
</div>
502519

0 commit comments

Comments
 (0)