import { z } from "zod"

import { nullableStringValidator } from "@/utils/zod/stringValidator"

export const pageSettingsSchema = z.object({
  hide_booking_widget: z.boolean(),
  booking_code: nullableStringValidator,
})

export type PageSettingsSchema = z.output<typeof pageSettingsSchema>
const DEFAULT_PAGE_SETTINGS: PageSettingsSchema = {
  hide_booking_widget: false,
  booking_code: "",
} as const

export const getPageSettingsSchema = z.object({
  page: z.object({
    settings: pageSettingsSchema
      .nullable()
      .optional()
      .transform((val) => val ?? DEFAULT_PAGE_SETTINGS),
  }),
})

export type GetPageSettingsSchema = z.output<typeof getPageSettingsSchema>
export const DEFAULT_GET_PAGE_SETTINGS: GetPageSettingsSchema = {
  page: {
    settings: DEFAULT_PAGE_SETTINGS,
  },
}
