From 053ef4a1c9b13f1093c498e0b58b5f365b96f43b Mon Sep 17 00:00:00 2001 From: Niclas Edenvin Date: Tue, 7 Jan 2025 10:39:28 +0000 Subject: [PATCH] Merged in fix/sw-1120-pet-costs (pull request #1125) fix(sw-1120): include pet cost in total * fix(sw-1120): include pet cost in total Approved-by: Bianca Widstam --- .../RoomSelection/RateSummary/index.tsx | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx index 109bbcd76..0def76307 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/RateSummary/index.tsx @@ -39,7 +39,6 @@ export default function RateSummary({ priceName, priceTerm, } = rateSummary - const priceToShow = isUserLoggedIn && member ? member : publicRate const isPetRoomSelected = features.some( (feature) => feature.code === RoomPackageCodeEnum.PET_ROOM @@ -49,13 +48,38 @@ export default function RateSummary({ (pkg) => pkg.code === RoomPackageCodeEnum.PET_ROOM ) + const petRoomLocalPrice = + isPetRoomSelected && petRoomPackage?.localPrice.totalPrice + ? Number(petRoomPackage?.localPrice.totalPrice) + : 0 + const petRoomRequestedPrice = + isPetRoomSelected && petRoomPackage?.requestedPrice.totalPrice + ? Number(petRoomPackage?.requestedPrice.totalPrice) + : 0 + + const priceToShow = isUserLoggedIn && member ? member : publicRate + + const totalPriceToShow = { + localPrice: { + currency: priceToShow.localPrice.currency, + price: priceToShow.localPrice.pricePerStay + petRoomLocalPrice, + }, + requestedPrice: !priceToShow.requestedPrice + ? undefined + : { + currency: priceToShow.requestedPrice.currency, + price: + priceToShow.requestedPrice.pricePerStay + petRoomRequestedPrice, + }, + } + const checkInDate = new Date(roomsAvailability.checkInDate) const checkOutDate = new Date(roomsAvailability.checkOutDate) const nights = dt(checkOutDate).diff(dt(checkInDate), "days") const showMemberDiscountBanner = member && !isUserLoggedIn - const summaryPriceTex = `${intl.formatMessage( + const summaryPriceText = `${intl.formatMessage( { id: "booking.nights" }, { totalNights: nights } )}, ${intl.formatMessage( @@ -83,7 +107,7 @@ export default function RateSummary({
@@ -96,7 +120,7 @@ export default function RateSummary({ { b: (str) => {str} } )} - {summaryPriceTex} + {summaryPriceText}
@@ -106,17 +130,17 @@ export default function RateSummary({ > {formatPrice( intl, - priceToShow.localPrice.pricePerStay, - priceToShow.localPrice.currency + totalPriceToShow.localPrice.price, + totalPriceToShow.localPrice.currency )} - {priceToShow?.requestedPrice ? ( + {totalPriceToShow?.requestedPrice ? ( {intl.formatMessage({ id: "Approx." })}{" "} {formatPrice( intl, - priceToShow.requestedPrice.pricePerStay, - priceToShow.requestedPrice.currency + totalPriceToShow.requestedPrice.price, + totalPriceToShow.requestedPrice.currency )} ) : null} @@ -128,36 +152,17 @@ export default function RateSummary({ {formatPrice( intl, - priceToShow.localPrice.pricePerStay, - priceToShow.localPrice.currency + totalPriceToShow.localPrice.price, + totalPriceToShow.localPrice.currency )} - {summaryPriceTex} + {summaryPriceText}
- {isPetRoomSelected && petRoomPackage?.localPrice && ( -
- - +{" "} - {formatPrice( - intl, - parseInt(petRoomPackage.localPrice.totalPrice), - petRoomPackage.localPrice.currency - )} - - - {intl.formatMessage({ id: "Pet charge" })} - -
- )}