Game calendar working
This commit is contained in:
34
src/util/CalendarUtil.ts
Normal file
34
src/util/CalendarUtil.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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");
|
||||
}
|
||||
Reference in New Issue
Block a user