From 8b53ed3301103e46285afec201e3af88a3c34a53 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Thu, 20 Feb 2025 12:03:26 +0100 Subject: [PATCH] feat: SW-1588 Optimized code & comments --- .../RoomCard/FlexibilityOption/PriceList/index.tsx | 7 ++++++- .../RoomsContainer/Rooms/RoomSelectionPanel/index.tsx | 6 ++++-- .../hotels/schemas/roomAvailability/configuration.ts | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomCard/FlexibilityOption/PriceList/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomCard/FlexibilityOption/PriceList/index.tsx index a421c93c2..c605baa21 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomCard/FlexibilityOption/PriceList/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/RoomCard/FlexibilityOption/PriceList/index.tsx @@ -63,6 +63,11 @@ export default function PriceList({ nights, }) + // When it is Promotion rate either booking code rate or public + // Show striked Regular rate which is overtaken by the Promotional rate when member rate is not available + const showOvertakingPrice = + !memberLocalPrice && publicLocalPrice.regularPricePerNight + return (
{isUserLoggedIn && isMainRoom && memberLocalPrice ? null : ( @@ -129,7 +134,7 @@ export default function PriceList({ )} - {publicLocalPrice.regularPricePerNight && ( + {showOvertakingPrice && (
diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/index.tsx index 882450e63..2dd064350 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/Rooms/RoomSelectionPanel/index.tsx @@ -34,8 +34,8 @@ export default function RoomSelectionPanel() { (state) => state.activeCodeFilter ) - // With Booking code rates we will always obtain public rate and never a member rate, - // so we should ignore it from the logic below. + // Regular Rates (Save, Change and Flex) always should send both public and member rates + // so we can check public rates for availability const isRegularRatesAvailableWithCode = bookingCode && rooms.some( @@ -49,6 +49,8 @@ export default function RoomSelectionPanel() { // Booking codes rate comes with various rate types but Regular is reserved // for non-booking code rates (Save, Change & Flex) + // With Booking code rates we will always obtain public rate and maybe a member rate + // so we check for public rate and ignore member rate const isBookingCodeRatesAvailable = bookingCode && rooms.some( diff --git a/apps/scandic-web/server/routers/hotels/schemas/roomAvailability/configuration.ts b/apps/scandic-web/server/routers/hotels/schemas/roomAvailability/configuration.ts index 56acc0e14..9c5ed5ae7 100644 --- a/apps/scandic-web/server/routers/hotels/schemas/roomAvailability/configuration.ts +++ b/apps/scandic-web/server/routers/hotels/schemas/roomAvailability/configuration.ts @@ -44,7 +44,8 @@ export const roomConfigurationSchema = z return product } - // Return rate even if single when booking code rate which can be any one of other rate types + // Return rate with only public available when it is a booking code rate + // which can be any one of other rate types if (product.productType.public.rateType !== RateTypeEnum.Regular) { return product }