Scheduling infrastructure for absolutely everyone.
fix: dynamic event length change on reschedule (#14110)
Shobana Chandrasekaranece74cbc495a
diff --git a/packages/features/bookings/Booker/store.ts b/packages/features/bookings/Booker/store.tsindex eb050d11668..1c7954d74b8 100644--- a/packages/features/bookings/Booker/store.ts+++ b/packages/features/bookings/Booker/store.ts@@ -282,7 +282,17 @@ export const useBookerStore = create<BookerStore>((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.tsindex f4079951fdb..f59132e7456 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?: booid: 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.parsebooking["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: {},