fix(2547): filter inActive hotels from booking widget

This commit is contained in:
Matilda Landström
2025-05-06 11:21:42 +02:00
committed by Michael Zetterberg
parent 6a2bb5ac2d
commit 5f38a92b74
3 changed files with 12 additions and 8 deletions

View File

@@ -71,6 +71,13 @@ export const getDestinationsAutoCompleteRoute = safeProtectedServiceProcedure
citiesByCountry: citiesByCountry, citiesByCountry: citiesByCountry,
}) })
const activeLocations = locations.filter((location) => {
return (
location.type === "cities" ||
(location.type === "hotels" && location.isActive)
)
})
const [hotelUrls, hotelUrlsError] = await hotelUrlsPromise const [hotelUrls, hotelUrlsError] = await hotelUrlsPromise
const [cityUrls, cityUrlsError] = await cityUrlsPromise const [cityUrls, cityUrlsError] = await cityUrlsPromise
const [countryUrls, countryUrlsError] = await countryUrlsPromise const [countryUrls, countryUrlsError] = await countryUrlsPromise
@@ -86,7 +93,7 @@ export const getDestinationsAutoCompleteRoute = safeProtectedServiceProcedure
throw new Error("Unable to fetch location URLs") throw new Error("Unable to fetch location URLs")
} }
const hotelsAndCities = locations const hotelsAndCities = activeLocations
.map((location) => { .map((location) => {
let url: string | undefined let url: string | undefined

View File

@@ -478,8 +478,7 @@ export const locationsSchema = z.object({
) )
.transform((data) => .transform((data) =>
data data
.filter((node) => !!node) .filter((node) => !!node && node.isPublished)
.filter((node) => !!node.isPublished)
.filter((node) => { .filter((node) => {
if (node.type === "hotels") { if (node.type === "hotels") {
if (!node.operaId) { if (!node.operaId) {
@@ -574,9 +573,7 @@ export const getHotelIdsSchema = z
), ),
}) })
.transform(({ data }) => { .transform(({ data }) => {
const filteredHotels = data.filter( const filteredHotels = data.filter((hotel) => hotel.attributes.isPublished)
(hotel) => !!hotel.attributes.isPublished && !!hotel.attributes.isActive
)
return filteredHotels.map((hotel) => hotel.id) return filteredHotels.map((hotel) => hotel.id)
}) })
@@ -594,7 +591,7 @@ export const getNearbyHotelIdsSchema = z
}) })
.transform(({ data }) => { .transform(({ data }) => {
const filteredHotels = data.filter( const filteredHotels = data.filter(
(hotel) => !!hotel.attributes.isPublished && !!hotel.attributes.isActive (hotel) => hotel.attributes.isPublished && hotel.attributes.isActive
) )
return filteredHotels.map((hotel) => hotel.id) return filteredHotels.map((hotel) => hotel.id)
}) })

View File

@@ -5,7 +5,7 @@ export const locationCitySchema = z.object({
cityIdentifier: z.string().optional(), cityIdentifier: z.string().optional(),
keyWords: z.array(z.string()).optional(), keyWords: z.array(z.string()).optional(),
name: z.string().optional().default(""), name: z.string().optional().default(""),
isPublished: z.boolean().default(false), isPublished: z.boolean(),
}), }),
country: z.string().optional().default(""), country: z.string().optional().default(""),
id: z.string().optional().default(""), id: z.string().optional().default(""),