From f123635020faca062d2f14e4c046be5020a4a393 Mon Sep 17 00:00:00 2001 From: Jan Berg Date: Tue, 23 Jul 2024 13:30:25 +0300 Subject: [PATCH] The booking duration is now only shown once in the room list. The reservationTime used for RoomCardReservationStatusIndicator now also correctly displays the remaining time. --- frontend/src/components/RoomCard/RoomCard.tsx | 68 ++----------------- 1 file changed, 6 insertions(+), 62 deletions(-) diff --git a/frontend/src/components/RoomCard/RoomCard.tsx b/frontend/src/components/RoomCard/RoomCard.tsx index 31cf33b..4758c42 100644 --- a/frontend/src/components/RoomCard/RoomCard.tsx +++ b/frontend/src/components/RoomCard/RoomCard.tsx @@ -88,7 +88,11 @@ export function getBookingTimeLeft(booking: Booking | undefined) { if (booking === undefined) { return 0; } - return Math.ceil(getTimeLeftMinutes(booking.endTime)) + 2; + // If the booking is ongoing, i.e start time is before "now", then do getTimeLeftMinutes + // Otherwise just get the total duration of the booking + return DateTime.fromISO(booking.startTime) <= DateTime.now() + ? Math.ceil(getTimeLeftMinutes(booking.endTime)) + 2 + : getTimeDiff(booking.startTime, booking.endTime); } export function getTimeAvailableMinutes(booking: Booking | undefined) { @@ -330,10 +334,7 @@ const ReservationStatusText = (props: { @@ -456,60 +457,6 @@ const RoomCard = (props: RoomCardProps) => { return defaultVars; }; - const bookingTime = () => { - if (isReserved) { - if (booking?.resourceStatus === 'accepted') { - if (DateTime.fromISO(booking.startTime) <= DateTime.now()) { - return ( - - - - Booked to you for {getBookingTimeLeft(booking)}{' '} - minutes. - - - ); - } else { - return ( - - - - Booked to you for{' '} - {getTimeDiff( - booking.startTime, - booking.endTime - )}{' '} - minutes. - - - ); - } - } else { - return ( - - - - Waiting Google calendar confirmation. - - - ); - } - } - return null; - }; - return ( { /> - - {bookingTime()} -