fix(SW-3084): Handle unpublished entries inside content pages
Approved-by: Matilda Landström
This commit is contained in:
@@ -44,6 +44,10 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case SidebarEnums.blocks.ScriptedCard:
|
case SidebarEnums.blocks.ScriptedCard:
|
||||||
|
if (!block.scripted_card) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={block.scripted_card.system.uid}
|
key={block.scripted_card.system.uid}
|
||||||
@@ -57,6 +61,10 @@ export default function Sidebar({ blocks }: SidebarProps) {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
case SidebarEnums.blocks.TeaserCard:
|
case SidebarEnums.blocks.TeaserCard:
|
||||||
|
if (!block.teaser_card) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TeaserCard
|
<TeaserCard
|
||||||
title={block.teaser_card.heading}
|
title={block.teaser_card.heading}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { CardsEnum } from "../../../../../types/cardsEnum"
|
|||||||
import { tempImageVaultAssetSchema } from "../../imageVault"
|
import { tempImageVaultAssetSchema } from "../../imageVault"
|
||||||
import {
|
import {
|
||||||
accountPageSchema,
|
accountPageSchema,
|
||||||
|
campaignOverviewPageSchema,
|
||||||
|
campaignPageSchema,
|
||||||
collectionPageSchema,
|
collectionPageSchema,
|
||||||
contentPageSchema,
|
contentPageSchema,
|
||||||
destinationCityPageSchema,
|
destinationCityPageSchema,
|
||||||
@@ -49,6 +51,8 @@ export const teaserCardBlockSchema = z.object({
|
|||||||
imageContainerSchema,
|
imageContainerSchema,
|
||||||
sysAssetSchema,
|
sysAssetSchema,
|
||||||
accountPageSchema,
|
accountPageSchema,
|
||||||
|
campaignOverviewPageSchema,
|
||||||
|
campaignPageSchema,
|
||||||
collectionPageSchema,
|
collectionPageSchema,
|
||||||
contentPageSchema,
|
contentPageSchema,
|
||||||
destinationCityPageSchema,
|
destinationCityPageSchema,
|
||||||
|
|||||||
@@ -3,15 +3,8 @@ import { z } from "zod"
|
|||||||
import { BlocksEnums } from "../../../../types/blocksEnum"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { ContentEnum } from "../../../../types/content"
|
import { ContentEnum } from "../../../../types/content"
|
||||||
import {
|
import {
|
||||||
accountPageSchema,
|
linkRefsUnionSchema,
|
||||||
collectionPageSchema,
|
linkUnionSchema,
|
||||||
contentPageSchema,
|
|
||||||
destinationCityPageSchema,
|
|
||||||
destinationCountryPageSchema,
|
|
||||||
destinationOverviewPageSchema,
|
|
||||||
hotelPageSchema,
|
|
||||||
loyaltyPageSchema,
|
|
||||||
startPageSchema,
|
|
||||||
transformPageLink,
|
transformPageLink,
|
||||||
} from "../pageLinks"
|
} from "../pageLinks"
|
||||||
import {
|
import {
|
||||||
@@ -36,15 +29,7 @@ export const contentSchema = z.object({
|
|||||||
.discriminatedUnion("__typename", [
|
.discriminatedUnion("__typename", [
|
||||||
imageContainerSchema,
|
imageContainerSchema,
|
||||||
sysAssetSchema,
|
sysAssetSchema,
|
||||||
accountPageSchema,
|
...linkUnionSchema.options,
|
||||||
collectionPageSchema,
|
|
||||||
contentPageSchema,
|
|
||||||
destinationCityPageSchema,
|
|
||||||
destinationCountryPageSchema,
|
|
||||||
destinationOverviewPageSchema,
|
|
||||||
hotelPageSchema,
|
|
||||||
loyaltyPageSchema,
|
|
||||||
startPageSchema,
|
|
||||||
])
|
])
|
||||||
.transform((data) => {
|
.transform((data) => {
|
||||||
const link = transformPageLink(data)
|
const link = transformPageLink(data)
|
||||||
@@ -73,15 +58,7 @@ export const contentRefsSchema = z.object({
|
|||||||
node: z.discriminatedUnion("__typename", [
|
node: z.discriminatedUnion("__typename", [
|
||||||
sysAssetRefsSchema,
|
sysAssetRefsSchema,
|
||||||
imageContainerRefsSchema,
|
imageContainerRefsSchema,
|
||||||
accountPageSchema,
|
...linkRefsUnionSchema.options,
|
||||||
collectionPageSchema,
|
|
||||||
contentPageSchema,
|
|
||||||
destinationCityPageSchema,
|
|
||||||
destinationCountryPageSchema,
|
|
||||||
destinationOverviewPageSchema,
|
|
||||||
hotelPageSchema,
|
|
||||||
loyaltyPageSchema,
|
|
||||||
startPageSchema,
|
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ export const scriptedCardsSchema = z.object({
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
.nullish()
|
||||||
.transform((data) => {
|
.transform((data) => {
|
||||||
|
if (!data?.scripted_cardConnection?.edges.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
theme: data.theme,
|
theme: data.theme,
|
||||||
...transformCardBlock(data.scripted_cardConnection.edges[0].node),
|
...transformCardBlock(data.scripted_cardConnection.edges[0].node),
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ export const teaserCardsSchema = z.object({
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
.nullish()
|
||||||
.transform((data) => {
|
.transform((data) => {
|
||||||
|
if (!data?.teaser_cardConnection?.edges.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...transformTeaserCardBlock(data.teaser_cardConnection.edges[0].node),
|
...transformTeaserCardBlock(data.teaser_cardConnection.edges[0].node),
|
||||||
theme: data.theme,
|
theme: data.theme,
|
||||||
|
|||||||
Reference in New Issue
Block a user