fix(SW-1830): Adjusted schemas for city and country pages to accept less data
* fix(SW-1830): Adjusted schemas for city and country pages to accept less data Approved-by: Fredrik Thorsson Approved-by: Matilda Landström
This commit is contained in:
@@ -51,7 +51,9 @@ export default async function DestinationCityPage() {
|
||||
<div className={styles.pageContainer}>
|
||||
<header className={styles.header}>
|
||||
<Breadcrumbs variant={PageContentTypeEnum.destinationCityPage} />
|
||||
<TopImages images={images} destinationName={city.name} />
|
||||
{images?.length && (
|
||||
<TopImages images={images} destinationName={city.name} />
|
||||
)}
|
||||
</header>
|
||||
<main className={styles.mainContent}>
|
||||
<HotelListing />
|
||||
@@ -61,7 +63,7 @@ export default async function DestinationCityPage() {
|
||||
<SidebarContentWrapper location={city.name}>
|
||||
<Body color="uiTextMediumContrast">{preamble}</Body>
|
||||
<ExperienceList experiences={experiences} />
|
||||
{has_sidepeek && (
|
||||
{has_sidepeek && sidepeek_content && (
|
||||
<DestinationPageSidePeek
|
||||
buttonText={sidepeek_button_text}
|
||||
sidePeekContent={sidepeek_content}
|
||||
|
||||
@@ -55,7 +55,12 @@ export default async function DestinationCountryPage() {
|
||||
variant={PageContentTypeEnum.destinationCityPage}
|
||||
/>
|
||||
</Suspense>
|
||||
<TopImages images={images} destinationName={translatedCountry} />
|
||||
{images?.length && (
|
||||
<TopImages
|
||||
images={images}
|
||||
destinationName={translatedCountry}
|
||||
/>
|
||||
)}
|
||||
</header>
|
||||
<main className={styles.mainContent}>
|
||||
<CityListing />
|
||||
@@ -65,7 +70,7 @@ export default async function DestinationCountryPage() {
|
||||
<SidebarContentWrapper location={translatedCountry}>
|
||||
<Body color="uiTextMediumContrast">{preamble}</Body>
|
||||
<ExperienceList experiences={experiences} />
|
||||
{has_sidepeek && (
|
||||
{has_sidepeek && sidepeek_content && (
|
||||
<DestinationPageSidePeek
|
||||
buttonText={sidepeek_button_text}
|
||||
sidePeekContent={sidepeek_content}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { ChevronRightSmallIcon } from "@/components/Icons"
|
||||
import JsonToHtml from "@/components/JsonToHtml"
|
||||
@@ -12,7 +13,7 @@ import type { DestinationCityPageData } from "@/types/trpc/routers/contentstack/
|
||||
import type { DestinationCountryPageData } from "@/types/trpc/routers/contentstack/destinationCountryPage"
|
||||
|
||||
interface DestinationPageSidepeekProps {
|
||||
buttonText: string
|
||||
buttonText?: string | null
|
||||
sidePeekContent: NonNullable<
|
||||
| DestinationCityPageData["sidepeek_content"]
|
||||
| DestinationCountryPageData["sidepeek_content"]
|
||||
@@ -24,6 +25,7 @@ export default function DestinationPageSidepeek({
|
||||
sidePeekContent,
|
||||
location,
|
||||
}: DestinationPageSidepeekProps) {
|
||||
const intl = useIntl()
|
||||
const [sidePeekIsOpen, setSidePeekIsOpen] = useState(false)
|
||||
const { heading, content } = sidePeekContent
|
||||
|
||||
@@ -42,7 +44,7 @@ export default function DestinationPageSidepeek({
|
||||
size="small"
|
||||
wrapping
|
||||
>
|
||||
{buttonText}
|
||||
{buttonText || intl.formatMessage({ id: "Read more" })}
|
||||
<ChevronRightSmallIcon />
|
||||
</Button>
|
||||
<SidePeek
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function TopImages({ images, destinationName }: TopImageProps) {
|
||||
open: false,
|
||||
activeIndex: 0,
|
||||
})
|
||||
const lightboxImages = mapImageVaultImagesToGalleryImages(images || [])
|
||||
const lightboxImages = mapImageVaultImagesToGalleryImages(images)
|
||||
const maxWidth = 1366 // 1366px is the max width of the image container
|
||||
const visibleImages = images.slice(0, 3)
|
||||
|
||||
|
||||
@@ -125,35 +125,39 @@ export const destinationCityPageSchema = z.object({
|
||||
.object({
|
||||
destination_experiences: z.array(z.string()),
|
||||
})
|
||||
.transform(({ destination_experiences }) => destination_experiences),
|
||||
.nullish()
|
||||
.transform((experiences) => experiences?.destination_experiences ?? []),
|
||||
images: z
|
||||
.array(z.object({ image: tempImageVaultAssetSchema }))
|
||||
.transform((images) =>
|
||||
images
|
||||
.map((image) => image.image)
|
||||
.filter((image): image is ImageVaultAsset => !!image)
|
||||
),
|
||||
)
|
||||
.nullish(),
|
||||
has_sidepeek: z.boolean().default(false),
|
||||
sidepeek_button_text: z.string().default(""),
|
||||
sidepeek_content: z.object({
|
||||
heading: z.string(),
|
||||
content: z.object({
|
||||
json: z.any(),
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: linkUnionSchema.transform((data) => {
|
||||
const link = transformPageLink(data)
|
||||
if (link) {
|
||||
return link
|
||||
}
|
||||
return data
|
||||
}),
|
||||
})
|
||||
),
|
||||
sidepeek_button_text: z.string().nullish().default(""),
|
||||
sidepeek_content: z
|
||||
.object({
|
||||
heading: z.string(),
|
||||
content: z.object({
|
||||
json: z.any(),
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: linkUnionSchema.transform((data) => {
|
||||
const link = transformPageLink(data)
|
||||
if (link) {
|
||||
return link
|
||||
}
|
||||
return data
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
.nullish(),
|
||||
blocks: discriminatedUnionArray(blocksSchema.options).nullable(),
|
||||
system: systemSchema.merge(
|
||||
z.object({
|
||||
@@ -228,17 +232,19 @@ const blocksRefsSchema = z.discriminatedUnion("__typename", [
|
||||
|
||||
export const destinationCityPageRefsSchema = z.object({
|
||||
destination_city_page: z.object({
|
||||
sidepeek_content: z.object({
|
||||
content: z.object({
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: linkRefsUnionSchema,
|
||||
})
|
||||
),
|
||||
sidepeek_content: z
|
||||
.object({
|
||||
content: z.object({
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: linkRefsUnionSchema,
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
.nullish(),
|
||||
blocks: discriminatedUnionArray(blocksRefsSchema.options).nullable(),
|
||||
system: systemSchema,
|
||||
}),
|
||||
|
||||
@@ -63,28 +63,31 @@ export const destinationCountryPageSchema = z.object({
|
||||
images
|
||||
.map((image) => image.image)
|
||||
.filter((image): image is ImageVaultAsset => !!image)
|
||||
),
|
||||
)
|
||||
.nullish(),
|
||||
has_sidepeek: z.boolean().default(false),
|
||||
sidepeek_button_text: z.string().default(""),
|
||||
sidepeek_content: z.object({
|
||||
heading: z.string(),
|
||||
content: z.object({
|
||||
json: z.any(),
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: linkUnionSchema.transform((data) => {
|
||||
const link = transformPageLink(data)
|
||||
if (link) {
|
||||
return link
|
||||
}
|
||||
return data
|
||||
}),
|
||||
})
|
||||
),
|
||||
sidepeek_button_text: z.string().nullish(),
|
||||
sidepeek_content: z
|
||||
.object({
|
||||
heading: z.string(),
|
||||
content: z.object({
|
||||
json: z.any(),
|
||||
embedded_itemsConnection: z.object({
|
||||
edges: z.array(
|
||||
z.object({
|
||||
node: linkUnionSchema.transform((data) => {
|
||||
const link = transformPageLink(data)
|
||||
if (link) {
|
||||
return link
|
||||
}
|
||||
return data
|
||||
}),
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
.nullish(),
|
||||
blocks: discriminatedUnionArray(blocksSchema.options).nullable(),
|
||||
system: systemSchema.merge(
|
||||
z.object({
|
||||
|
||||
Reference in New Issue
Block a user