From a40a5c04fe10709c9106c0b955d282b1b211740c Mon Sep 17 00:00:00 2001 From: nicolas Date: Sun, 18 Jul 2021 22:17:18 +0200 Subject: [PATCH] Retain rescheduleUid when picking a date --- lib/events/EventManager.ts | 5 ++--- pages/[user]/[type].tsx | 14 +++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/events/EventManager.ts b/lib/events/EventManager.ts index 05adebaa..5fbc58d4 100644 --- a/lib/events/EventManager.ts +++ b/lib/events/EventManager.ts @@ -45,9 +45,8 @@ export default class EventManager { } public async update(event: CalendarEvent, booking: PartialBooking): Promise> { - const results: Array = []; // First, update all calendar events. - results.concat(await this.updateAllCalendarEvents(event, booking)); + const results: Array = await this.updateAllCalendarEvents(event, booking); // If and only if event type is a video meeting, update the video meeting as well. if (EventManager.isIntegration(event.location)) { @@ -95,7 +94,7 @@ export default class EventManager { booking: PartialBooking ): Promise> { return async.mapLimit(this.calendarCredentials, 5, async (credential) => { - const bookingRefUid = booking.references.filter((ref) => ref.type === credential.type)[0].uid; + const bookingRefUid = booking.references.filter((ref) => ref.type === credential.type)[0]?.uid; return updateEvent(credential, bookingRefUid, event); }); } diff --git a/pages/[user]/[type].tsx b/pages/[user]/[type].tsx index 04cdbd76..313ee133 100644 --- a/pages/[user]/[type].tsx +++ b/pages/[user]/[type].tsx @@ -48,9 +48,17 @@ export default function Type(props): Type { router.replace( { - query: { - date: formattedDate, - }, + query: Object.assign( + {}, + { + date: formattedDate, + }, + rescheduleUid + ? { + rescheduleUid: rescheduleUid, + } + : {} + ), }, undefined, {