feat(SW-1717): rewrite select-rate to show all variants of rate-cards

This commit is contained in:
Simon Emanuelsson
2025-03-25 11:25:44 +01:00
committed by Michael Zetterberg
parent adde77eaa9
commit ebaea78fb3
118 changed files with 4601 additions and 4374 deletions

View File

@@ -47,9 +47,9 @@ export default function PriceDetails({
const totalPrice = isBreakfast
? breakfastData!.priceAdult * breakfastData!.nrOfAdults +
breakfastData!.priceChild * breakfastData!.nrOfPayingChildren
breakfastData!.priceChild * breakfastData!.nrOfPayingChildren
: quantityWithCard && selectedAncillary
? selectedAncillary.price.totalPrice * quantityWithCard
? selectedAncillary.price.total * quantityWithCard
: null
const totalPoints =
@@ -101,15 +101,15 @@ export default function PriceDetails({
const items = isBreakfast
? getBreakfastItems(selectedAncillary, breakfastData)
: [
{
title: selectedAncillary.title,
totalPrice: selectedAncillary.price.totalPrice,
currency: selectedAncillary.price.currency,
points: selectedAncillary.points,
quantityWithCard,
quantityWithPoints,
},
]
{
title: selectedAncillary.title,
totalPrice: selectedAncillary.price.total,
currency: selectedAncillary.price.currency,
points: selectedAncillary.points,
quantityWithCard,
quantityWithPoints,
},
]
return (
<>

View File

@@ -1,4 +1,3 @@
import { useEffect } from "react"
import { useFormContext } from "react-hook-form"
import { useIntl } from "react-intl"
@@ -117,7 +116,7 @@ function BreakfastInfo() {
<Alert
type={AlertTypeEnum.Info}
text={intl.formatMessage({
id: "Breakfast can only be added for the entire duration of the stayand for all guests.",
id: "Breakfast can only be added for the entire duration of the stay and for all guests.",
})}
/>
{(breakfastData.nrOfPayingChildren > 0 ||

View File

@@ -212,10 +212,10 @@ export default function AddAncillaryFlowModal({
if (booking.confirmationNumber) {
const card = savedCreditCard
? {
alias: savedCreditCard.alias,
expiryDate: savedCreditCard.expirationDate,
cardType: savedCreditCard.cardType,
}
alias: savedCreditCard.alias,
expiryDate: savedCreditCard.expirationDate,
cardType: savedCreditCard.cardType,
}
: undefined
guaranteeBooking.mutate({
confirmationNumber: booking.confirmationNumber,
@@ -313,7 +313,7 @@ export default function AddAncillaryFlowModal({
) : (
formatPrice(
intl,
selectedAncillary.price.totalPrice,
selectedAncillary.price.total,
selectedAncillary.price.currency
)
)}

View File

@@ -116,7 +116,10 @@ export function Ancillaries({
description: intl.formatMessage({ id: "Buffet" }),
id: breakfastPackage.code,
title: intl.formatMessage({ id: "Breakfast" }),
price: breakfastPackage.localPrice,
price: {
currency: breakfastPackage.localPrice.currency,
total: breakfastPackage.localPrice.totalPrice,
},
// TODO: Change this to the correct URL, whatever that is
imageUrl:
"https://images-test.scandichotels.com/publishedmedia/hcf9hchiad7zrvlkc2pt/Breakfast_-_Scandic_Sweden_-_Free_to_use.jpg",

View File

@@ -106,11 +106,25 @@ export default function useModifyStay({
return { success: false, noAvailability: true }
}
const roomPrice = isLoggedIn
? data.memberRate?.localPrice.pricePerStay
: data.publicRate?.localPrice.pricePerStay
let roomPrice = 0
if (isLoggedIn && "member" in data.product && data.product.member) {
roomPrice = data.product.member.localPrice.pricePerStay
} else if ("public" in data.product && data.product.public) {
roomPrice = data.product.public.localPrice.pricePerStay
} else if (
"corporateCheque" in data.product &&
data.product.corporateCheque.localPrice.additionalPricePerStay
) {
roomPrice =
data.product.corporateCheque.localPrice.additionalPricePerStay
} else if (
"redemption" in data.product &&
data.product.redemption.localPrice.additionalPricePerStay
) {
roomPrice = data.product.redemption.localPrice.additionalPricePerStay
}
totalNewPrice += roomPrice ?? 0
totalNewPrice += roomPrice
availabilityResults.push(data)
} catch (error) {
console.error("Error checking room availability:", error)