feat(FE): crud show, handle date timezones

This commit is contained in:
Michael 2025-04-09 10:31:55 +02:00
parent 95fa9fd742
commit 37a3d1a457
2 changed files with 43 additions and 33 deletions

View file

@ -1,17 +1,21 @@
import type {ShowInstance} from "@models/show/showInstance.ts";
import type {calendarShowEvent} from "@models/misc/calendarShowEvent.ts";
import {convertToUserTimezoneDate} from "@/helpers/DateFormatter.ts";
export const setShowInstancesForCalendar = (showInstances: ShowInstance[]): calendarShowEvent[] => {
return showInstances.flatMap((showInstance: ShowInstance, index: number) => {
return {
showInstanceIndex: index,
showInstanceId: showInstance.id,
title: showInstance.show.name,
color: showInstance.show.color,
start: new Date(showInstance.starts),
end: new Date(showInstance.ends),
timed: true
if(showInstances.length > 0){
return showInstances.flatMap((showInstance: ShowInstance, index: number) => {
return {
showInstanceIndex: index,
showInstanceId: showInstance.id,
title: showInstance.show.name,
color: '#'+showInstance.show.backgroundColor,
start: convertToUserTimezoneDate(showInstance.starts),
end: convertToUserTimezoneDate(showInstance.ends),
timed: true
}
}
}
);
);
}
return [];
}