diff --git a/packages/features/bookings/Booker/store.ts b/packages/features/bookings/Booker/store.ts index eb050d1166..1c7954d74b 100644 --- a/packages/features/bookings/Booker/store.ts +++ b/packages/features/bookings/Booker/store.ts @@ -282,7 +282,17 @@ export const useBookerStore = create((set, get) => ({ // if the user reschedules a booking right after the confirmation page. // In that case the time would still be store in the store, this way we // force clear this. - if (rescheduleUid && bookingData) set({ selectedTimeslot: null }); + // Also, fetch the original booking duration if user is rescheduling and + // update the selectedDuration + if (rescheduleUid && bookingData) { + set({ selectedTimeslot: null }); + const originalBookingLength = dayjs(bookingData?.endTime).diff( + dayjs(bookingData?.startTime), + "minutes" + ); + set({ selectedDuration: originalBookingLength }); + updateQueryParam("duration", originalBookingLength ?? ""); + } if (month) set({ month }); if (isInstantMeeting) { diff --git a/packages/features/bookings/lib/get-booking.ts b/packages/features/bookings/lib/get-booking.ts index f4079951fd..f59132e745 100644 --- a/packages/features/bookings/lib/get-booking.ts +++ b/packages/features/bookings/lib/get-booking.ts @@ -54,6 +54,7 @@ async function getBooking(prisma: PrismaClient, uid: string, isSeatedEvent?: boo id: true, uid: true, startTime: true, + endTime: true, description: true, customInputs: true, responses: true, @@ -85,6 +86,7 @@ async function getBooking(prisma: PrismaClient, uid: string, isSeatedEvent?: boo // @NOTE: had to do this because Server side cant return [Object objects] // probably fixable with json.stringify -> json.parse booking["startTime"] = (booking?.startTime as Date)?.toISOString() as unknown as Date; + booking["endTime"] = (booking?.endTime as Date)?.toISOString() as unknown as Date; } return booking; @@ -223,6 +225,7 @@ export const getBookingForSeatedEvent = async (uid: string) => { id: true, uid: true, startTime: true, + endTime: true, attendees: { select: { id: true, @@ -254,6 +257,7 @@ export const getBookingForSeatedEvent = async (uid: string) => { ...booking, // @NOTE: had to do this because Server side cant return [Object objects] startTime: booking.startTime.toISOString() as unknown as Date, + endTime: booking.endTime.toISOString() as unknown as Date, description: null, customInputs: null, responses: {},