x
This commit is contained in:
1 parent
c1c3a43d7d
commit
a5f6e3171b
11 files changed
+351
-13
No files matched your search
@@ -277,4 +277,88 @@ export interface CustomerAddress {
|
||||
updatedAt?: string
|
||||
}
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
export const HeroArticlePayloadSchema = z.object({
|
||||
title: z.string().min(1, "Title is required"),
|
||||
subtitle: z.string().optional(),
|
||||
author: z.string().optional(),
|
||||
publishDate: z.string().optional(), // Or z.date() if preferred, but string works for ISO dates
|
||||
backgroundImageUrl: z.string().url("Must be a valid URL").optional(),
|
||||
overlayColor: z.string().optional(),
|
||||
});
|
||||
export type HeroArticlePayload = z.infer<typeof HeroArticlePayloadSchema>;
|
||||
|
||||
export const RichTextPayloadSchema = z.object({
|
||||
content: z.string().min(1, "Content is required"),
|
||||
});
|
||||
export type RichTextPayload = z.infer<typeof RichTextPayloadSchema>;
|
||||
|
||||
export const ScentNotesBreakdownPayloadSchema = z.object({
|
||||
title: z.string().optional(),
|
||||
topNotes: z.array(z.string()),
|
||||
middleNotes: z.array(z.string()),
|
||||
baseNotes: z.array(z.string()),
|
||||
});
|
||||
export type ScentNotesBreakdownPayload = z.infer<typeof ScentNotesBreakdownPayloadSchema>;
|
||||
|
||||
export const QuoteCalloutPayloadSchema = z.object({
|
||||
quote: z.string().min(1, "Quote is required"),
|
||||
author: z.string().optional(),
|
||||
});
|
||||
export type QuoteCalloutPayload = z.infer<typeof QuoteCalloutPayloadSchema>;
|
||||
|
||||
export const ProductCarouselPayloadSchema = z.object({
|
||||
title: z.string().optional(),
|
||||
collectionId: z.string().optional(),
|
||||
limit: z.number().int().positive().optional(),
|
||||
showPrice: z.boolean().optional(),
|
||||
showAddToCart: z.boolean().optional(),
|
||||
});
|
||||
export type ProductCarouselPayload = z.infer<typeof ProductCarouselPayloadSchema>;
|
||||
|
||||
export const ScentGuideSectionSchema = z.discriminatedUnion("type", [
|
||||
z.object({
|
||||
id: z.string().or(z.number()),
|
||||
type: z.literal("hero_article"),
|
||||
order: z.number(),
|
||||
payload: HeroArticlePayloadSchema,
|
||||
}),
|
||||
z.object({
|
||||
id: z.string().or(z.number()),
|
||||
type: z.literal("rich_text"),
|
||||
order: z.number(),
|
||||
payload: RichTextPayloadSchema,
|
||||
}),
|
||||
z.object({
|
||||
id: z.string().or(z.number()),
|
||||
type: z.literal("scent_notes_breakdown"),
|
||||
order: z.number(),
|
||||
payload: ScentNotesBreakdownPayloadSchema,
|
||||
}),
|
||||
z.object({
|
||||
id: z.string().or(z.number()),
|
||||
type: z.literal("quote_callout"),
|
||||
order: z.number(),
|
||||
payload: QuoteCalloutPayloadSchema,
|
||||
}),
|
||||
z.object({
|
||||
id: z.string().or(z.number()),
|
||||
type: z.literal("product_carousel"),
|
||||
order: z.number(),
|
||||
payload: ProductCarouselPayloadSchema,
|
||||
}),
|
||||
]);
|
||||
|
||||
export const ScentGuidePageSchema = z.object({
|
||||
pageId: z.string().or(z.number()),
|
||||
title: z.string(),
|
||||
slug: z.string(),
|
||||
status: z.string().optional(),
|
||||
metadata: z.object({
|
||||
seoTitle: z.string().optional(),
|
||||
seoDescription: z.string().optional(),
|
||||
}).optional(),
|
||||
sections: z.array(ScentGuideSectionSchema),
|
||||
});
|
||||
export type ScentGuidePage = z.infer<typeof ScentGuidePageSchema>;
|
||||
Reference in new issue
Block a user