Merged in feat/SW-1557-implement-booking-code-select (pull request #1304)
feat: SW-1577 Implemented booking code city search * feat: SW-1577 Implemented booking code city search * feat: SW-1557 Strict comparison * feat: SW-1557 Review comments fix Approved-by: Michael Zetterberg Approved-by: Pontus Dreij
This commit is contained in:
@@ -5,6 +5,7 @@ import { useIntl } from "react-intl"
|
||||
import { useMediaQuery } from "usehooks-ts"
|
||||
|
||||
import { selectHotel } from "@/constants/routes/hotelReservation"
|
||||
import { useBookingCodeFilterStore } from "@/stores/bookingCode-filter"
|
||||
import { useHotelFilterStore } from "@/stores/hotel-filters"
|
||||
import { useHotelsMapStore } from "@/stores/hotels-map"
|
||||
|
||||
@@ -18,6 +19,7 @@ import useLang from "@/hooks/useLang"
|
||||
import { useScrollToTop } from "@/hooks/useScrollToTop"
|
||||
import { debounce } from "@/utils/debounce"
|
||||
|
||||
import BookingCodeFilter from "../../BookingCodeFilter"
|
||||
import FilterAndSortModal from "../../FilterAndSortModal"
|
||||
import HotelListing from "../HotelListing"
|
||||
import { getVisibleHotels } from "./utils"
|
||||
@@ -35,6 +37,7 @@ export default function SelectHotelContent({
|
||||
mapId,
|
||||
hotels,
|
||||
filterList,
|
||||
bookingCode,
|
||||
}: Omit<SelectHotelMapProps, "apiKey">) {
|
||||
const lang = useLang()
|
||||
const intl = useIntl()
|
||||
@@ -53,6 +56,9 @@ export default function SelectHotelContent({
|
||||
elementRef: listingContainerRef,
|
||||
refScrollable: true,
|
||||
})
|
||||
const activeCodeFilter = useBookingCodeFilterStore(
|
||||
(state) => state.activeCodeFilter
|
||||
)
|
||||
|
||||
const coordinates = useMemo(
|
||||
() =>
|
||||
@@ -72,15 +78,23 @@ export default function SelectHotelContent({
|
||||
}
|
||||
}, [activeHotelCard, activeHotelPin])
|
||||
|
||||
const filteredHotelPins = useMemo(
|
||||
() =>
|
||||
hotelPins.filter((hotel) =>
|
||||
activeFilters.every((filterId) =>
|
||||
hotel.facilityIds.includes(Number(filterId))
|
||||
const filteredHotelPins = useMemo(() => {
|
||||
const updatedHotelsList = bookingCode
|
||||
? hotelPins.filter(
|
||||
(hotel) =>
|
||||
!hotel.publicPrice ||
|
||||
activeCodeFilter === "all" ||
|
||||
(activeCodeFilter === "discounted" &&
|
||||
hotel.rateType?.toLowerCase() !== "regular") ||
|
||||
activeCodeFilter === hotel.rateType?.toLowerCase()
|
||||
)
|
||||
),
|
||||
[activeFilters, hotelPins]
|
||||
)
|
||||
: hotelPins
|
||||
return updatedHotelsList.filter((hotel) =>
|
||||
activeFilters.every((filterId) =>
|
||||
hotel.facilityIds.includes(Number(filterId))
|
||||
)
|
||||
)
|
||||
}, [activeFilters, hotelPins, bookingCode, activeCodeFilter])
|
||||
|
||||
const getHotelCards = useCallback(() => {
|
||||
const visibleHotels = getVisibleHotels(hotels, filteredHotelPins, map)
|
||||
@@ -143,6 +157,7 @@ export default function SelectHotelContent({
|
||||
filters={filterList}
|
||||
setShowSkeleton={setShowSkeleton}
|
||||
/>
|
||||
{bookingCode ? <BookingCodeFilter /> : null}
|
||||
</div>
|
||||
|
||||
{showSkeleton ? (
|
||||
|
||||
Reference in New Issue
Block a user