Update handleCancelBooking.ts
allow the cancellation of past time slots when allRemainingBookings is true prevents error 400pull/12074/head
parent
79c1aa60a2
commit
a7956175f9
|
@ -129,7 +129,8 @@ async function handler(req: CustomRequest) {
|
||||||
throw new HttpError({ statusCode: 400, message: "Booking not found" });
|
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" });
|
throw new HttpError({ statusCode: 400, message: "Cannot cancel past events" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue