fix(SW-1386): transform full width campaign data
This commit is contained in:
@@ -14,48 +14,44 @@ interface FullWidthCampaignProps {
|
||||
}
|
||||
|
||||
export default function FullWidthCampaign({ content }: FullWidthCampaignProps) {
|
||||
return content.full_width_campaignConnection.edges.map(({ node }) => (
|
||||
<div key={node.system.uid} className={styles.container}>
|
||||
{node.background_image ? (
|
||||
const { background_image, primary_button, secondary_button } = content
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
{background_image ? (
|
||||
<Image
|
||||
className={styles.image}
|
||||
alt={
|
||||
node.background_image.meta.alt ||
|
||||
node.background_image.meta.caption ||
|
||||
""
|
||||
}
|
||||
src={node.background_image.url}
|
||||
focalPoint={node.background_image.focalPoint}
|
||||
alt={background_image.meta.alt || background_image.meta.caption || ""}
|
||||
src={background_image.url}
|
||||
focalPoint={background_image.focalPoint}
|
||||
width={1512}
|
||||
height={880}
|
||||
/>
|
||||
) : null}
|
||||
<div className={styles.content}>
|
||||
<BiroScript color="baseText" type="two">
|
||||
{node.scripted_top_title}
|
||||
{content.scripted_top_title}
|
||||
</BiroScript>
|
||||
<div className={styles.mainContent}>
|
||||
<Title color="baseText" textAlign="center" level="h3">
|
||||
{node.heading}
|
||||
{content.heading}
|
||||
</Title>
|
||||
<Preamble color="baseText" textAlign="center">
|
||||
{node.body_text}
|
||||
{content.body_text}
|
||||
</Preamble>
|
||||
<div className={styles.buttons}>
|
||||
{node.has_primary_button ? (
|
||||
{content.has_primary_button ? (
|
||||
<Button intent="inverted" size="small" theme="base" asChild>
|
||||
<Link
|
||||
href={node.primary_button.href}
|
||||
target={
|
||||
node.primary_button.openInNewTab ? "_blank" : undefined
|
||||
}
|
||||
href={primary_button.href}
|
||||
target={primary_button.openInNewTab ? "_blank" : undefined}
|
||||
color="none"
|
||||
>
|
||||
{node.primary_button.title}
|
||||
{primary_button.title}
|
||||
</Link>
|
||||
</Button>
|
||||
) : null}
|
||||
{node.has_secondary_button ? (
|
||||
{content.has_secondary_button ? (
|
||||
<Button
|
||||
intent="secondary"
|
||||
size="small"
|
||||
@@ -63,13 +59,11 @@ export default function FullWidthCampaign({ content }: FullWidthCampaignProps) {
|
||||
asChild
|
||||
>
|
||||
<Link
|
||||
href={node.secondary_button.href}
|
||||
target={
|
||||
node.secondary_button.openInNewTab ? "_blank" : undefined
|
||||
}
|
||||
href={secondary_button.href}
|
||||
target={secondary_button.openInNewTab ? "_blank" : undefined}
|
||||
color="none"
|
||||
>
|
||||
{node.secondary_button.title}
|
||||
{secondary_button.title}
|
||||
</Link>
|
||||
</Button>
|
||||
) : null}
|
||||
@@ -77,5 +71,5 @@ export default function FullWidthCampaign({ content }: FullWidthCampaignProps) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -9,25 +9,29 @@ import { buttonSchema } from "./utils/buttonLinkSchema"
|
||||
import { BlocksEnums } from "@/types/enums/blocks"
|
||||
|
||||
export const fullWidthCampaignSchema = z.object({
|
||||
full_width_campaign: z.object({
|
||||
full_width_campaignConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
background_image: tempImageVaultAssetSchema,
|
||||
heading: z.string().optional(),
|
||||
body_text: z.string().optional(),
|
||||
scripted_top_title: z.string().optional(),
|
||||
has_primary_button: z.boolean().default(false),
|
||||
primary_button: buttonSchema,
|
||||
has_secondary_button: z.boolean().default(false),
|
||||
secondary_button: buttonSchema,
|
||||
system: systemSchema,
|
||||
}),
|
||||
})
|
||||
),
|
||||
full_width_campaign: z
|
||||
.object({
|
||||
full_width_campaignConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: z.object({
|
||||
background_image: tempImageVaultAssetSchema,
|
||||
heading: z.string().optional(),
|
||||
body_text: z.string().optional(),
|
||||
scripted_top_title: z.string().optional(),
|
||||
has_primary_button: z.boolean().default(false),
|
||||
primary_button: buttonSchema,
|
||||
has_secondary_button: z.boolean().default(false),
|
||||
secondary_button: buttonSchema,
|
||||
system: systemSchema,
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
return data.full_width_campaignConnection.edges[0]?.node || null
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
export const fullWidthCampaignBlockSchema = z
|
||||
|
||||
Reference in New Issue
Block a user