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
This commit is contained in:
Niclas Edenvin
2025-01-07 10:39:28 +00:00
parent 0ac09f37f6
commit 053ef4a1c9

View File

@@ -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({
<div className={styles.promoContainer}>
<SignupPromoDesktop
memberPrice={{
amount: member.localPrice.pricePerStay,
amount: member.localPrice.pricePerStay + petRoomLocalPrice,
currency: member.localPrice.currency,
}}
/>
@@ -96,7 +120,7 @@ export default function RateSummary({
{ b: (str) => <b>{str}</b> }
)}
</Body>
<Caption color="uiTextMediumContrast">{summaryPriceTex}</Caption>
<Caption color="uiTextMediumContrast">{summaryPriceText}</Caption>
</div>
<div className={styles.summaryPrice}>
<div className={styles.summaryPriceTextDesktop}>
@@ -106,17 +130,17 @@ export default function RateSummary({
>
{formatPrice(
intl,
priceToShow.localPrice.pricePerStay,
priceToShow.localPrice.currency
totalPriceToShow.localPrice.price,
totalPriceToShow.localPrice.currency
)}
</Subtitle>
{priceToShow?.requestedPrice ? (
{totalPriceToShow?.requestedPrice ? (
<Body color="uiTextMediumContrast">
{intl.formatMessage({ id: "Approx." })}{" "}
{formatPrice(
intl,
priceToShow.requestedPrice.pricePerStay,
priceToShow.requestedPrice.currency
totalPriceToShow.requestedPrice.price,
totalPriceToShow.requestedPrice.currency
)}
</Body>
) : null}
@@ -128,36 +152,17 @@ export default function RateSummary({
<Subtitle color={isUserLoggedIn ? "red" : "uiTextHighContrast"}>
{formatPrice(
intl,
priceToShow.localPrice.pricePerStay,
priceToShow.localPrice.currency
totalPriceToShow.localPrice.price,
totalPriceToShow.localPrice.currency
)}
</Subtitle>
<Footnote
color="uiTextMediumContrast"
className={styles.summaryPriceTextMobile}
>
{summaryPriceTex}
{summaryPriceText}
</Footnote>
</div>
{isPetRoomSelected && petRoomPackage?.localPrice && (
<div className={styles.petInfo}>
<Body
color="uiTextHighContrast"
textTransform="bold"
textAlign="right"
>
+{" "}
{formatPrice(
intl,
parseInt(petRoomPackage.localPrice.totalPrice),
petRoomPackage.localPrice.currency
)}
</Body>
<Body color="uiTextMediumContrast" textAlign="right">
{intl.formatMessage({ id: "Pet charge" })}
</Body>
</div>
)}
<Button
type="submit"
theme="base"