feat(SW-874): Updated logic for getLowestPricedDuplicateRooms
This commit is contained in:
@@ -46,7 +46,7 @@ export function getLowestPricedDuplicateRooms(
|
||||
localPrice: memberLocalPrice,
|
||||
} = memberProduct
|
||||
|
||||
const currentLowest = roomMap.get(roomType)
|
||||
const previousLowest = roomMap.get(roomType)
|
||||
|
||||
const currentRequestedPrice = Math.min(
|
||||
Number(publicRequestedPrice.pricePerNight) ?? Infinity,
|
||||
@@ -58,17 +58,42 @@ export function getLowestPricedDuplicateRooms(
|
||||
)
|
||||
|
||||
if (
|
||||
!currentLowest ||
|
||||
currentRequestedPrice < currentLowest.requestedPrice ||
|
||||
(currentRequestedPrice === currentLowest.requestedPrice &&
|
||||
currentLocalPrice < currentLowest.localPrice)
|
||||
!previousLowest ||
|
||||
currentRequestedPrice <
|
||||
Math.min(
|
||||
Number(
|
||||
previousLowest.products[0].productType.public.requestedPrice
|
||||
.pricePerNight
|
||||
) ?? Infinity,
|
||||
Number(
|
||||
previousLowest.products[0].productType.member?.requestedPrice
|
||||
?.pricePerNight
|
||||
) ?? Infinity
|
||||
) ||
|
||||
(currentRequestedPrice ===
|
||||
Math.min(
|
||||
Number(
|
||||
previousLowest.products[0].productType.public.requestedPrice
|
||||
.pricePerNight
|
||||
) ?? Infinity,
|
||||
Number(
|
||||
previousLowest.products[0].productType.member?.requestedPrice
|
||||
?.pricePerNight
|
||||
) ?? Infinity
|
||||
) &&
|
||||
currentLocalPrice <
|
||||
Math.min(
|
||||
Number(
|
||||
previousLowest.products[0].productType.public.localPrice
|
||||
.pricePerNight
|
||||
) ?? Infinity,
|
||||
Number(
|
||||
previousLowest.products[0].productType.member?.localPrice
|
||||
?.pricePerNight
|
||||
) ?? Infinity
|
||||
))
|
||||
) {
|
||||
roomMap.set(roomType, {
|
||||
...room,
|
||||
product,
|
||||
requestedPrice: currentRequestedPrice,
|
||||
localPrice: currentLocalPrice,
|
||||
})
|
||||
roomMap.set(roomType, room)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user