From 1c20bdcecf1c0924047e069f04f04fd747f14310 Mon Sep 17 00:00:00 2001 From: Somay Chauhan Date: Thu, 30 Nov 2023 23:57:37 +0530 Subject: [PATCH] fix: rescheduling recurring events (#12567) --- apps/web/components/booking/BookingListItem.tsx | 8 ++++---- apps/web/pages/booking/[uid].tsx | 1 + .../Booker/components/BookEventForm/BookEventForm.tsx | 2 +- .../features/bookings/components/event-meta/Details.tsx | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index f2281abd8a7900..4af0888a2915c2 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -525,8 +525,8 @@ const RecurringBookingsTooltip = ({ return ( recurringDate >= now && !booking.recurringInfo?.bookings[BookingStatus.CANCELLED] - .map((date) => date.toDateString()) - .includes(recurringDate.toDateString()) + .map((date) => date.toString()) + .includes(recurringDate.toString()) ); }).length; @@ -543,8 +543,8 @@ const RecurringBookingsTooltip = ({ const pastOrCancelled = aDate < now || booking.recurringInfo?.bookings[BookingStatus.CANCELLED] - .map((date) => date.toDateString()) - .includes(aDate.toDateString()); + .map((date) => date.toString()) + .includes(aDate.toString()); return (

{formatTime(aDate, userTimeFormat, userTimeZone)} diff --git a/apps/web/pages/booking/[uid].tsx b/apps/web/pages/booking/[uid].tsx index 029652211a1c5f..3221ffe7d5ba9f 100644 --- a/apps/web/pages/booking/[uid].tsx +++ b/apps/web/pages/booking/[uid].tsx @@ -1244,6 +1244,7 @@ async function getRecurringBookings(recurringEventId: string | null) { const recurringBookings = await prisma.booking.findMany({ where: { recurringEventId, + status: BookingStatus.ACCEPTED, }, select: { startTime: true, diff --git a/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx b/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx index ebbbdeeb45077d..dc8be1e7730bbd 100644 --- a/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx +++ b/packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx @@ -344,7 +344,7 @@ export const BookEventFormChild = ({ hashedLink, }; - if (eventQuery.data?.recurringEvent?.freq && recurringEventCount) { + if (eventQuery.data?.recurringEvent?.freq && recurringEventCount && !rescheduleUid) { createRecurringBookingMutation.mutate( mapRecurringBookingToMutationInput(bookingInput, recurringEventCount) ); diff --git a/packages/features/bookings/components/event-meta/Details.tsx b/packages/features/bookings/components/event-meta/Details.tsx index ee7b9f301745ed..6a5bac820268a9 100644 --- a/packages/features/bookings/components/event-meta/Details.tsx +++ b/packages/features/bookings/components/event-meta/Details.tsx @@ -1,6 +1,7 @@ import { Fragment } from "react"; import React from "react"; +import { useBookerStore } from "@calcom/features/bookings/Booker/store"; import classNames from "@calcom/lib/classNames"; import getPaymentAppData from "@calcom/lib/getPaymentAppData"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -110,6 +111,7 @@ export const EventMetaBlock = ({ */ export const EventDetails = ({ event, blocks = defaultEventDetailsBlocks }: EventDetailsProps) => { const { t } = useLocale(); + const rescheduleUid = useBookerStore((state) => state.rescheduleUid); return ( <> @@ -144,7 +146,7 @@ export const EventDetails = ({ event, blocks = defaultEventDetailsBlocks }: Even ); case EventDetailBlocks.OCCURENCES: - if (!event.recurringEvent) return null; + if (!event.recurringEvent || rescheduleUid) return null; return (