fix: Trimming hotel ids from contentstack to avoid 404 errors when fetching hotel data

Approved-by: Linus Flood
Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2025-09-12 09:18:50 +00:00
parent 15a352ea99
commit ce71fc421c
5 changed files with 20 additions and 16 deletions

View File

@@ -6,13 +6,13 @@ import { Country } from "../../../../types/country"
export const locationFilterSchema = z
.object({
country: z.nativeEnum(Country).nullable(),
city_denmark: z.string().optional().nullable(),
city_finland: z.string().optional().nullable(),
city_germany: z.string().optional().nullable(),
city_poland: z.string().optional().nullable(),
city_norway: z.string().optional().nullable(),
city_sweden: z.string().optional().nullable(),
excluded: z.array(z.string()),
city_denmark: z.string().nullish(),
city_finland: z.string().nullish(),
city_germany: z.string().nullish(),
city_poland: z.string().nullish(),
city_norway: z.string().nullish(),
city_sweden: z.string().nullish(),
excluded: z.array(z.string().transform((id) => id.trim())),
})
.transform((data) => {
const cities = [
@@ -46,7 +46,7 @@ export const contentPageHotelListingSchema = z.object({
location_filter: locationFilterSchema,
manual_filter: z
.object({
hotels: z.array(z.string()),
hotels: z.array(z.string().transform((id) => id.trim())),
})
.transform((data) => ({ hotels: data.hotels.filter(Boolean) })),
content_type: z.enum(["hotel", "restaurant", "meeting"]),
@@ -82,7 +82,7 @@ export const campaignOverviewPageHotelListingSchema = z.object({
edges: z.array(
z.object({
node: z.object({
hotel_page_id: z.string(),
hotel_page_id: z.string().transform((id) => id.trim()),
}),
})
),