import { z } from "zod" import { nullableArrayObjectValidator } from "@/utils/zod/arrayValidator" import { nullableStringValidator } from "@/utils/zod/stringValidator" import { displayWebPageSchema } from "./additionalData/displayWebPage" import { facilitySchema } from "./additionalData/facility" import { gallerySchema } from "./additionalData/gallery" import { restaurantsOverviewPageSchema } from "./additionalData/restaurantsOverviewPage" import { specialNeedGroupSchema } from "./additionalData/specialNeedGroups" export const extraPageSchema = z.object({ elevatorPitch: nullableStringValidator, mainBody: nullableStringValidator, nameInUrl: nullableStringValidator, }) export const additionalDataSchema = z.object({ attributes: z.object({ accessibility: facilitySchema.nullish(), conferencesAndMeetings: facilitySchema.nullish(), displayWebPage: displayWebPageSchema, gallery: gallerySchema.nullish(), healthAndFitness: extraPageSchema, healthAndWellness: facilitySchema.nullish(), hotelParking: extraPageSchema, hotelRoomElevatorPitchText: nullableStringValidator, hotelSpecialNeeds: extraPageSchema, id: nullableStringValidator, meetingRooms: extraPageSchema, name: nullableStringValidator, parkingImages: facilitySchema.nullish(), restaurantImages: facilitySchema.nullish(), restaurantsOverviewPage: restaurantsOverviewPageSchema, specialNeedGroups: nullableArrayObjectValidator(specialNeedGroupSchema), }), type: z.literal("additionalData"), }) export function transformAdditionalData( data: z.output ) { return { ...data.attributes, id: data.attributes.id, type: data.type, } }