fix: dynamic event length change on reschedule (#14110)

* fixed dynamic event length change on reschedule

* fixed dynamic event length change on reschedule

* Update get-booking.ts

Type check: added endTime

* Update get-booking.ts

* Fix: typeCheck error

* Revert yarn.lock to its state before unintended changes
This commit is contained in:
Shobana Chandrasekaran
2024-03-18 14:53:53 -04:00
committed by GitHub
parent 3c5a007125
commit ece74cbc49
2 changed files with 15 additions and 1 deletions
+11 -1
View File
@@ -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) {
@@ -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: {},