Skip to content

Commit

Permalink
get rid of bookings from calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRomaa committed Mar 26, 2024
1 parent bca6ac9 commit 0b78cc6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 33 deletions.
5 changes: 2 additions & 3 deletions src/components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Options, 'defaultView'>;
Expand Down Expand Up @@ -47,8 +47,7 @@ export const TuiCalendar: React.FC<TuiCalendarProps> = ({ events, onSelectDateTi
fetchApi<Calendar>(`/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();
Expand Down
2 changes: 0 additions & 2 deletions src/types/calendar.ts
Original file line number Diff line number Diff line change
@@ -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[];
}
8 changes: 0 additions & 8 deletions src/types/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,3 @@ export type TopPosition = {
position: string;
hours: string;
};

export type ControllerBooking = {
id: number;
user: BasicUser;
callsign: string;
start: string;
end: string;
};
20 changes: 0 additions & 20 deletions src/utils/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand All @@ -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 = {
Expand Down Expand Up @@ -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,
};
}

0 comments on commit 0b78cc6

Please sign in to comment.