Merged in feat/SW-1453-city-listing-on-country-page (pull request #1222)

feat(SW-1453): added city listing component

* feat(SW-1453): added city listing component


Approved-by: Christian Andolf
Approved-by: Fredrik Thorsson
This commit is contained in:
Erik Tiekstra
2025-01-29 10:09:51 +00:00
parent a7468cd958
commit ca42876eb8
25 changed files with 496 additions and 57 deletions
+8 -8
View File
@@ -9,7 +9,6 @@ import {
apiCountriesSchema,
apiLocationsSchema,
type CitiesGroupedByCountry,
type Countries,
getHotelIdsByCityIdSchema,
} from "./output"
import {
@@ -124,22 +123,23 @@ export async function getCountries(
}
export async function getCitiesByCountry(
countries: Countries,
countries: string[],
options: RequestOptionsWithOutBody,
params: URLSearchParams,
lang: Lang
lang: Lang,
affix: string = locationsAffix
) {
return unstable_cache(
async function (
searchParams: URLSearchParams,
searchedCountries: Countries
searchedCountries: string[]
) {
const citiesGroupedByCountry: CitiesGroupedByCountry = {}
await Promise.all(
searchedCountries.data.map(async (country) => {
searchedCountries.map(async (country) => {
const countryResponse = await api.get(
api.endpoints.v1.Hotel.Cities.country(country.name),
api.endpoints.v1.Hotel.Cities.country(country),
options,
searchParams
)
@@ -157,7 +157,7 @@ export async function getCitiesByCountry(
return null
}
citiesGroupedByCountry[country.name] = citiesByCountry.data.data
citiesGroupedByCountry[country] = citiesByCountry.data.data
return true
})
)
@@ -165,7 +165,7 @@ export async function getCitiesByCountry(
return citiesGroupedByCountry
},
[
`${lang}:${locationsAffix}:cities-by-country`,
`${lang}:${affix}:cities-by-country`,
params.toString(),
JSON.stringify(countries),
],