58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import {
|
|
linkAndTitleSchema,
|
|
linkConnectionRefs,
|
|
} from "@/server/routers/contentstack/schemas/linkConnection"
|
|
|
|
import { systemSchema } from "../schemas/system"
|
|
|
|
const navigationLinksSchema = z
|
|
.array(linkAndTitleSchema)
|
|
.nullable()
|
|
.transform((data) => {
|
|
if (!data) {
|
|
return null
|
|
}
|
|
|
|
return data
|
|
.filter((item) => !!item.link)
|
|
.map((item) => ({
|
|
url: item.link!.url,
|
|
title: item.title || item.link!.title,
|
|
}))
|
|
})
|
|
|
|
export const campaignOverviewPageSchema = z.object({
|
|
campaign_overview_page: z.object({
|
|
title: z.string(),
|
|
header: z.object({
|
|
heading: z.string(),
|
|
preamble: z.string(),
|
|
navigation_links: navigationLinksSchema,
|
|
}),
|
|
system: systemSchema.merge(
|
|
z.object({
|
|
created_at: z.string(),
|
|
updated_at: z.string(),
|
|
})
|
|
),
|
|
}),
|
|
trackingProps: z.object({
|
|
url: z.string(),
|
|
}),
|
|
})
|
|
|
|
/** REFS */
|
|
|
|
const campaignOverviewPageHeaderRefs = z.object({
|
|
navigation_links: z.array(linkConnectionRefs),
|
|
})
|
|
|
|
export const campaignOverviewPageRefsSchema = z.object({
|
|
campaign_overview_page: z.object({
|
|
header: campaignOverviewPageHeaderRefs,
|
|
system: systemSchema,
|
|
}),
|
|
})
|