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:
Erik Tiekstra
2025-02-12 13:02:19 +00:00
parent 019a5db549
commit 1532898c23
10 changed files with 106 additions and 88 deletions

View File

@@ -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({