From ff2754f663aea9d0ecb1d2308080927c5d287879 Mon Sep 17 00:00:00 2001 From: Kartik Saini <41051387+kart1ka@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:25:39 +0530 Subject: [PATCH] feat: allow marking no show after booking has started (#17625) * feat: allow marking no show after booking has started * fix --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> --- apps/web/components/booking/BookingListItem.tsx | 3 ++- packages/features/handleMarkNoShow.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 1baf6e8f33..736ed28ce8 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -132,6 +132,7 @@ function BookingListItem(booking: BookingItemProps) { }); const isUpcoming = new Date(booking.endTime) >= new Date(); + const isOngoing = isUpcoming && new Date() >= new Date(booking.startTime); const isBookingInPast = new Date(booking.endTime) < new Date(); const isCancelled = booking.status === BookingStatus.CANCELLED; const isConfirmed = booking.status === BookingStatus.ACCEPTED; @@ -269,7 +270,7 @@ function BookingListItem(booking: BookingItemProps) { }); } - if (isBookingInPast) { + if (isBookingInPast || isOngoing) { editBookingActions.push({ id: "no_show", label: t("mark_as_no_show"), diff --git a/packages/features/handleMarkNoShow.ts b/packages/features/handleMarkNoShow.ts index 784d3a70be..d2269ff83c 100644 --- a/packages/features/handleMarkNoShow.ts +++ b/packages/features/handleMarkNoShow.ts @@ -216,6 +216,16 @@ const assertCanAccessBooking = async (bookingUid: string, userId?: number) => { if (!booking) throw new HttpError({ statusCode: 403, message: "You are not allowed to access this booking" }); + + const isUpcoming = new Date(booking.endTime) >= new Date(); + const isOngoing = isUpcoming && new Date() >= new Date(booking.startTime); + const isBookingInPast = new Date(booking.endTime) < new Date(); + if (!isBookingInPast && !isOngoing) { + throw new HttpError({ + statusCode: 403, + message: "Cannot mark no-show before the meeting has started.", + }); + } }; export default handleMarkNoShow;