Skip to content

Commit

Permalink
add correct strapi props in preparation for CMS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer6497 committed Dec 27, 2024
1 parent ae6b80b commit 9eca2dd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/services/cms/models/StrapiBoxWithImage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { z } from "zod";
import { type BoxWithImageProps } from "~/components/BoxWithImage";
import {
variantWidths,
type Variant,
type BoxWithImageProps,
} from "~/components/BoxWithImage";
import { omitNull } from "~/util/omitNull";
import { HasOptionalStrapiIdSchema } from "./HasStrapiId";
import { OptionalStrapiLinkIdentifierSchema } from "./HasStrapiLinkIdentifier";
Expand All @@ -8,13 +12,18 @@ import { StrapiContainerSchema } from "./StrapiContainer";
import { getHeadingProps, StrapiHeadingSchema } from "./StrapiHeading";
import { StrapiImageSchema, getImageProps } from "./StrapiImage";

// Necessary destructuring for zod enum type
const [firstWidth, ...widths] = Object.keys(variantWidths).map(
(key) => key as Variant,
);

const StrapiBoxWithImageSchema = z
.object({
heading: StrapiHeadingSchema.nullable(),
image: StrapiImageSchema,
content: z.string().nullable(),
outerBackground: StrapiBackgroundSchema.nullable(),
variant: z.enum(["ImgMTextL"]).nullable(),
variant: z.enum([firstWidth, ...widths]).nullable(),
container: StrapiContainerSchema,
})
.merge(HasOptionalStrapiIdSchema)
Expand Down

0 comments on commit 9eca2dd

Please sign in to comment.