fix(2547): filter inActive hotels from booking widget
This commit is contained in:
committed by
Michael Zetterberg
parent
6a2bb5ac2d
commit
5f38a92b74
@@ -71,6 +71,13 @@ export const getDestinationsAutoCompleteRoute = safeProtectedServiceProcedure
|
||||
citiesByCountry: citiesByCountry,
|
||||
})
|
||||
|
||||
const activeLocations = locations.filter((location) => {
|
||||
return (
|
||||
location.type === "cities" ||
|
||||
(location.type === "hotels" && location.isActive)
|
||||
)
|
||||
})
|
||||
|
||||
const [hotelUrls, hotelUrlsError] = await hotelUrlsPromise
|
||||
const [cityUrls, cityUrlsError] = await cityUrlsPromise
|
||||
const [countryUrls, countryUrlsError] = await countryUrlsPromise
|
||||
@@ -86,7 +93,7 @@ export const getDestinationsAutoCompleteRoute = safeProtectedServiceProcedure
|
||||
throw new Error("Unable to fetch location URLs")
|
||||
}
|
||||
|
||||
const hotelsAndCities = locations
|
||||
const hotelsAndCities = activeLocations
|
||||
.map((location) => {
|
||||
let url: string | undefined
|
||||
|
||||
|
||||
@@ -478,8 +478,7 @@ export const locationsSchema = z.object({
|
||||
)
|
||||
.transform((data) =>
|
||||
data
|
||||
.filter((node) => !!node)
|
||||
.filter((node) => !!node.isPublished)
|
||||
.filter((node) => !!node && node.isPublished)
|
||||
.filter((node) => {
|
||||
if (node.type === "hotels") {
|
||||
if (!node.operaId) {
|
||||
@@ -574,9 +573,7 @@ export const getHotelIdsSchema = z
|
||||
),
|
||||
})
|
||||
.transform(({ data }) => {
|
||||
const filteredHotels = data.filter(
|
||||
(hotel) => !!hotel.attributes.isPublished && !!hotel.attributes.isActive
|
||||
)
|
||||
const filteredHotels = data.filter((hotel) => hotel.attributes.isPublished)
|
||||
return filteredHotels.map((hotel) => hotel.id)
|
||||
})
|
||||
|
||||
@@ -594,7 +591,7 @@ export const getNearbyHotelIdsSchema = z
|
||||
})
|
||||
.transform(({ data }) => {
|
||||
const filteredHotels = data.filter(
|
||||
(hotel) => !!hotel.attributes.isPublished && !!hotel.attributes.isActive
|
||||
(hotel) => hotel.attributes.isPublished && hotel.attributes.isActive
|
||||
)
|
||||
return filteredHotels.map((hotel) => hotel.id)
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ export const locationCitySchema = z.object({
|
||||
cityIdentifier: z.string().optional(),
|
||||
keyWords: z.array(z.string()).optional(),
|
||||
name: z.string().optional().default(""),
|
||||
isPublished: z.boolean().default(false),
|
||||
isPublished: z.boolean(),
|
||||
}),
|
||||
country: z.string().optional().default(""),
|
||||
id: z.string().optional().default(""),
|
||||
|
||||
Reference in New Issue
Block a user