diff --git a/app/(authenticated)/calendar/YSTVCalendar.tsx b/app/(authenticated)/calendar/YSTVCalendar.tsx
index f449b023..5bc2f15d 100644
--- a/app/(authenticated)/calendar/YSTVCalendar.tsx
+++ b/app/(authenticated)/calendar/YSTVCalendar.tsx
@@ -32,6 +32,8 @@ import { z } from "zod";
import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { fetchEvents } from "./actions";
import { calendarEventsQueryKey } from "./helpers";
+import { EventColours } from "@/features/calendar/types";
+import { EventType } from "@/features/calendar/types";
dayjs.extend(weekOfYear);
@@ -86,6 +88,12 @@ const HistoryStateSchema = z.object({
filter: z.enum(["all", "mine", "vacant"]).optional(),
});
+const getEventColor = (evt: Event): string => {
+ if (evt.is_cancelled) return "#B00020";
+ if (evt.is_tentative) return "#8b8b8b";
+ return EventColours[evt.event_type as EventType] || "#FFC0CB";
+};
+
export default function YSTVCalendar() {
const currentDate = new Date();
@@ -363,13 +371,13 @@ export default function YSTVCalendar() {
end: evt.end_date,
url: `/calendar/${evt.event_id}`,
};
- if (evt.is_tentative) {
- eventObject.color = "#8b8b8b";
- }
+
+ eventObject.color = getEventColor(evt);
+
if (evt.is_cancelled) {
- eventObject.color = "#B00020";
eventObject.className = "ystv-calendar-strike-through";
}
+
if (evt.end_date.valueOf() < currentDate.valueOf()) {
eventObject.className += " opacity-50";
}
@@ -381,8 +389,6 @@ export default function YSTVCalendar() {
);
}
-type EventType = "show" | "meeting" | "social" | "other";
-
interface Event {
event_id: number;
event_type: EventType | string;
diff --git a/app/(authenticated)/calendar/new/page.tsx b/app/(authenticated)/calendar/new/page.tsx
index 88150223..d52d4b1d 100644
--- a/app/(authenticated)/calendar/new/page.tsx
+++ b/app/(authenticated)/calendar/new/page.tsx
@@ -52,7 +52,7 @@ export default async function NewEventPage() {
);
if (permittedEventTypes.length === 0) {
throw new Forbidden([
- "Calendar.Admin or Calendar.{Show,Meeting,Social}.{Creator,Admin}" as any,
+ "Calendar.Admin or Calendar.{Show,Meeting,Workshop,Social}.{Creator,Admin}" as any,
]);
}
const allMembers = await getAllUsers();
diff --git a/app/(authenticated)/calendar/page.tsx b/app/(authenticated)/calendar/page.tsx
index 8a01f8f1..a546fd9c 100644
--- a/app/(authenticated)/calendar/page.tsx
+++ b/app/(authenticated)/calendar/page.tsx
@@ -13,6 +13,7 @@ import {
} from "@tanstack/react-query";
import { fetchEvents } from "./actions";
import { calendarEventsQueryKey } from "./helpers";
+import EventColoursKey from "@/components/EventColoursKey";
export default async function CalendarPage() {
await mustGetCurrentUser();
@@ -83,6 +84,7 @@ export default async function CalendarPage() {