Merged in fix/SW-3117-filter-select-hotel (pull request #2475)
Fix/SW-3117 filter select hotel * fix(SW-3117): default hotel count fix * fix(SW-3117): default hotel count for mobile Approved-by: Tobias Johansson Approved-by: Matilda Landström
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import { useCallback, useEffect, useRef } from "react"
|
import { useCallback, useEffect, useRef } from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { useHotelFilterStore } from "@/stores/hotel-filters"
|
||||||
import { useHotelsMapStore } from "@/stores/hotels-map"
|
import { useHotelsMapStore } from "@/stores/hotels-map"
|
||||||
|
|
||||||
import ListingHotelCardDialog from "../HotelCardDialog/ListingHotelCardDialog"
|
import ListingHotelCardDialog from "../HotelCardDialog/ListingHotelCardDialog"
|
||||||
@@ -14,6 +15,7 @@ import type { HotelCardDialogListingProps } from "@/types/components/hotelReserv
|
|||||||
|
|
||||||
export default function HotelCardDialogListing({
|
export default function HotelCardDialogListing({
|
||||||
hotels,
|
hotels,
|
||||||
|
unfilteredHotelCount,
|
||||||
}: HotelCardDialogListingProps) {
|
}: HotelCardDialogListingProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const isRedemption = hotels?.find(
|
const isRedemption = hotels?.find(
|
||||||
@@ -31,6 +33,7 @@ export default function HotelCardDialogListing({
|
|||||||
const isScrollingRef = useRef<boolean>(false)
|
const isScrollingRef = useRef<boolean>(false)
|
||||||
const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||||
const { activeHotel, activate, deactivate } = useHotelsMapStore()
|
const { activeHotel, activate, deactivate } = useHotelsMapStore()
|
||||||
|
const setResultCount = useHotelFilterStore((state) => state.setResultCount)
|
||||||
|
|
||||||
const handleIntersection = useCallback(
|
const handleIntersection = useCallback(
|
||||||
(entries: IntersectionObserverEntry[]) => {
|
(entries: IntersectionObserverEntry[]) => {
|
||||||
@@ -118,6 +121,10 @@ export default function HotelCardDialogListing({
|
|||||||
}
|
}
|
||||||
}, [dialogRef, activeHotel, deactivate])
|
}, [dialogRef, activeHotel, deactivate])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setResultCount(hotels.length, unfilteredHotelCount)
|
||||||
|
}, [hotels, setResultCount, unfilteredHotelCount])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.hotelCardDialogListing} ref={dialogRef}>
|
<div className={styles.hotelCardDialogListing} ref={dialogRef}>
|
||||||
{hotelsPinData?.map((data) => {
|
{hotelsPinData?.map((data) => {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export default function HotelCardListing({
|
|||||||
}, [activeHotel, type])
|
}, [activeHotel, type])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setResultCount(hotels.length, unfilteredHotelCount ?? hotels.length)
|
setResultCount(hotels.length, unfilteredHotelCount)
|
||||||
}, [hotels, setResultCount, unfilteredHotelCount])
|
}, [hotels, setResultCount, unfilteredHotelCount])
|
||||||
|
|
||||||
function isHotelActiveInMapView(hotelName: string): boolean {
|
function isHotelActiveInMapView(hotelName: string): boolean {
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ export default function HotelListing({
|
|||||||
|
|
||||||
return isMobile ? (
|
return isMobile ? (
|
||||||
<div className={styles.hotelListingMobile} data-open={!!activeHotel}>
|
<div className={styles.hotelListingMobile} data-open={!!activeHotel}>
|
||||||
<HotelCardDialogListing hotels={hotels} />
|
<HotelCardDialogListing
|
||||||
|
hotels={hotels}
|
||||||
|
unfilteredHotelCount={unfilteredHotelCount}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className={styles.hotelListing}>
|
<div className={styles.hotelListing}>
|
||||||
|
|||||||
@@ -121,7 +121,11 @@ export default async function SelectHotel({
|
|||||||
bookingCode={bookingCode}
|
bookingCode={bookingCode}
|
||||||
isBookingCodeRateNotAvailable={!isBookingCodeRateAvailable}
|
isBookingCodeRateNotAvailable={!isBookingCodeRateAvailable}
|
||||||
/>
|
/>
|
||||||
<HotelCardListing hotelData={hotels} isAlternative={isAlternative} />
|
<HotelCardListing
|
||||||
|
hotelData={hotels}
|
||||||
|
isAlternative={isAlternative}
|
||||||
|
unfilteredHotelCount={hotels.length}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export type HotelData = {
|
|||||||
|
|
||||||
export type HotelCardListingProps = {
|
export type HotelCardListingProps = {
|
||||||
hotelData: HotelResponse[]
|
hotelData: HotelResponse[]
|
||||||
unfilteredHotelCount?: number
|
unfilteredHotelCount: number
|
||||||
type?: HotelCardListingTypeEnum
|
type?: HotelCardListingTypeEnum
|
||||||
isAlternative?: boolean
|
isAlternative?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ export interface HotelCardDialogImageProps {
|
|||||||
|
|
||||||
export interface HotelCardDialogListingProps {
|
export interface HotelCardDialogListingProps {
|
||||||
hotels: HotelResponse[]
|
hotels: HotelResponse[]
|
||||||
|
unfilteredHotelCount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SelectHotelMapContainerProps = {
|
export type SelectHotelMapContainerProps = {
|
||||||
|
|||||||
Reference in New Issue
Block a user