From c5a40f6c37f744639c5690762c03b0d0d79b6c1d Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Thu, 16 Jun 2022 17:03:51 +0100 Subject: [PATCH] Fix for slots being duplicated in teams (#3082) --- apps/web/lib/slots.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/web/lib/slots.ts b/apps/web/lib/slots.ts index f7011edf47..758b2823da 100644 --- a/apps/web/lib/slots.ts +++ b/apps/web/lib/slots.ts @@ -100,7 +100,15 @@ const getSlots = ({ inviteeDate, frequency, minimumBookingNotice, workingHours, slots.push(slot); } }); - return slots; + + const uniq = (a: Dayjs[]) => { + const seen: Record = {}; + return a.filter((item) => { + return seen.hasOwnProperty(item.format()) ? false : (seen[item.format()] = true); + }); + }; + + return uniq(slots); }; export default getSlots;