Feat/SW-2271 hotel list filtering

* feat(SW-2271): Changes to hotel data types in preperation for filtering
* feat(SW-2271): Added filter and sort functionality

Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-07-04 09:27:20 +00:00
parent 82e21af0d4
commit fa7214cb58
58 changed files with 1572 additions and 450 deletions

View File

@@ -53,19 +53,17 @@ import { getVerifiedUser } from "../user/utils"
import { additionalDataSchema } from "./schemas/hotel/include/additionalData"
import { meetingRoomsSchema } from "./schemas/meetingRoom"
import {
getBedTypes,
getCitiesByCountry,
getCountries,
getHotel,
getHotelIdsByCityId,
getHotelIdsByCityIdentifier,
getHotelIdsByCountry,
getHotelsByHotelIds,
getLocations,
} from "./utils"
import {
getBedTypes,
getHotelsAvailabilityByCity,
getHotelsAvailabilityByHotelIds,
getHotelsByHotelIds,
getLocations,
getPackages,
getRoomsAvailability,
getSelectedRoomAvailability,
@@ -73,10 +71,7 @@ import {
selectRateRedirectURL,
} from "./utils"
import type {
DestinationPagesHotelData,
HotelDataWithUrl,
} from "../../types/hotel"
import type { HotelListingHotelData } from "../../types/hotel"
import type { CityLocation } from "../../types/locations"
import type { Room } from "../../types/room"
@@ -570,7 +565,7 @@ export const hotelQueryRouter = router({
get: contentStackBaseWithServiceProcedure
.input(getHotelsByCSFilterInput)
.query(async function ({ ctx, input }) {
const { locationFilter, hotelsToInclude } = input
const { locationFilter, hotelsToInclude, contentType } = input
const language = ctx.lang
let hotelsToFetch: string[] = []
@@ -669,29 +664,16 @@ export const hotelQueryRouter = router({
return []
}
const hotelPages = await getHotelPageUrls(language)
const hotels = await Promise.all(
hotelsToFetch.map(async (hotelId) => {
const hotelData = await getHotel(
{ hotelId, isCardOnlyPayment: false, language },
ctx.serviceToken
)
const hotelPage = hotelPages.find(
(page) => page.hotelId === hotelId
)
return hotelData
? {
...hotelData,
url: hotelPage?.url ?? null,
}
: null
})
)
const hotels = await getHotelsByHotelIds({
hotelIds: hotelsToFetch,
lang: language,
serviceToken: ctx.serviceToken,
contentType,
})
metricsGetHotelsByCSFilter.success()
return hotels.filter((hotel): hotel is HotelDataWithUrl => !!hotel)
return hotels
}),
}),
getDestinationsMapData: serviceProcedure
@@ -713,7 +695,7 @@ export const hotelQueryRouter = router({
}
const countryNames = countries.data.map((country) => country.name)
const hotelData: DestinationPagesHotelData[] = (
const hotelData: HotelListingHotelData[] = (
await Promise.all(
countryNames.map(async (country) => {
const hotelIds = await getHotelIdsByCountry({