Merged in feat/SW-2220-destination-list (pull request #1851)

Feat/SW-2220 destination list

* fix(SW-2220): remove old hotels

* fix(SW-2220): add filtering of cities without urls

* fix(SW-2220): destinations English

* fix(SW-2220): update all country files

* refactor(SW-2220): cleanup


Approved-by: Michael Zetterberg
Approved-by: Erik Tiekstra
This commit is contained in:
Matilda Landström
2025-04-25 13:14:23 +00:00
parent 035653349a
commit 1f8594e5c8
9 changed files with 4082 additions and 4819 deletions

View File

@@ -34,7 +34,7 @@ import {
} from "./output"
import type {
Cities,
City,
DestinationsData,
} from "@/types/components/destinationOverviewPage/destinationsList/destinationsData"
import {
@@ -212,28 +212,33 @@ export const destinationOverviewPageQueryRouter = router({
const destinations = await Promise.all(
Object.entries(citiesByCountry).map(async ([country, cities]) => {
const activeCitiesWithHotelCount: Cities = await Promise.all(
cities.map(async (city) => {
const [hotels] = await safeTry(
getHotelIdsByCityId({
cityId: city.id,
serviceToken: ctx.serviceToken,
})
)
const activeCitiesWithHotelCount: (City | null)[] =
await Promise.all(
cities.map(async (city) => {
const [hotels] = await safeTry(
getHotelIdsByCityId({
cityId: city.id,
serviceToken: ctx.serviceToken,
})
)
const cityPage = cityPages.find(
(cityPage) => cityPage.city === city.cityIdentifier
)
const cityPage = cityPages.find(
(cityPage) => cityPage.city === city.cityIdentifier
)
return {
id: city.id,
name: city.name,
hotelIds: hotels || [],
hotelCount: hotels ? hotels.length : 0,
url: cityPage?.url,
}
})
)
return cityPage?.url
? {
id: city.id,
name: city.name,
hotelIds: hotels || [],
hotelCount: hotels ? hotels.length : 0,
url: cityPage.url,
}
: null
})
)
const filteredActiveCitiesWithHotelCount: City[] =
activeCitiesWithHotelCount.filter((c): c is City => !!c)
const countryPages = await getCountryPageUrls(lang)
const countryPage = countryPages.find(
@@ -243,11 +248,11 @@ export const destinationOverviewPageQueryRouter = router({
return {
country,
countryUrl: countryPage?.url,
numberOfHotels: activeCitiesWithHotelCount.reduce(
numberOfHotels: filteredActiveCitiesWithHotelCount.reduce(
(acc, city) => acc + city.hotelCount,
0
),
cities: activeCitiesWithHotelCount,
cities: filteredActiveCitiesWithHotelCount,
}
})
)