diff --git a/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts b/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts index 2a3145ba4..04d35fa7e 100644 --- a/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts +++ b/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts @@ -205,7 +205,6 @@ export const destinationOverviewPageQueryRouter = router({ lang, countries: countryNames, serviceToken: ctx.serviceToken, - onlyPublished: true, }) const cityPages = await getCityPageUrls(lang) diff --git a/apps/scandic-web/server/routers/hotels/output.ts b/apps/scandic-web/server/routers/hotels/output.ts index bc466d5f2..ea7090fcb 100644 --- a/apps/scandic-web/server/routers/hotels/output.ts +++ b/apps/scandic-web/server/routers/hotels/output.ts @@ -566,6 +566,7 @@ export const getHotelIdsSchema = z z.object({ attributes: z.object({ isPublished: z.boolean(), + isActive: z.boolean(), }), id: z.string(), }) @@ -573,7 +574,7 @@ export const getHotelIdsSchema = z }) .transform(({ data }) => { const filteredHotels = data.filter( - (hotel) => !!hotel.attributes.isPublished + (hotel) => !!hotel.attributes.isPublished && !!hotel.attributes.isActive ) return filteredHotels.map((hotel) => hotel.id) }) @@ -582,12 +583,20 @@ export const getNearbyHotelIdsSchema = z .object({ data: z.array( z.object({ - // We only care about the hotel id + attributes: z.object({ + isPublished: z.boolean(), + isActive: z.boolean(), + }), id: z.string(), }) ), }) - .transform((data) => data.data.map((hotel) => hotel.id)) + .transform(({ data }) => { + const filteredHotels = data.filter( + (hotel) => !!hotel.attributes.isPublished && !!hotel.attributes.isActive + ) + return filteredHotels.map((hotel) => hotel.id) + }) export const roomFeaturesSchema = z .object({ diff --git a/apps/scandic-web/server/routers/hotels/utils.ts b/apps/scandic-web/server/routers/hotels/utils.ts index b7a6d329d..99f5c4594 100644 --- a/apps/scandic-web/server/routers/hotels/utils.ts +++ b/apps/scandic-web/server/routers/hotels/utils.ts @@ -178,13 +178,11 @@ export async function getCountries({ export async function getCitiesByCountry({ countries, lang, - onlyPublished = false, affix = locationsAffix, serviceToken, }: { countries: string[] lang: Lang - onlyPublished?: boolean // false by default as it might be used in other places affix?: string serviceToken: string }): Promise { @@ -218,7 +216,6 @@ export async function getCitiesByCountry({ console.error(citiesByCountry.error) throw new Error(`Unable to parse cities by country ${country}`) } - return { ...citiesByCountry.data, country } }, "1d" @@ -228,9 +225,7 @@ export async function getCitiesByCountry({ const filteredCitiesByCountries = allCitiesByCountries.map((country) => ({ ...country, - data: onlyPublished - ? country.data.filter((city) => city.isPublished) - : country.data, + data: country.data.filter((city) => city.isPublished), })) const groupedCitiesByCountry: CitiesGroupedByCountry =