Update handleCancelBooking.ts

allow the cancellation of past time slots when allRemainingBookings is true prevents error 400
pull/12074/head
Srikanthan 2023-10-25 10:26:07 +05:30 committed by GitHub
parent 79c1aa60a2
commit a7956175f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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" });
}