Merged in feat/SW-1457-city-dynamic-map (pull request #1320)
feat(SW-1457): Added map and fetching hotels by cityIdentifier * feat(SW-1457): Added map and fetching hotels by cityIdentifier Approved-by: Fredrik Thorsson Approved-by: Matilda Landström
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
breakfastPackageInputSchema,
|
||||
cityCoordinatesInputSchema,
|
||||
getAdditionalDataInputSchema,
|
||||
getHotelsByCityIdentifierInput,
|
||||
getHotelsByCountryInput,
|
||||
getHotelsByCSFilterInput,
|
||||
getHotelsByHotelIdsAvailabilityInputSchema,
|
||||
@@ -51,7 +52,9 @@ import {
|
||||
getCitiesByCountry,
|
||||
getCountries,
|
||||
getHotelIdsByCityId,
|
||||
getHotelIdsByCityIdentifier,
|
||||
getHotelIdsByCountry,
|
||||
getHotelsByHotelIds,
|
||||
getLocations,
|
||||
} from "./utils"
|
||||
|
||||
@@ -861,21 +864,22 @@ export const hotelQueryRouter = router({
|
||||
hotelIdsParams
|
||||
)
|
||||
|
||||
const hotels = await Promise.all(
|
||||
hotelIds.map(async (hotelId) => {
|
||||
const [hotelData, url] = await Promise.all([
|
||||
getHotel(
|
||||
{ hotelId, isCardOnlyPayment: false, language: lang },
|
||||
ctx.serviceToken
|
||||
),
|
||||
getHotelPageUrl(lang, hotelId),
|
||||
])
|
||||
return await getHotelsByHotelIds(hotelIds, lang, serviceToken)
|
||||
}),
|
||||
}),
|
||||
byCityIdentifier: router({
|
||||
get: contentStackBaseWithServiceProcedure
|
||||
.input(getHotelsByCityIdentifierInput)
|
||||
.query(async ({ ctx, input }) => {
|
||||
const { lang, serviceToken } = ctx
|
||||
const { cityIdentifier } = input
|
||||
|
||||
return hotelData ? { ...hotelData, url } : null
|
||||
})
|
||||
const hotelIds = await getHotelIdsByCityIdentifier(
|
||||
cityIdentifier,
|
||||
serviceToken
|
||||
)
|
||||
|
||||
return hotels.filter((hotel): hotel is HotelDataWithUrl => !!hotel)
|
||||
return await getHotelsByHotelIds(hotelIds, lang, serviceToken)
|
||||
}),
|
||||
}),
|
||||
byCSFilter: router({
|
||||
|
||||
Reference in New Issue
Block a user