Skip to content

Commit 33a182e

Browse files
committed
Don't show restrictions on ViewCalendar.tsx
1 parent 6d5cf39 commit 33a182e

File tree

1 file changed

+3
-57
lines changed

1 file changed

+3
-57
lines changed

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

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ import { createEventModalPlugin } from "@schedule-x/event-modal";
1212
import "@schedule-x/theme-default/dist/index.css";
1313
import React from "react";
1414
import { useGetSharedEventsQuery } from "@/api/eventsApiSlice";
15-
import { Event, TimetableEvents, Restriction } from "@/utils/type-utils";
15+
import { Event, TimetableEvents } from "@/utils/type-utils";
1616
import {
1717
getSemesterStartAndEndDates,
1818
getSemesterStartAndEndDatesPlusOneWeek,
1919
} from "@/utils/semester-utils";
2020
import { courseEventStyles } from "@/constants/calendarConstants";
2121
import { parseEvent } from "@/utils/calendar-utils";
22-
import { useGetSharedRestrictionsQuery } from "@/api/sharedApiSlice";
2322
import { useGetUsernameFromUserIdQuery } from "@/api/authApiSlice";
24-
import { formatTime } from "@/utils/format-date-time";
2523
import { Spinner } from "@/components/ui/spinner";
2624
import { SemesterIcon } from "@/components/semester-icon";
2725

@@ -58,17 +56,7 @@ const ViewCalendar = React.memo<ViewCalendarProps>(
5856
};
5957
const sharedEvents = sharedEventsData as TimetableEvents;
6058

61-
const { data: restrictionsData, isLoading: isRestrictionsLoading } =
62-
useGetSharedRestrictionsQuery(
63-
{ user_id, calendar_id },
64-
{ skip: !user_id || !calendar_id },
65-
) as {
66-
data: Restriction[];
67-
isLoading: boolean;
68-
};
69-
const restrictions = restrictionsData ?? [];
70-
71-
const isLoading = isSharedEventsLoading || isRestrictionsLoading;
59+
const isLoading = isSharedEventsLoading;
7260

7361
const courseEvents: Event[] = sharedEvents?.courseEvents ?? [];
7462
const userEvents: Event[] = sharedEvents?.userEvents ?? [];
@@ -150,7 +138,7 @@ const ViewCalendar = React.memo<ViewCalendarProps>(
150138
<span className="text-green-500">{timetable_title}</span> for{" "}
151139
<span className="text-green-500">{semester}</span>
152140
</h1>
153-
<div className="text-sm justify-between tracking-tight mb-2">
141+
<div className="text-sm justify-between tracking-tight mb-4">
154142
<b>Courses:</b>{" "}
155143
{courses.length === 0 && (
156144
<span className="text-sm text-red-500">
@@ -166,48 +154,6 @@ const ViewCalendar = React.memo<ViewCalendarProps>(
166154
</span>
167155
))}
168156
</div>
169-
<b className="text-sm">Restrictions: </b>
170-
{restrictions.length === 0 && (
171-
<span className="text-sm text-red-500">
172-
No restrictions applied
173-
</span>
174-
)}
175-
<div className="grid grid-rows-3 text-sm justify-between mb-4">
176-
{restrictions.map((restriction) => {
177-
const restrictedDays = JSON.parse(restriction.days)
178-
.map((day: string) => {
179-
if (day === "MO") return "Monday";
180-
if (day === "TU") return "Tuesday";
181-
if (day === "WE") return "Wednesday";
182-
if (day === "TH") return "Thursday";
183-
if (day === "FR") return "Friday";
184-
if (day === "SA") return "Saturday";
185-
if (day === "SU") return "Sunday";
186-
return "Unknown Day";
187-
})
188-
.join(", ");
189-
const restrictionText =
190-
restriction.type === "Max Gap"
191-
? `${restriction.type} of ${restriction.max_gap} hours between courses`
192-
: restriction.type === "Restrict Before"
193-
? `${restriction.type} ${formatTime(new Date(`2025-01-01T${restriction.end_time}.00Z`))} on ${restrictedDays}`
194-
: restriction.type === "Restrict After"
195-
? `${restriction.type} ${formatTime(new Date(`2025-01-01T${restriction.start_time}.00Z`))} on ${restrictedDays}`
196-
: restriction.type === "Restrict Between"
197-
? `${restriction.type} ${formatTime(new Date(`2025-01-01T${restriction.start_time}.00Z`))} and ${formatTime(new Date(`2025-01-01T${restriction.end_time}.00Z`))} on ${restrictedDays}`
198-
: restriction.type === "Restrict Day"
199-
? `Restrict the days of ${restrictedDays}`
200-
: restriction.type === "Days Off"
201-
? `Minimum of ${restriction.num_days} days off`
202-
: "Unknown Restriction Applied";
203-
204-
return (
205-
<div className="text-red-500" key={restriction.id}>
206-
{restrictionText}
207-
</div>
208-
);
209-
})}
210-
</div>
211157
</>
212158
)}
213159
<ScheduleXCalendar calendarApp={calendar} />

0 commit comments

Comments
 (0)