Merged in fix/allow-single-rateCode (pull request #1438)

fix: allow rates that only have either of member or public to be selectable

* fix: allow rates that only have either of member or public to be selectable


Approved-by: Michael Zetterberg
This commit is contained in:
Simon.Emanuelsson
2025-03-03 08:28:55 +00:00
committed by Linus Flood
parent 3f01266a75
commit c3e3fa62ec
30 changed files with 487 additions and 573 deletions

View File

@@ -12,10 +12,15 @@ export const calculateTotalPrice = (
) => {
return selectedRateSummary.reduce<Price>(
(total, room, idx) => {
const priceToUse =
const rate =
isUserLoggedIn && room.member && idx + 1 === 1
? room.member
: room.public
if (!rate) {
return total
}
const isPetRoom = room.features.find(
(feature) => feature.code === RoomPackageCodeEnum.PET_ROOM
)
@@ -31,18 +36,16 @@ export const calculateTotalPrice = (
return {
local: {
currency: priceToUse.localPrice.currency,
currency: rate.localPrice.currency,
price:
total.local.price +
priceToUse.localPrice.pricePerStay +
petRoomPrice,
total.local.price + rate.localPrice.pricePerStay + petRoomPrice,
},
requested: priceToUse.requestedPrice
requested: rate.requestedPrice
? {
currency: priceToUse.requestedPrice.currency,
currency: rate.requestedPrice.currency,
price:
(total.requested?.price ?? 0) +
priceToUse.requestedPrice.pricePerStay +
rate.requestedPrice.pricePerStay +
petRoomPrice,
}
: undefined,
@@ -50,7 +53,8 @@ export const calculateTotalPrice = (
},
{
local: {
currency: selectedRateSummary[0].public.localPrice.currency,
currency: (selectedRateSummary[0].public?.localPrice.currency ||
selectedRateSummary[0].member?.localPrice.currency)!,
price: 0,
},
requested: undefined,