Refactor site header, heroes, and design system
This commit is contained in:
+55
-17
@@ -25,23 +25,61 @@ export const categoryInputSchema = z.object({
|
||||
isActive: z.boolean(),
|
||||
});
|
||||
|
||||
export const sectionInputSchema = z.object({
|
||||
id: z.string().trim().optional(),
|
||||
type: z.nativeEnum(PortfolioSectionType),
|
||||
titleAr: requiredText("Section titleAr"),
|
||||
titleEn: requiredText("Section titleEn"),
|
||||
titleDe: requiredText("Section titleDe"),
|
||||
bodyAr: requiredText("Section bodyAr"),
|
||||
bodyEn: requiredText("Section bodyEn"),
|
||||
bodyDe: requiredText("Section bodyDe"),
|
||||
imagePath: optionalTrimmedText,
|
||||
media: mediaFieldInputSchema.optional(),
|
||||
linkUrl: optionalTrimmedText.refine(
|
||||
(value) => value === "" || /^https?:\/\//.test(value) || value.startsWith("/"),
|
||||
"Section linkUrl must be an absolute URL or start with /.",
|
||||
),
|
||||
sortOrder: z.coerce.number().int().min(0).max(9999),
|
||||
});
|
||||
export const sectionInputSchema = z
|
||||
.object({
|
||||
id: z.string().trim().optional(),
|
||||
type: z.nativeEnum(PortfolioSectionType),
|
||||
titleAr: requiredText("Section titleAr"),
|
||||
titleEn: requiredText("Section titleEn"),
|
||||
titleDe: requiredText("Section titleDe"),
|
||||
bodyAr: optionalTrimmedText,
|
||||
bodyEn: optionalTrimmedText,
|
||||
bodyDe: optionalTrimmedText,
|
||||
imagePath: optionalTrimmedText,
|
||||
media: mediaFieldInputSchema.optional(),
|
||||
linkUrl: optionalTrimmedText.refine(
|
||||
(value) => value === "" || /^https?:\/\//.test(value) || value.startsWith("/"),
|
||||
"Section linkUrl must be an absolute URL or start with /.",
|
||||
),
|
||||
sortOrder: z.coerce.number().int().min(0).max(9999),
|
||||
})
|
||||
.superRefine((value, context) => {
|
||||
const hasBody = Boolean(value.bodyAr && value.bodyEn && value.bodyDe);
|
||||
const hasImage = value.media?.mode === "library"
|
||||
? Boolean(value.media.assetId)
|
||||
: value.media?.mode === "upload"
|
||||
? true
|
||||
: Boolean(value.imagePath);
|
||||
|
||||
if (
|
||||
(value.type === PortfolioSectionType.RICH_TEXT ||
|
||||
value.type === PortfolioSectionType.STATS ||
|
||||
value.type === PortfolioSectionType.DELIVERABLES) &&
|
||||
!hasBody
|
||||
) {
|
||||
context.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["bodyAr"],
|
||||
message: "This section type requires body content in all languages.",
|
||||
});
|
||||
}
|
||||
|
||||
if (value.type === PortfolioSectionType.GALLERY && !hasImage) {
|
||||
context.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["media"],
|
||||
message: "Single image sections require an image.",
|
||||
});
|
||||
}
|
||||
|
||||
if (value.type === PortfolioSectionType.LINK && !value.linkUrl) {
|
||||
context.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["linkUrl"],
|
||||
message: "Link sections require a link URL.",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const assetInputSchema = z.object({
|
||||
id: z.string().trim().optional(),
|
||||
|
||||
Reference in New Issue
Block a user