From a7956175f9f997f9c7649f513144864bd068a09a Mon Sep 17 00:00:00 2001 From: Srikanthan <102219405+techwithsrikanth@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:26:07 +0530 Subject: [PATCH] Update handleCancelBooking.ts allow the cancellation of past time slots when allRemainingBookings is true prevents error 400 --- packages/features/bookings/lib/handleCancelBooking.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.ts index b4fb989203..bd65d19f6b 100644 --- a/packages/features/bookings/lib/handleCancelBooking.ts +++ b/packages/features/bookings/lib/handleCancelBooking.ts @@ -129,7 +129,8 @@ async function handler(req: CustomRequest) { throw new HttpError({ statusCode: 400, message: "Booking not found" }); } - if (userId !== bookingToDelete.user?.id && bookingToDelete.startTime < new Date()) { + if (userId !== bookingToDelete.user?.id && !allRemainingBookings) { + // Allow cancellation for past time slots when allRemainingBookings is true throw new HttpError({ statusCode: 400, message: "Cannot cancel past events" }); }