Merged in fix/teaser-card-issue (pull request #2459)

fix(SW-3120): update teaser card validation

* fix: update teaser card validation


Approved-by: Michael Zetterberg
Approved-by: Linus Flood
This commit is contained in:
Matilda Landström
2025-06-27 13:27:35 +00:00
parent fe75018a46
commit 2b5573059c
2 changed files with 38 additions and 34 deletions

View File

@@ -39,10 +39,12 @@ export default function TeaserCardSidepeek({
handleClose={() => setSidePeekIsOpen(false)} handleClose={() => setSidePeekIsOpen(false)}
openInRoot openInRoot
> >
<JsonToHtml {content ? (
nodes={content.json.children} <JsonToHtml
embeds={content.embedded_itemsConnection.edges} nodes={content.json.children}
/> embeds={content.embedded_itemsConnection.edges}
/>
) : null}
<div className={styles.ctaContainer}> <div className={styles.ctaContainer}>
{primary_button && ( {primary_button && (
<ButtonLink <ButtonLink

View File

@@ -38,36 +38,38 @@ export const teaserCardBlockSchema = z.object({
sidepeek_content: z sidepeek_content: z
.object({ .object({
heading: z.string(), heading: z.string(),
content: z.object({ content: z
json: z.any(), .object({
embedded_itemsConnection: z.object({ json: z.any(),
edges: z.array( embedded_itemsConnection: z.object({
z.object({ edges: z.array(
node: z z.object({
.discriminatedUnion("__typename", [ node: z
imageContainerSchema, .discriminatedUnion("__typename", [
sysAssetSchema, imageContainerSchema,
accountPageSchema, sysAssetSchema,
collectionPageSchema, accountPageSchema,
contentPageSchema, collectionPageSchema,
destinationCityPageSchema, contentPageSchema,
destinationCountryPageSchema, destinationCityPageSchema,
destinationOverviewPageSchema, destinationCountryPageSchema,
hotelPageSchema, destinationOverviewPageSchema,
loyaltyPageSchema, hotelPageSchema,
startPageSchema, loyaltyPageSchema,
]) startPageSchema,
.transform((data) => { ])
const link = transformPageLink(data) .transform((data) => {
if (link) { const link = transformPageLink(data)
return link if (link) {
} return link
return data }
}), return data
}) }),
), })
}), ),
}), }),
})
.nullish(),
has_primary_button: z.boolean().default(false), has_primary_button: z.boolean().default(false),
primary_button: buttonSchema, primary_button: buttonSchema,
has_secondary_button: z.boolean().default(false), has_secondary_button: z.boolean().default(false),