Merged in fix/remove-cities-without-hotels (pull request #1493)
fix: remove cities that don't have a city page * fix: remove cities that don't have a city page Approved-by: Erik Tiekstra
This commit is contained in:
@@ -34,7 +34,10 @@ import {
|
||||
getDestinationOverviewPageSuccessCounter,
|
||||
} from "./telemetry"
|
||||
|
||||
import type { DestinationsData } from "@/types/components/destinationOverviewPage/destinationsList/destinationsData"
|
||||
import type {
|
||||
Cities,
|
||||
DestinationsData,
|
||||
} from "@/types/components/destinationOverviewPage/destinationsList/destinationsData"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
type TrackingSDKPageData,
|
||||
@@ -258,16 +261,25 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
(cityPage) => cityPage.city === city.cityIdentifier
|
||||
)
|
||||
|
||||
if (!cityPage) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
id: city.id,
|
||||
name: city.name,
|
||||
hotelIds: hotels,
|
||||
hotelCount: hotels?.length ?? 0,
|
||||
url: cityPage?.url,
|
||||
url: cityPage.url,
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
const activeCitiesWithHotelCount: Cities =
|
||||
citiesWithHotelCount.filter(
|
||||
(city): city is Cities[number] => !!city
|
||||
)
|
||||
|
||||
const countryPage = countryPages.find(
|
||||
(countryPage) => countryPage.country === country
|
||||
)
|
||||
@@ -275,11 +287,11 @@ export const destinationOverviewPageQueryRouter = router({
|
||||
return {
|
||||
country,
|
||||
countryUrl: countryPage?.url,
|
||||
numberOfHotels: citiesWithHotelCount.reduce(
|
||||
numberOfHotels: activeCitiesWithHotelCount.reduce(
|
||||
(acc, city) => acc + city.hotelCount,
|
||||
0
|
||||
),
|
||||
cities: citiesWithHotelCount,
|
||||
cities: activeCitiesWithHotelCount,
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -5,12 +5,14 @@ export type DestinationsData = {
|
||||
cities: {
|
||||
id: string
|
||||
name: string
|
||||
hotelIds: string[] | null
|
||||
hotelIds: string[]
|
||||
hotelCount: number
|
||||
url: string | undefined
|
||||
url: string
|
||||
}[]
|
||||
}[]
|
||||
|
||||
export type Cities = DestinationsData[number]["cities"]
|
||||
|
||||
export type HotelsSectionProps = {
|
||||
destinations: DestinationsData
|
||||
}
|
||||
@@ -23,5 +25,5 @@ export type DestinationProps = {
|
||||
country: string
|
||||
countryUrl: string | undefined
|
||||
numberOfHotels: number
|
||||
cities: DestinationsData[number]["cities"]
|
||||
cities: Cities
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user