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:
@@ -16,7 +16,6 @@ import { cache } from "@/utils/cache"
|
||||
|
||||
import { getHotelPageUrl } from "../contentstack/hotelPage/utils"
|
||||
import { getVerifiedUser, parsedUser } from "../user/query"
|
||||
import { additionalDataSchema } from "./schemas/additionalData"
|
||||
import {
|
||||
getAdditionalDataInputSchema,
|
||||
getBreakfastPackageInputSchema,
|
||||
@@ -43,6 +42,7 @@ import {
|
||||
getRoomPackagesSchema,
|
||||
getRoomsAvailabilitySchema,
|
||||
} from "./output"
|
||||
import { additionalDataSchema } from "./schemas/additionalData"
|
||||
import {
|
||||
additionalDataCounter,
|
||||
additionalDataFailCounter,
|
||||
@@ -1132,9 +1132,9 @@ export const hotelQueryRouter = router({
|
||||
if (!countries) {
|
||||
return null
|
||||
}
|
||||
|
||||
const countryNames = countries.data.map((country) => country.name)
|
||||
const citiesByCountry = await getCitiesByCountry(
|
||||
countries,
|
||||
countryNames,
|
||||
options,
|
||||
searchParams,
|
||||
ctx.lang
|
||||
|
||||
@@ -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),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user