Merged in fix/SW-2717-select-hotel-booking-codes- (pull request #2270)
fix: SW-2717 Updated filter display rules * fix: SW-2717 Updated filter display rules * fix: SW-2717 Fixed chip button trigger popover after next upgrade * SW-2717 Optimised code Approved-by: Erik Tiekstra
This commit is contained in:
@@ -23,6 +23,7 @@ interface SelectHotelProps {
|
||||
bookingCode?: string
|
||||
city: Location
|
||||
hotels: HotelResponse[]
|
||||
isBookingCodeRateAvailable?: boolean
|
||||
mapHref: string
|
||||
title: string
|
||||
}
|
||||
@@ -32,43 +33,28 @@ export default async function SelectHotel({
|
||||
city,
|
||||
hotels,
|
||||
isAlternative = false,
|
||||
isBookingCodeRateAvailable = false,
|
||||
mapHref,
|
||||
title,
|
||||
}: SelectHotelProps) {
|
||||
const intl = await getIntl()
|
||||
|
||||
const isAllUnavailable = !hotels.length
|
||||
const isAllUnavailable = hotels.every(
|
||||
(hotel) => hotel.availability.status !== "Available"
|
||||
)
|
||||
const isCityWithCountry = (city: any): city is { country: string } =>
|
||||
"country" in city
|
||||
|
||||
const isBookingCodeRateAvailable = bookingCode
|
||||
? hotels.some(
|
||||
(hotel) =>
|
||||
hotel.availability.bookingCode &&
|
||||
hotel.availability.status === "Available"
|
||||
)
|
||||
: false
|
||||
|
||||
const isFullPriceHotelAvailable = bookingCode
|
||||
? hotels?.some(
|
||||
(hotel) =>
|
||||
!hotel.availability.bookingCode &&
|
||||
hotel.availability.status === "Available"
|
||||
)
|
||||
: false
|
||||
|
||||
// Special rates (corporate cheque, voucher and reward nights) will not have regular rate hotels availability
|
||||
// Special rates (corporate cheque, voucher) will not have regular rate hotels availability
|
||||
const isSpecialRate = hotels.some(
|
||||
(hotel) =>
|
||||
hotel.availability.productType?.bonusCheque ||
|
||||
hotel.availability.productType?.voucher ||
|
||||
hotel.availability.productType?.redemptions
|
||||
hotel.availability.productType?.voucher
|
||||
)
|
||||
|
||||
const filterList = getFiltersFromHotels(hotels)
|
||||
|
||||
const showBookingCodeFilter =
|
||||
isBookingCodeRateAvailable && isFullPriceHotelAvailable && !isSpecialRate
|
||||
const showBookingCodeFilter = isBookingCodeRateAvailable && !isSpecialRate
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user