Merged in feat/SW-1584-destination-content-blocks (pull request #1278)
Feat/SW-1584 destination content blocks * feat(SW-1584): Added accordion and content blocks to destination city pages * feat(SW-1584): Added accordion and content blocks to destination country pages Approved-by: Matilda Landström
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
grid-template-areas:
|
||||
"header"
|
||||
"sidebar"
|
||||
"mainSection";
|
||||
"mainContent";
|
||||
width: 100%;
|
||||
gap: var(--Spacing-x4);
|
||||
}
|
||||
@@ -13,8 +13,10 @@
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
.mainSection {
|
||||
grid-area: mainSection;
|
||||
.mainContent {
|
||||
grid-area: mainContent;
|
||||
display: grid;
|
||||
gap: var(--Spacing-x6);
|
||||
padding-bottom: var(--Spacing-x7);
|
||||
max-width: var(--max-width-page);
|
||||
width: 100%;
|
||||
@@ -47,7 +49,11 @@
|
||||
.pageContainer {
|
||||
grid-template-areas:
|
||||
"header sidebar"
|
||||
"mainSection sidebar";
|
||||
"mainContent sidebar";
|
||||
grid-template-columns: 1fr var(--map-desktop-width);
|
||||
}
|
||||
|
||||
.mainContent {
|
||||
gap: var(--Spacing-x9);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Suspense } from "react"
|
||||
|
||||
import { getDestinationCityPage } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import Blocks from "@/components/Blocks"
|
||||
import Breadcrumbs from "@/components/Breadcrumbs"
|
||||
import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
@@ -28,6 +29,7 @@ export default async function DestinationCityPage() {
|
||||
|
||||
const { tracking, destinationCityPage, hotels } = pageData
|
||||
const {
|
||||
blocks,
|
||||
images,
|
||||
heading,
|
||||
preamble,
|
||||
@@ -51,8 +53,10 @@ export default async function DestinationCityPage() {
|
||||
destinationName={destination_settings.city}
|
||||
/>
|
||||
</header>
|
||||
<main className={styles.mainSection}>
|
||||
<main className={styles.mainContent}>
|
||||
<HotelListing hotels={hotels} />
|
||||
|
||||
{blocks && <Blocks blocks={blocks} />}
|
||||
</main>
|
||||
<aside className={styles.sidebar}>
|
||||
<SidebarContentWrapper>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
grid-template-areas:
|
||||
"header"
|
||||
"sidebar"
|
||||
"mainSection";
|
||||
"mainContent";
|
||||
width: 100%;
|
||||
gap: var(--Spacing-x4);
|
||||
}
|
||||
@@ -13,10 +13,14 @@
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
.mainSection {
|
||||
grid-area: mainSection;
|
||||
.mainContent {
|
||||
grid-area: mainContent;
|
||||
display: grid;
|
||||
gap: var(--Spacing-x6);
|
||||
padding-bottom: var(--Spacing-x7);
|
||||
max-width: var(--max-width-page);
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
@@ -45,7 +49,11 @@
|
||||
.pageContainer {
|
||||
grid-template-areas:
|
||||
"header sidebar"
|
||||
"mainSection sidebar";
|
||||
"mainContent sidebar";
|
||||
grid-template-columns: 1fr var(--map-desktop-width);
|
||||
}
|
||||
|
||||
.mainContent {
|
||||
gap: var(--Spacing-x9);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Suspense } from "react"
|
||||
|
||||
import { getDestinationCountryPage } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import Blocks from "@/components/Blocks"
|
||||
import Breadcrumbs from "@/components/Breadcrumbs"
|
||||
import BreadcrumbsSkeleton from "@/components/TempDesignSystem/Breadcrumbs/BreadcrumbsSkeleton"
|
||||
import Body from "@/components/TempDesignSystem/Text/Body"
|
||||
@@ -35,6 +36,7 @@ export default async function DestinationCountryPage() {
|
||||
const { tracking, destinationCountryPage, cities, translatedCountry } =
|
||||
pageData
|
||||
const {
|
||||
blocks,
|
||||
images,
|
||||
heading,
|
||||
preamble,
|
||||
@@ -54,8 +56,9 @@ export default async function DestinationCountryPage() {
|
||||
</Suspense>
|
||||
<TopImages images={images} destinationName={translatedCountry} />
|
||||
</header>
|
||||
<main className={styles.mainSection}>
|
||||
<main className={styles.mainContent}>
|
||||
<CityListing cities={cities} />
|
||||
{blocks && <Blocks blocks={blocks} />}
|
||||
</main>
|
||||
<aside className={styles.sidebar}>
|
||||
<SidebarContentWrapper>
|
||||
|
||||
@@ -79,13 +79,13 @@ fragment Accordion_ContentPage on ContentPageBlocksAccordion {
|
||||
title
|
||||
accordions {
|
||||
__typename
|
||||
...GlobalAccordion
|
||||
...SpecificAccordion
|
||||
...GlobalAccordion_ContentPage
|
||||
...SpecificAccordion_ContentPage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment GlobalAccordion on ContentPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
fragment GlobalAccordion_ContentPage on ContentPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
__typename
|
||||
global_accordion {
|
||||
global_accordionConnection {
|
||||
@@ -98,7 +98,7 @@ fragment GlobalAccordion on ContentPageBlocksAccordionBlockAccordionsGlobalAccor
|
||||
}
|
||||
}
|
||||
|
||||
fragment SpecificAccordion on ContentPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
fragment SpecificAccordion_ContentPage on ContentPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
__typename
|
||||
specific_accordion {
|
||||
questions {
|
||||
@@ -130,13 +130,13 @@ fragment Accordion_ContentPageRefs on ContentPageBlocksAccordion {
|
||||
accordion {
|
||||
accordions {
|
||||
__typename
|
||||
...GlobalAccordionRefs
|
||||
...SpecificAccordionRefs
|
||||
...GlobalAccordion_ContentPageRefs
|
||||
...SpecificAccordion_ContentPageRefs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment GlobalAccordionRefs on ContentPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
fragment GlobalAccordion_ContentPageRefs on ContentPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
global_accordion {
|
||||
global_accordionConnection {
|
||||
edges {
|
||||
@@ -148,7 +148,207 @@ fragment GlobalAccordionRefs on ContentPageBlocksAccordionBlockAccordionsGlobalA
|
||||
}
|
||||
}
|
||||
|
||||
fragment SpecificAccordionRefs on ContentPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
fragment SpecificAccordion_ContentPageRefs on ContentPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
specific_accordion {
|
||||
questions {
|
||||
answer {
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageRef
|
||||
...CollectionPageRef
|
||||
...ContentPageRef
|
||||
...DestinationCityPageRef
|
||||
...DestinationCountryPageRef
|
||||
...DestinationOverviewPageRef
|
||||
...HotelPageRef
|
||||
...LoyaltyPageRef
|
||||
...StartPageRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Accordion_DestinationCityPage on DestinationCityPageBlocksAccordion {
|
||||
__typename
|
||||
accordion {
|
||||
title
|
||||
accordions {
|
||||
__typename
|
||||
...GlobalAccordion_DestinationCityPage
|
||||
...SpecificAccordion_DestinationCityPage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment GlobalAccordion_DestinationCityPage on DestinationCityPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
__typename
|
||||
global_accordion {
|
||||
global_accordionConnection {
|
||||
edges {
|
||||
node {
|
||||
...AccordionBlock
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment SpecificAccordion_DestinationCityPage on DestinationCityPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
__typename
|
||||
specific_accordion {
|
||||
questions {
|
||||
question
|
||||
answer {
|
||||
json
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageLink
|
||||
...CollectionPageLink
|
||||
...ContentPageLink
|
||||
...DestinationCityPageLink
|
||||
...DestinationCountryPageLink
|
||||
...DestinationOverviewPageLink
|
||||
...HotelPageLink
|
||||
...LoyaltyPageLink
|
||||
...StartPageLink
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Accordion_DestinationCityPageRefs on DestinationCityPageBlocksAccordion {
|
||||
accordion {
|
||||
accordions {
|
||||
__typename
|
||||
...GlobalAccordion_DestinationCityPageRefs
|
||||
...SpecificAccordion_DestinationCityPageRefs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment GlobalAccordion_DestinationCityPageRefs on DestinationCityPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
global_accordion {
|
||||
global_accordionConnection {
|
||||
edges {
|
||||
node {
|
||||
...AccordionBlockRefs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment SpecificAccordion_DestinationCityPageRefs on DestinationCityPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
specific_accordion {
|
||||
questions {
|
||||
answer {
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageRef
|
||||
...CollectionPageRef
|
||||
...ContentPageRef
|
||||
...DestinationCityPageRef
|
||||
...DestinationCountryPageRef
|
||||
...DestinationOverviewPageRef
|
||||
...HotelPageRef
|
||||
...LoyaltyPageRef
|
||||
...StartPageRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Accordion_DestinationCountryPage on DestinationCountryPageBlocksAccordion {
|
||||
__typename
|
||||
accordion {
|
||||
title
|
||||
accordions {
|
||||
__typename
|
||||
...GlobalAccordion_DestinationCountryPage
|
||||
...SpecificAccordion_DestinationCountryPage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment GlobalAccordion_DestinationCountryPage on DestinationCountryPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
__typename
|
||||
global_accordion {
|
||||
global_accordionConnection {
|
||||
edges {
|
||||
node {
|
||||
...AccordionBlock
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment SpecificAccordion_DestinationCountryPage on DestinationCountryPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
__typename
|
||||
specific_accordion {
|
||||
questions {
|
||||
question
|
||||
answer {
|
||||
json
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageLink
|
||||
...CollectionPageLink
|
||||
...ContentPageLink
|
||||
...DestinationCityPageLink
|
||||
...DestinationCountryPageLink
|
||||
...DestinationOverviewPageLink
|
||||
...HotelPageLink
|
||||
...LoyaltyPageLink
|
||||
...StartPageLink
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Accordion_DestinationCountryPageRefs on DestinationCountryPageBlocksAccordion {
|
||||
accordion {
|
||||
accordions {
|
||||
__typename
|
||||
...GlobalAccordion_DestinationCountryPageRefs
|
||||
...SpecificAccordion_DestinationCountryPageRefs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment GlobalAccordion_DestinationCountryPageRefs on DestinationCountryPageBlocksAccordionBlockAccordionsGlobalAccordion {
|
||||
global_accordion {
|
||||
global_accordionConnection {
|
||||
edges {
|
||||
node {
|
||||
...AccordionBlockRefs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment SpecificAccordion_DestinationCountryPageRefs on DestinationCountryPageBlocksAccordionBlockAccordionsSpecificAccordion {
|
||||
specific_accordion {
|
||||
questions {
|
||||
answer {
|
||||
|
||||
@@ -118,3 +118,97 @@ fragment Content_LoyaltyPageRefs on LoyaltyPageBlocksContent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Content_DestinationCityPage on DestinationCityPageBlocksContent {
|
||||
content {
|
||||
content {
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageLink
|
||||
...CollectionPageLink
|
||||
...ContentPageLink
|
||||
...DestinationCityPageLink
|
||||
...DestinationCountryPageLink
|
||||
...DestinationOverviewPageLink
|
||||
...HotelPageLink
|
||||
...LoyaltyPageLink
|
||||
...StartPageLink
|
||||
}
|
||||
}
|
||||
}
|
||||
json
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Content_DestinationCityPageRefs on DestinationCityPageBlocksContent {
|
||||
content {
|
||||
content {
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageRef
|
||||
...CollectionPageRef
|
||||
...ContentPageRef
|
||||
...DestinationCityPageRef
|
||||
...DestinationCountryPageRef
|
||||
...DestinationOverviewPageRef
|
||||
...HotelPageRef
|
||||
...LoyaltyPageRef
|
||||
...StartPageRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Content_DestinationCountryPage on DestinationCountryPageBlocksContent {
|
||||
content {
|
||||
content {
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageLink
|
||||
...CollectionPageLink
|
||||
...ContentPageLink
|
||||
...DestinationCityPageLink
|
||||
...DestinationCountryPageLink
|
||||
...DestinationOverviewPageLink
|
||||
...HotelPageLink
|
||||
...LoyaltyPageLink
|
||||
...StartPageLink
|
||||
}
|
||||
}
|
||||
}
|
||||
json
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment Content_DestinationCountryPageRefs on DestinationCountryPageBlocksContent {
|
||||
content {
|
||||
content {
|
||||
embedded_itemsConnection {
|
||||
edges {
|
||||
node {
|
||||
__typename
|
||||
...AccountPageRef
|
||||
...CollectionPageRef
|
||||
...ContentPageRef
|
||||
...DestinationCityPageRef
|
||||
...DestinationCountryPageRef
|
||||
...DestinationOverviewPageRef
|
||||
...HotelPageRef
|
||||
...LoyaltyPageRef
|
||||
...StartPageRef
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#import "../../Fragments/System.graphql"
|
||||
|
||||
#import "../../Fragments/Blocks/Accordion.graphql"
|
||||
#import "../../Fragments/Blocks/Content.graphql"
|
||||
|
||||
#import "../../Fragments/PageLink/AccountPageLink.graphql"
|
||||
#import "../../Fragments/PageLink/CollectionPageLink.graphql"
|
||||
#import "../../Fragments/PageLink/ContentPageLink.graphql"
|
||||
@@ -63,6 +66,11 @@ query GetDestinationCityPage($locale: String!, $uid: String!) {
|
||||
json
|
||||
}
|
||||
}
|
||||
blocks {
|
||||
__typename
|
||||
...Accordion_DestinationCityPage
|
||||
...Content_DestinationCityPage
|
||||
}
|
||||
system {
|
||||
...System
|
||||
created_at
|
||||
@@ -96,6 +104,11 @@ query GetDestinationCityPageRefs($locale: String!, $uid: String!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
blocks {
|
||||
__typename
|
||||
...Accordion_DestinationCityPageRefs
|
||||
...Content_DestinationCityPageRefs
|
||||
}
|
||||
system {
|
||||
...System
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#import "../../Fragments/System.graphql"
|
||||
|
||||
#import "../../Fragments/Blocks/Accordion.graphql"
|
||||
#import "../../Fragments/Blocks/Content.graphql"
|
||||
|
||||
#import "../../Fragments/PageLink/AccountPageLink.graphql"
|
||||
#import "../../Fragments/PageLink/CollectionPageLink.graphql"
|
||||
#import "../../Fragments/PageLink/ContentPageLink.graphql"
|
||||
@@ -58,6 +61,11 @@ query GetDestinationCountryPage($locale: String!, $uid: String!) {
|
||||
json
|
||||
}
|
||||
}
|
||||
blocks {
|
||||
__typename
|
||||
...Accordion_DestinationCountryPage
|
||||
...Content_DestinationCountryPage
|
||||
}
|
||||
system {
|
||||
...System
|
||||
created_at
|
||||
@@ -91,6 +99,11 @@ query GetDestinationCountryPageRefs($locale: String!, $uid: String!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
blocks {
|
||||
__typename
|
||||
...Accordion_DestinationCountryPageRefs
|
||||
...Content_DestinationCountryPageRefs
|
||||
}
|
||||
system {
|
||||
...System
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { discriminatedUnionArray } from "@/lib/discriminatedUnion"
|
||||
|
||||
import { removeMultipleSlashes } from "@/utils/url"
|
||||
|
||||
import {
|
||||
accordionRefsSchema,
|
||||
accordionSchema,
|
||||
} from "../schemas/blocks/accordion"
|
||||
import { contentRefsSchema, contentSchema } from "../schemas/blocks/content"
|
||||
import { tempImageVaultAssetSchema } from "../schemas/imageVault"
|
||||
import {
|
||||
linkRefsUnionSchema,
|
||||
@@ -15,6 +22,7 @@ import {
|
||||
TrackingChannelEnum,
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import { DestinationCityPageEnum } from "@/types/enums/destinationCityPage"
|
||||
|
||||
export const destinationCityListDataSchema = z
|
||||
.object({
|
||||
@@ -54,6 +62,25 @@ export const destinationCityListDataSchema = z
|
||||
({ all_destination_city_page }) => all_destination_city_page.items?.[0]
|
||||
)
|
||||
|
||||
export const destinationCityPageContent = z
|
||||
.object({
|
||||
__typename: z.literal(DestinationCityPageEnum.ContentStack.blocks.Content),
|
||||
})
|
||||
.merge(contentSchema)
|
||||
|
||||
export const destinationCityPageAccordion = z
|
||||
.object({
|
||||
__typename: z.literal(
|
||||
DestinationCityPageEnum.ContentStack.blocks.Accordion
|
||||
),
|
||||
})
|
||||
.merge(accordionSchema)
|
||||
|
||||
export const blocksSchema = z.discriminatedUnion("__typename", [
|
||||
destinationCityPageAccordion,
|
||||
destinationCityPageContent,
|
||||
])
|
||||
|
||||
export const destinationCityPageSchema = z
|
||||
.object({
|
||||
destination_city_page: z.object({
|
||||
@@ -123,6 +150,7 @@ export const destinationCityPageSchema = z
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
blocks: discriminatedUnionArray(blocksSchema.options).nullable(),
|
||||
system: systemSchema.merge(
|
||||
z.object({
|
||||
created_at: z.string(),
|
||||
@@ -158,6 +186,25 @@ export const destinationCityPageSchema = z
|
||||
})
|
||||
|
||||
/** REFS */
|
||||
const destinationCityPageContentRefs = z
|
||||
.object({
|
||||
__typename: z.literal(DestinationCityPageEnum.ContentStack.blocks.Content),
|
||||
})
|
||||
.merge(contentRefsSchema)
|
||||
|
||||
const destinationCityPageAccordionRefs = z
|
||||
.object({
|
||||
__typename: z.literal(
|
||||
DestinationCityPageEnum.ContentStack.blocks.Accordion
|
||||
),
|
||||
})
|
||||
.merge(accordionRefsSchema)
|
||||
|
||||
const blocksRefsSchema = z.discriminatedUnion("__typename", [
|
||||
destinationCityPageAccordionRefs,
|
||||
destinationCityPageContentRefs,
|
||||
])
|
||||
|
||||
export const destinationCityPageRefsSchema = z.object({
|
||||
destination_city_page: z.object({
|
||||
sidepeek_content: z.object({
|
||||
@@ -171,6 +218,7 @@ export const destinationCityPageRefsSchema = z.object({
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
blocks: discriminatedUnionArray(blocksRefsSchema.options).nullable(),
|
||||
system: systemSchema,
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -4,13 +4,14 @@ import { getHotel } from "../../hotels/query"
|
||||
import { getHotelIdsByCityIdentifier } from "../../hotels/utils"
|
||||
import { getHotelPageUrl } from "../hotelPage/utils"
|
||||
|
||||
import { DestinationCityPageEnum } from "@/types/enums/destinationCityPage"
|
||||
import type { HotelData } from "@/types/hotel"
|
||||
import type { System } from "@/types/requests/system"
|
||||
import type { GetDestinationCityPageRefsSchema } from "@/types/trpc/routers/contentstack/destinationCityPage"
|
||||
import type { DestinationCityPageRefs } from "@/types/trpc/routers/contentstack/destinationCityPage"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
export function generatePageTags(
|
||||
validatedData: GetDestinationCityPageRefsSchema,
|
||||
validatedData: DestinationCityPageRefs,
|
||||
lang: Lang
|
||||
): string[] {
|
||||
const connections = getConnections(validatedData)
|
||||
@@ -22,8 +23,29 @@ export function generatePageTags(
|
||||
|
||||
export function getConnections({
|
||||
destination_city_page,
|
||||
}: GetDestinationCityPageRefsSchema) {
|
||||
}: DestinationCityPageRefs) {
|
||||
const connections: System["system"][] = [destination_city_page.system]
|
||||
if (destination_city_page.blocks) {
|
||||
destination_city_page.blocks.forEach((block) => {
|
||||
switch (block.__typename) {
|
||||
case DestinationCityPageEnum.ContentStack.blocks.Accordion: {
|
||||
if (block.accordion.length) {
|
||||
connections.push(...block.accordion)
|
||||
}
|
||||
break
|
||||
}
|
||||
case DestinationCityPageEnum.ContentStack.blocks.Content:
|
||||
{
|
||||
if (block.content.length) {
|
||||
// TS has trouble infering the filtered types
|
||||
// @ts-ignore
|
||||
connections.push(...block.content)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
if (destination_city_page.sidepeek_content) {
|
||||
destination_city_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach(
|
||||
({ node }) => {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { discriminatedUnionArray } from "@/lib/discriminatedUnion"
|
||||
|
||||
import {
|
||||
accordionRefsSchema,
|
||||
accordionSchema,
|
||||
} from "../schemas/blocks/accordion"
|
||||
import { contentRefsSchema, contentSchema } from "../schemas/blocks/content"
|
||||
import { tempImageVaultAssetSchema } from "../schemas/imageVault"
|
||||
import {
|
||||
linkRefsUnionSchema,
|
||||
@@ -14,6 +21,28 @@ import {
|
||||
type TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import { Country } from "@/types/enums/country"
|
||||
import { DestinationCountryPageEnum } from "@/types/enums/destinationCountryPage"
|
||||
|
||||
export const destinationCountryPageContent = z
|
||||
.object({
|
||||
__typename: z.literal(
|
||||
DestinationCountryPageEnum.ContentStack.blocks.Content
|
||||
),
|
||||
})
|
||||
.merge(contentSchema)
|
||||
|
||||
export const destinationCountryPageAccordion = z
|
||||
.object({
|
||||
__typename: z.literal(
|
||||
DestinationCountryPageEnum.ContentStack.blocks.Accordion
|
||||
),
|
||||
})
|
||||
.merge(accordionSchema)
|
||||
|
||||
export const blocksSchema = z.discriminatedUnion("__typename", [
|
||||
destinationCountryPageAccordion,
|
||||
destinationCountryPageContent,
|
||||
])
|
||||
|
||||
export const destinationCountryPageSchema = z
|
||||
.object({
|
||||
@@ -57,6 +86,7 @@ export const destinationCountryPageSchema = z
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
blocks: discriminatedUnionArray(blocksSchema.options).nullable(),
|
||||
system: systemSchema.merge(
|
||||
z.object({
|
||||
created_at: z.string(),
|
||||
@@ -91,6 +121,26 @@ export const destinationCountryPageSchema = z
|
||||
})
|
||||
|
||||
/** REFS */
|
||||
const destinationCountryPageContentRefs = z
|
||||
.object({
|
||||
__typename: z.literal(
|
||||
DestinationCountryPageEnum.ContentStack.blocks.Content
|
||||
),
|
||||
})
|
||||
.merge(contentRefsSchema)
|
||||
|
||||
const destinationCountryPageAccordionRefs = z
|
||||
.object({
|
||||
__typename: z.literal(
|
||||
DestinationCountryPageEnum.ContentStack.blocks.Accordion
|
||||
),
|
||||
})
|
||||
.merge(accordionRefsSchema)
|
||||
|
||||
const blocksRefsSchema = z.discriminatedUnion("__typename", [
|
||||
destinationCountryPageAccordionRefs,
|
||||
destinationCountryPageContentRefs,
|
||||
])
|
||||
export const destinationCountryPageRefsSchema = z.object({
|
||||
destination_country_page: z.object({
|
||||
sidepeek_content: z.object({
|
||||
@@ -104,6 +154,7 @@ export const destinationCountryPageRefsSchema = z.object({
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
blocks: discriminatedUnionArray(blocksRefsSchema.options).nullable(),
|
||||
system: systemSchema,
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -14,14 +14,15 @@ import {
|
||||
} from "./telemetry"
|
||||
|
||||
import { ApiCountry, type Country } from "@/types/enums/country"
|
||||
import { DestinationCountryPageEnum } from "@/types/enums/destinationCountryPage"
|
||||
import type { RequestOptionsWithOutBody } from "@/types/fetch"
|
||||
import type { System } from "@/types/requests/system"
|
||||
import type { GetDestinationCityListDataResponse } from "@/types/trpc/routers/contentstack/destinationCityPage"
|
||||
import type { GetDestinationCountryPageRefsSchema } from "@/types/trpc/routers/contentstack/destinationCountryPage"
|
||||
import type { DestinationCountryPageRefs } from "@/types/trpc/routers/contentstack/destinationCountryPage"
|
||||
import type { Lang } from "@/constants/languages"
|
||||
|
||||
export function generatePageTags(
|
||||
validatedData: GetDestinationCountryPageRefsSchema,
|
||||
validatedData: DestinationCountryPageRefs,
|
||||
lang: Lang
|
||||
): string[] {
|
||||
const connections = getConnections(validatedData)
|
||||
@@ -33,9 +34,29 @@ export function generatePageTags(
|
||||
|
||||
export function getConnections({
|
||||
destination_country_page,
|
||||
}: GetDestinationCountryPageRefsSchema) {
|
||||
}: DestinationCountryPageRefs) {
|
||||
const connections: System["system"][] = [destination_country_page.system]
|
||||
|
||||
if (destination_country_page.blocks) {
|
||||
destination_country_page.blocks.forEach((block) => {
|
||||
switch (block.__typename) {
|
||||
case DestinationCountryPageEnum.ContentStack.blocks.Accordion: {
|
||||
if (block.accordion.length) {
|
||||
connections.push(...block.accordion)
|
||||
}
|
||||
break
|
||||
}
|
||||
case DestinationCountryPageEnum.ContentStack.blocks.Content:
|
||||
{
|
||||
if (block.content.length) {
|
||||
// TS has trouble infering the filtered types
|
||||
// @ts-ignore
|
||||
connections.push(...block.content)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
if (destination_country_page.sidepeek_content) {
|
||||
destination_country_page.sidepeek_content.content.embedded_itemsConnection.edges.forEach(
|
||||
({ node }) => {
|
||||
|
||||
@@ -35,6 +35,10 @@ export type Accordion = z.infer<typeof accordionSchema>
|
||||
enum AccordionEnum {
|
||||
ContentPageBlocksAccordionBlockAccordionsGlobalAccordion = "ContentPageBlocksAccordionBlockAccordionsGlobalAccordion",
|
||||
ContentPageBlocksAccordionBlockAccordionsSpecificAccordion = "ContentPageBlocksAccordionBlockAccordionsSpecificAccordion",
|
||||
DestinationCityPageBlocksAccordionBlockAccordionsGlobalAccordion = "DestinationCityPageBlocksAccordionBlockAccordionsGlobalAccordion",
|
||||
DestinationCityPageBlocksAccordionBlockAccordionsSpecificAccordion = "DestinationCityPageBlocksAccordionBlockAccordionsSpecificAccordion",
|
||||
DestinationCountryPageBlocksAccordionBlockAccordionsGlobalAccordion = "DestinationCountryPageBlocksAccordionBlockAccordionsGlobalAccordion",
|
||||
DestinationCountryPageBlocksAccordionBlockAccordionsSpecificAccordion = "DestinationCountryPageBlocksAccordionBlockAccordionsSpecificAccordion",
|
||||
}
|
||||
|
||||
export const accordionSchema = z.object({
|
||||
@@ -47,10 +51,7 @@ export const accordionSchema = z.object({
|
||||
title: z.string().optional().default(""),
|
||||
accordions: z.array(
|
||||
z.object({
|
||||
__typename: z.enum([
|
||||
AccordionEnum.ContentPageBlocksAccordionBlockAccordionsGlobalAccordion,
|
||||
AccordionEnum.ContentPageBlocksAccordionBlockAccordionsSpecificAccordion,
|
||||
]),
|
||||
__typename: z.nativeEnum(AccordionEnum),
|
||||
global_accordion: z
|
||||
.object({
|
||||
global_accordionConnection: z.object({
|
||||
@@ -78,6 +79,8 @@ export const accordionSchema = z.object({
|
||||
accordions: data.accordions.flatMap((acc) => {
|
||||
switch (acc.__typename) {
|
||||
case AccordionEnum.ContentPageBlocksAccordionBlockAccordionsGlobalAccordion:
|
||||
case AccordionEnum.DestinationCityPageBlocksAccordionBlockAccordionsGlobalAccordion:
|
||||
case AccordionEnum.DestinationCountryPageBlocksAccordionBlockAccordionsGlobalAccordion:
|
||||
return (
|
||||
acc.global_accordion?.global_accordionConnection.edges.flatMap(
|
||||
({ node: accordionConnection }) => {
|
||||
@@ -86,6 +89,8 @@ export const accordionSchema = z.object({
|
||||
) || []
|
||||
)
|
||||
case AccordionEnum.ContentPageBlocksAccordionBlockAccordionsSpecificAccordion:
|
||||
case AccordionEnum.DestinationCityPageBlocksAccordionBlockAccordionsSpecificAccordion:
|
||||
case AccordionEnum.DestinationCountryPageBlocksAccordionBlockAccordionsSpecificAccordion:
|
||||
return acc.specific_accordion?.questions || []
|
||||
}
|
||||
}),
|
||||
@@ -136,10 +141,7 @@ export const accordionRefsSchema = z.object({
|
||||
.object({
|
||||
accordions: z.array(
|
||||
z.object({
|
||||
__typename: z.enum([
|
||||
AccordionEnum.ContentPageBlocksAccordionBlockAccordionsGlobalAccordion,
|
||||
AccordionEnum.ContentPageBlocksAccordionBlockAccordionsSpecificAccordion,
|
||||
]),
|
||||
__typename: z.nativeEnum(AccordionEnum),
|
||||
global_accordion: z
|
||||
.object({
|
||||
global_accordionConnection: globalAccordionConnectionRefs,
|
||||
@@ -153,6 +155,8 @@ export const accordionRefsSchema = z.object({
|
||||
return data.accordions.flatMap((accordion) => {
|
||||
switch (accordion.__typename) {
|
||||
case AccordionEnum.ContentPageBlocksAccordionBlockAccordionsGlobalAccordion:
|
||||
case AccordionEnum.DestinationCityPageBlocksAccordionBlockAccordionsGlobalAccordion:
|
||||
case AccordionEnum.DestinationCountryPageBlocksAccordionBlockAccordionsGlobalAccordion:
|
||||
return (
|
||||
accordion.global_accordion?.global_accordionConnection.edges.flatMap(
|
||||
({ node: accordionConnection }) => {
|
||||
@@ -165,6 +169,8 @@ export const accordionRefsSchema = z.object({
|
||||
) || []
|
||||
)
|
||||
case AccordionEnum.ContentPageBlocksAccordionBlockAccordionsSpecificAccordion:
|
||||
case AccordionEnum.DestinationCityPageBlocksAccordionBlockAccordionsSpecificAccordion:
|
||||
case AccordionEnum.DestinationCountryPageBlocksAccordionBlockAccordionsSpecificAccordion:
|
||||
return (
|
||||
accordion.specific_accordion?.questions.flatMap((question) =>
|
||||
question.answer.embedded_itemsConnection.edges.flatMap(
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { Block as AccountPageBlock } from "@/types/trpc/routers/contentstack/accountPage"
|
||||
import type { Block as CollectionPageBlock } from "@/types/trpc/routers/contentstack/collectionPage"
|
||||
import type { Block as ContentPageBlock } from "@/types/trpc/routers/contentstack/contentPage"
|
||||
import type { Block as DestinationCityPageBlock } from "@/types/trpc/routers/contentstack/destinationCityPage"
|
||||
import type { Block as DestinationCountryPageBlock } from "@/types/trpc/routers/contentstack/destinationCountryPage"
|
||||
import type { Block as LoyaltyPageBlock } from "@/types/trpc/routers/contentstack/loyaltyPage"
|
||||
import type { Block as StartPageBlock } from "@/types/trpc/routers/contentstack/startPage"
|
||||
|
||||
@@ -8,6 +10,8 @@ export type Blocks =
|
||||
| AccountPageBlock
|
||||
| CollectionPageBlock
|
||||
| ContentPageBlock
|
||||
| DestinationCityPageBlock
|
||||
| DestinationCountryPageBlock
|
||||
| LoyaltyPageBlock
|
||||
| StartPageBlock
|
||||
|
||||
|
||||
8
types/enums/destinationCityPage.ts
Normal file
8
types/enums/destinationCityPage.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export namespace DestinationCityPageEnum {
|
||||
export namespace ContentStack {
|
||||
export const enum blocks {
|
||||
Accordion = "DestinationCityPageBlocksAccordion",
|
||||
Content = "DestinationCityPageBlocksContent",
|
||||
}
|
||||
}
|
||||
}
|
||||
8
types/enums/destinationCountryPage.ts
Normal file
8
types/enums/destinationCountryPage.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export namespace DestinationCountryPageEnum {
|
||||
export namespace ContentStack {
|
||||
export const enum blocks {
|
||||
Accordion = "DestinationCountryPageBlocksAccordion",
|
||||
Content = "DestinationCountryPageBlocksContent",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { z } from "zod"
|
||||
|
||||
import type {
|
||||
blocksSchema,
|
||||
destinationCityListDataSchema,
|
||||
destinationCityPageRefsSchema,
|
||||
destinationCityPageSchema,
|
||||
@@ -21,6 +22,7 @@ export interface DestinationCityListData
|
||||
export interface DestinationCityListItem extends DestinationCityListData {
|
||||
cityName: string
|
||||
}
|
||||
export type Block = z.output<typeof blocksSchema>
|
||||
|
||||
export interface GetDestinationCityPageRefsSchema
|
||||
extends z.input<typeof destinationCityPageRefsSchema> {}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { z } from "zod"
|
||||
|
||||
import type {
|
||||
blocksSchema,
|
||||
destinationCountryPageRefsSchema,
|
||||
destinationCountryPageSchema,
|
||||
} from "@/server/routers/contentstack/destinationCountryPage/output"
|
||||
@@ -11,6 +12,7 @@ interface DestinationCountryPage
|
||||
extends z.output<typeof destinationCountryPageSchema> {}
|
||||
export type DestinationCountryPageData =
|
||||
DestinationCountryPage["destinationCountryPage"]
|
||||
export type Block = z.output<typeof blocksSchema>
|
||||
|
||||
export interface GetDestinationCountryPageRefsSchema
|
||||
extends z.input<typeof destinationCountryPageRefsSchema> {}
|
||||
|
||||
Reference in New Issue
Block a user