35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { CalendarEvent } from "@/interface/Calendar";
|
|
import { EventInput } from "@fullcalendar/core/index.js";
|
|
import moment from "moment";
|
|
|
|
|
|
const enum CalendarEventColors {
|
|
GAME = "#3788D8",
|
|
RAID_GROUP = "#DB301D",
|
|
RAID_INSTANCE = "#30BB37"
|
|
}
|
|
|
|
|
|
export function calendarEventToFullCalendarEvent(calendarEvents: CalendarEvent[]): EventInput[]{
|
|
const newEvents: EventInput[] = [];
|
|
|
|
for(const calEvent of calendarEvents){
|
|
newEvents.push({
|
|
id: calEvent.calendarEventId,
|
|
title: calEvent.eventName,
|
|
start: calEvent.eventStartDate,
|
|
end: calEvent.eventEndDate,
|
|
backgroundColor: calEvent.gameId ? CalendarEventColors.GAME : calEvent.raidInstanceId ? CalendarEventColors.RAID_INSTANCE : CalendarEventColors.RAID_GROUP,
|
|
borderColor: calEvent.gameId ? CalendarEventColors.GAME : calEvent.raidInstanceId ? CalendarEventColors.RAID_INSTANCE : CalendarEventColors.RAID_GROUP
|
|
});
|
|
}
|
|
|
|
|
|
return newEvents;
|
|
}
|
|
|
|
|
|
export const dateToString = (inDate: Date): string => {
|
|
return moment(inDate).format("MM/DD/YYYY HH:mm");
|
|
}
|