Merged in feat/SW-2398-ui-update-for-booking-codes (pull request #1862)
feat: SW-2398 UI updates booking codes * feat: SW-2398 UI updates booking codes * feat: SW-2398 Rate cards UI changes * feat: SW-2398 Optimized css with vars and chip code * feat: SW-2398 Optimized code as review comments * feat: SW-2398 Optimized code * feat: SW-2398 Optimized code and mobile UX * feat: SW-2398 Optimized code * feat: SW-2398 Fixed UI * feat: SW-2398 Updated animation Approved-by: Erik Tiekstra
This commit is contained in:
@@ -25,7 +25,6 @@ import {
|
||||
} from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
|
||||
import { AlertTypeEnum } from "@/types/enums/alert"
|
||||
import { BookingCodeFilterEnum } from "@/types/enums/bookingCodeFilter"
|
||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||
|
||||
export default function HotelCardListing({
|
||||
hotelData,
|
||||
@@ -44,16 +43,28 @@ export default function HotelCardListing({
|
||||
const sortBy = searchParams.get("sort") ?? DEFAULT_SORT
|
||||
|
||||
const bookingCode = searchParams.get("bookingCode")
|
||||
// Special rates (corporate cheque, voucher and reward nights) will not have regular rate hotels availability
|
||||
const isSpecialRate = hotelData.find(
|
||||
(hotel) =>
|
||||
hotel.availability.productType?.bonusCheque ||
|
||||
hotel.availability.productType?.voucher ||
|
||||
hotel.availability.productType?.redemptions
|
||||
)
|
||||
// Special rates (corporate cheque, voucher) will not show regular rate hotels availability
|
||||
const isSpecialRate = bookingCode
|
||||
? hotelData.find(
|
||||
(hotel) =>
|
||||
hotel.availability.productType?.bonusCheque ||
|
||||
hotel.availability.productType?.voucher
|
||||
)
|
||||
: false
|
||||
const activeCodeFilter = useBookingCodeFilterStore(
|
||||
(state) => state.activeCodeFilter
|
||||
)
|
||||
const isBookingCodeRateAvailable =
|
||||
bookingCode && !isSpecialRate
|
||||
? hotelData.some(
|
||||
(hotel) =>
|
||||
hotel.availability.productType?.public?.bookingCode ||
|
||||
hotel.availability.productType?.member?.bookingCode
|
||||
)
|
||||
: false
|
||||
const showOnlyBookingCodeRates =
|
||||
isBookingCodeRateAvailable &&
|
||||
activeCodeFilter !== BookingCodeFilterEnum.Discounted
|
||||
|
||||
const hotels = useMemo(() => {
|
||||
const sortedHotels = getSortedHotels({
|
||||
@@ -61,24 +72,14 @@ export default function HotelCardListing({
|
||||
sortBy,
|
||||
bookingCode: isSpecialRate ? null : bookingCode,
|
||||
})
|
||||
const updatedHotelsList =
|
||||
bookingCode && !isSpecialRate
|
||||
? sortedHotels.filter(
|
||||
(hotel) =>
|
||||
!hotel.availability.productType ||
|
||||
activeCodeFilter === BookingCodeFilterEnum.All ||
|
||||
(activeCodeFilter === BookingCodeFilterEnum.Discounted &&
|
||||
hotel.availability.productType.public?.rateType !==
|
||||
RateTypeEnum.Regular &&
|
||||
hotel.availability.productType.member?.rateType !==
|
||||
RateTypeEnum.Regular) ||
|
||||
(activeCodeFilter === BookingCodeFilterEnum.Regular &&
|
||||
(hotel.availability.productType.public?.rateType ===
|
||||
RateTypeEnum.Regular ||
|
||||
hotel.availability.productType.member?.rateType ===
|
||||
RateTypeEnum.Regular))
|
||||
)
|
||||
: sortedHotels
|
||||
|
||||
const updatedHotelsList = showOnlyBookingCodeRates
|
||||
? sortedHotels.filter(
|
||||
(hotel) =>
|
||||
hotel.availability.productType?.public?.bookingCode ||
|
||||
hotel.availability.productType?.member?.bookingCode
|
||||
)
|
||||
: sortedHotels
|
||||
|
||||
if (!activeFilters.length) {
|
||||
return updatedHotelsList
|
||||
@@ -92,11 +93,11 @@ export default function HotelCardListing({
|
||||
)
|
||||
)
|
||||
}, [
|
||||
activeCodeFilter,
|
||||
activeFilters,
|
||||
bookingCode,
|
||||
hotelData,
|
||||
sortBy,
|
||||
showOnlyBookingCodeRates,
|
||||
isSpecialRate,
|
||||
])
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { SortOrder } from "@/types/components/hotelReservation/selectHotel/hotelSorter"
|
||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||
import type { HotelResponse } from "@/components/HotelReservation/SelectHotel/helpers"
|
||||
|
||||
function getPricePerNight(hotel: HotelResponse): number {
|
||||
@@ -50,18 +49,13 @@ export function getSortedHotels({
|
||||
if (bookingCode) {
|
||||
const bookingCodeRateHotels = availableHotels.filter(
|
||||
(hotel) =>
|
||||
hotel.availability.productType?.public?.rateType !==
|
||||
RateTypeEnum.Regular &&
|
||||
hotel.availability.productType?.member?.rateType !==
|
||||
RateTypeEnum.Regular &&
|
||||
!!hotel.availability.productType
|
||||
hotel.availability.productType?.public?.bookingCode ||
|
||||
hotel.availability.productType?.member?.bookingCode
|
||||
)
|
||||
const regularRateHotels = availableHotels.filter(
|
||||
(hotel) =>
|
||||
hotel.availability.productType?.public?.rateType ===
|
||||
RateTypeEnum.Regular ||
|
||||
hotel?.availability.productType?.member?.rateType ===
|
||||
RateTypeEnum.Regular
|
||||
!hotel.availability.productType?.public?.bookingCode &&
|
||||
!hotel?.availability.productType?.member?.bookingCode
|
||||
)
|
||||
|
||||
return bookingCodeRateHotels
|
||||
|
||||
Reference in New Issue
Block a user