feat(SW-717) Fixed bug where available rooms didn't show if there where also unavaible dublicates.
This commit is contained in:
@@ -22,13 +22,25 @@ export function filterDuplicateRoomTypesByLowestPrice(
|
|||||||
const roomMap = new Map()
|
const roomMap = new Map()
|
||||||
|
|
||||||
roomConfigurations.forEach((room) => {
|
roomConfigurations.forEach((room) => {
|
||||||
const { roomType, products } = room
|
const { roomType, products, status } = room
|
||||||
|
|
||||||
if (!duplicateRoomTypes.has(roomType)) {
|
if (!duplicateRoomTypes.has(roomType)) {
|
||||||
roomMap.set(roomType, room)
|
roomMap.set(roomType, room)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const previousRoom = roomMap.get(roomType)
|
||||||
|
|
||||||
|
// Prioritize 'Available' status
|
||||||
|
if (status === "Available" && previousRoom?.status === "NotAvailable") {
|
||||||
|
roomMap.set(roomType, room)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status === "NotAvailable" && previousRoom?.status === "Available") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (previousRoom) {
|
||||||
products.forEach((product) => {
|
products.forEach((product) => {
|
||||||
const { productType } = product
|
const { productType } = product
|
||||||
const publicProduct = productType.public || {
|
const publicProduct = productType.public || {
|
||||||
@@ -99,6 +111,9 @@ export function filterDuplicateRoomTypesByLowestPrice(
|
|||||||
roomMap.set(roomType, room)
|
roomMap.set(roomType, room)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
roomMap.set(roomType, room)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return Array.from(roomMap.values())
|
return Array.from(roomMap.values())
|
||||||
|
|||||||
Reference in New Issue
Block a user