Files
web/server/routers/contentstack/hotelPage/output.ts
2024-09-10 16:10:01 +02:00

65 lines
1.6 KiB
TypeScript

import { z } from "zod"
import { HotelBlocksTypenameEnum } from "@/types/components/hotelPage/enums"
export const activityCardSchema = z.object({
background_image: z.any(),
cta_text: z.string(),
heading: z.string(),
open_in_new_tab: z.boolean(),
scripted_title: z.string().optional(),
body_text: z.string(),
hotel_page_activities_content_pageConnection: z.object({
edges: z.array(
z.object({
node: z.object({
url: z.string(),
web: z.object({
original_url: z.string().optional(),
}),
system: z.object({
locale: z.string(),
}),
}),
})
),
}),
})
const contentBlockActivity = z.object({
__typename: z.literal(
HotelBlocksTypenameEnum.HotelPageContentUpcomingActivitiesCard
),
upcoming_activities_card: activityCardSchema,
})
const contentBlockItem = z.discriminatedUnion("__typename", [
contentBlockActivity,
])
export const validateHotelPageSchema = z.object({
hotel_page: z.object({
hotel_page_id: z.string(),
title: z.string(),
url: z.string(),
content: z.array(contentBlockItem).nullable(),
}),
})
export const hotelPageSchema = z.object({
hotel_page: z.object({
hotel_page_id: z.string(),
title: z.string(),
url: z.string(),
}),
})
// Will be extended once we introduce more functionality to our entries.
export type HotelPageDataRaw = z.infer<typeof validateHotelPageSchema>
type HotelPageRaw = HotelPageDataRaw["hotel_page"]
export type HotelPage = HotelPageRaw
export type ActivityCard = z.infer<typeof activityCardSchema>
export type ContentBlockItem = z.infer<typeof contentBlockItem>