From 0b78cc6954eef11e52346a63414a919f13f87921 Mon Sep 17 00:00:00 2001 From: Michael Romashov Date: Tue, 26 Mar 2024 00:56:20 -0400 Subject: [PATCH] get rid of bookings from calendar --- src/components/Calendar.tsx | 5 ++--- src/types/calendar.ts | 2 -- src/types/connections.ts | 8 -------- src/utils/calendar.ts | 20 -------------------- 4 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/components/Calendar.tsx b/src/components/Calendar.tsx index 3689f23..74e45f9 100644 --- a/src/components/Calendar.tsx +++ b/src/components/Calendar.tsx @@ -8,7 +8,7 @@ import { LuArrowLeft, LuArrowRight } from 'react-icons/lu'; import type { EventObject, ExternalEventTypes } from '@toast-ui/calendar'; import { Button } from '@/components/Button'; import { fetchApi } from '@/utils/fetch'; -import { eventObjectFromBooking, eventObjectFromEvent, eventObjectFromSession, tuiCalendars, tuiTheme, tuiTimezones } from '@/utils/calendar'; +import { eventObjectFromEvent, eventObjectFromSession, tuiCalendars, tuiTheme, tuiTimezones } from '@/utils/calendar'; import type { Calendar } from '@/types/calendar'; type ReactCalendarOptions = Omit; @@ -47,8 +47,7 @@ export const TuiCalendar: React.FC = ({ events, onSelectDateTi fetchApi(`/calendar/${dateKey}/`) .then((data) => { const newEvents = data.events.map(eventObjectFromEvent) - .concat(data.sessions.map(eventObjectFromSession)) - .concat(data.bookings.map(eventObjectFromBooking)); + .concat(data.sessions.map(eventObjectFromSession)); if (calendar) { calendar.clear(); diff --git a/src/types/calendar.ts b/src/types/calendar.ts index 0c7206e..28db52c 100644 --- a/src/types/calendar.ts +++ b/src/types/calendar.ts @@ -1,9 +1,7 @@ import { type BasicEvent } from '@/types/events'; import { type BasicTrainingSession } from '@/types/training'; -import { type ControllerBooking } from '@/types/connections'; export type Calendar = { events: BasicEvent[]; sessions: BasicTrainingSession[]; - bookings: ControllerBooking[]; } diff --git a/src/types/connections.ts b/src/types/connections.ts index fa0c70d..55c6758 100644 --- a/src/types/connections.ts +++ b/src/types/connections.ts @@ -62,11 +62,3 @@ export type TopPosition = { position: string; hours: string; }; - -export type ControllerBooking = { - id: number; - user: BasicUser; - callsign: string; - start: string; - end: string; -}; diff --git a/src/utils/calendar.ts b/src/utils/calendar.ts index 63217b3..4f1cdb5 100644 --- a/src/utils/calendar.ts +++ b/src/utils/calendar.ts @@ -7,7 +7,6 @@ import type { EventObject } from '@toast-ui/calendar'; import colors from 'tailwindcss/colors'; import { type BasicTrainingSession, SESSION_TYPE_STRING, type TrainingRequest } from '@/types/training'; import type { BasicEvent } from '@/types/events'; -import type { ControllerBooking } from '@/types/connections'; export const tuiCalendars = [ { @@ -28,12 +27,6 @@ export const tuiCalendars = [ backgroundColor: colors.gray[400], borderColor: colors.gray[500], }, - { - id: 'bookings', - name: 'Controller Bookings', - backgroundColor: colors.emerald[400], - borderColor: colors.emerald[500], - }, ]; export const tuiTimezones = { @@ -120,16 +113,3 @@ export function eventObjectFromRequest(request: TrainingRequest): EventObject { end: request.end, }; } - -export function eventObjectFromBooking(booking: ControllerBooking): EventObject { - return { - id: booking.id.toString(), - calendarId: 'bookings', - title: `${booking.callsign} [${booking.user.first_name} ${booking.user.last_name}]`, - location: booking.callsign, - category: 'time', - isReadOnly: true, - start: booking.start, - end: booking.end, - }; -}