feat: Add originalStartTime to event DTOs and service to correctly identify and manage event exceptions in the UI.
This commit is contained in:
@@ -62,10 +62,10 @@ type BookingWithUserDto = {
|
||||
id: number;
|
||||
};
|
||||
|
||||
// The final shape of a calendar event occurrence
|
||||
export type CalendarEventDto = Omit<Event, 'bookings'> & {
|
||||
isModified?: boolean;
|
||||
isCancelled?: boolean;
|
||||
originalStartTime: Date;
|
||||
eventBookings: BookingWithUserDto[];
|
||||
};
|
||||
|
||||
@@ -146,6 +146,7 @@ export class CalendarService {
|
||||
const key = `${event.id}-${event.startTime.getTime()}`;
|
||||
return {
|
||||
...event,
|
||||
originalStartTime: event.startTime,
|
||||
eventBookings: bookingMap.get(key) || [],
|
||||
};
|
||||
});
|
||||
@@ -197,6 +198,7 @@ export class CalendarService {
|
||||
exception.newEndTime ||
|
||||
new Date(occurrenceDate.getTime() + duration),
|
||||
isModified: true,
|
||||
originalStartTime: occurrenceDate,
|
||||
eventBookings: bookingMap.get(key) || [],
|
||||
isCancelled: !!exception.isCancelled,
|
||||
});
|
||||
@@ -206,6 +208,7 @@ export class CalendarService {
|
||||
recurringOccurrences.push({
|
||||
...event,
|
||||
startTime: occurrenceDate,
|
||||
originalStartTime: occurrenceDate,
|
||||
endTime: new Date(occurrenceDate.getTime() + duration),
|
||||
eventBookings: bookingMap.get(key) || [],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user