diff --git a/apps/scandic-web/server/routers/autocomplete/destinations.ts b/apps/scandic-web/server/routers/autocomplete/destinations.ts index 5cc3c8117..0020cdf98 100644 --- a/apps/scandic-web/server/routers/autocomplete/destinations.ts +++ b/apps/scandic-web/server/routers/autocomplete/destinations.ts @@ -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 diff --git a/apps/scandic-web/server/routers/hotels/output.ts b/apps/scandic-web/server/routers/hotels/output.ts index af918adc3..6b424d5c1 100644 --- a/apps/scandic-web/server/routers/hotels/output.ts +++ b/apps/scandic-web/server/routers/hotels/output.ts @@ -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) }) diff --git a/apps/scandic-web/server/routers/hotels/schemas/location/city.ts b/apps/scandic-web/server/routers/hotels/schemas/location/city.ts index 0f55a6f99..fe524fe16 100644 --- a/apps/scandic-web/server/routers/hotels/schemas/location/city.ts +++ b/apps/scandic-web/server/routers/hotels/schemas/location/city.ts @@ -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(""),