From 50632dd9ddbca6d186e53183a09f3a99ec17c65c Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Wed, 11 May 2022 21:47:42 +0100 Subject: [PATCH] Add 'free' and 'workingElsewhere' as a non-blocking event (#2652) * Add 'free' and 'workingElsewhere' to non-blocking event - this will allow bookings at these times * Update CalendarService.ts Co-authored-by: zomars Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../office365calendar/lib/CalendarService.ts | 18 ++++++++++-------- packages/types/Calendar.d.ts | 8 +++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/app-store/office365calendar/lib/CalendarService.ts b/packages/app-store/office365calendar/lib/CalendarService.ts index 848e4334..2d1827e0 100644 --- a/packages/app-store/office365calendar/lib/CalendarService.ts +++ b/packages/app-store/office365calendar/lib/CalendarService.ts @@ -107,9 +107,9 @@ export default class Office365CalendarService implements Calendar { const dateFromParsed = new Date(dateFrom); const dateToParsed = new Date(dateTo); - const filter = `?startdatetime=${encodeURIComponent( + const filter = `?startDateTime=${encodeURIComponent( dateFromParsed.toISOString() - )}&enddatetime=${encodeURIComponent(dateToParsed.toISOString())}`; + )}&endDateTime=${encodeURIComponent(dateToParsed.toISOString())}`; return (await this.auth) .getToken() .then(async (accessToken) => { @@ -142,12 +142,14 @@ export default class Office365CalendarService implements Calendar { return responseBody.responses.reduce( (acc: BufferedBusyTime[], subResponse: { body: { value: any[] } }) => acc.concat( - subResponse.body.value.map((evt) => { - return { - start: evt.start.dateTime + "Z", - end: evt.end.dateTime + "Z", - }; - }) + subResponse.body.value + .filter((evt) => evt.showAs !== "free" && evt.showAs !== "workingElsewhere") + .map((evt) => { + return { + start: evt.start.dateTime + "Z", + end: evt.end.dateTime + "Z", + }; + }) ), [] ); diff --git a/packages/types/Calendar.d.ts b/packages/types/Calendar.d.ts index 57f8386f..45bd1e0d 100644 --- a/packages/types/Calendar.d.ts +++ b/packages/types/Calendar.d.ts @@ -60,7 +60,13 @@ export type BatchResponse = { }; export type SubResponse = { - body: { value: { start: { dateTime: string }; end: { dateTime: string } }[] }; + body: { + value: { + showAs: "free" | "tentative" | "away" | "busy" | "workingElsewhere"; + start: { dateTime: string }; + end: { dateTime: string }; + }[]; + }; }; export interface ConferenceData {