Skip to content

Commit 5de488d

Browse files
committed
fix date compare logic
considering date, start_time when compare reservation time with current time
1 parent 1d0bca6 commit 5de488d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/popo/reservation/place/reserve.place.controller.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,14 @@ export class ReservePlaceController {
286286
await this.reservePlaceService.remove(uuid);
287287
} else {
288288
if (reservation.booker_id == user.uuid) {
289-
if(reservation.start_time < new Date().toISOString()) {
289+
// if reservation is in the past, deny delete
290+
const reservation_time = reservation.date + reservation.start_time;
291+
const current_time = new Date().toISOString().replace(/[-T:]/g, '').slice(0, 12);
292+
if (reservation_time < current_time) {
290293
throw new BadRequestException('Cannot delete past reservation');
294+
} else {
295+
await this.reservePlaceService.remove(uuid);
291296
}
292-
await this.reservePlaceService.remove(uuid);
293297
} else {
294298
throw new UnauthorizedException('Unauthorized delete action');
295299
}

0 commit comments

Comments
 (0)