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 type HotelPageRaw = HotelPageDataRaw["hotel_page"] export type HotelPage = HotelPageRaw export type ActivityCard = z.infer export type ContentBlockItem = z.infer