feat(SW-2973): Added bookingCode if available to links inside campaign pages
* feat(SW-2973): Moved block types to trpc lib Approved-by: Matilda Landström
This commit is contained in:
@@ -24,6 +24,7 @@ import styles from "./campaignHotelListing.module.css"
|
|||||||
interface CampaignHotelListingClientProps {
|
interface CampaignHotelListingClientProps {
|
||||||
heading: string
|
heading: string
|
||||||
preamble?: string | null
|
preamble?: string | null
|
||||||
|
bookingCode?: string | null
|
||||||
visibleCountMobile: 3 | 6
|
visibleCountMobile: 3 | 6
|
||||||
visibleCountDesktop: 3 | 6
|
visibleCountDesktop: 3 | 6
|
||||||
isMainBlock: boolean
|
isMainBlock: boolean
|
||||||
@@ -35,6 +36,7 @@ export default function CampaignHotelListingClient({
|
|||||||
visibleCountMobile,
|
visibleCountMobile,
|
||||||
visibleCountDesktop,
|
visibleCountDesktop,
|
||||||
isMainBlock,
|
isMainBlock,
|
||||||
|
bookingCode,
|
||||||
}: CampaignHotelListingClientProps) {
|
}: CampaignHotelListingClientProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const isMobile = useMediaQuery("(max-width: 767px)")
|
const isMobile = useMediaQuery("(max-width: 767px)")
|
||||||
@@ -119,16 +121,24 @@ export default function CampaignHotelListingClient({
|
|||||||
) : null}
|
) : null}
|
||||||
</header>
|
</header>
|
||||||
<ul className={styles.list}>
|
<ul className={styles.list}>
|
||||||
{activeHotels.map(({ hotel, url }, index) => (
|
{activeHotels.map(({ hotel, url }, index) => {
|
||||||
<li
|
const urlWithOptionalBookingCode = bookingCode
|
||||||
key={hotel.id}
|
? `${url}?bookingCode=${bookingCode}`
|
||||||
className={cx(styles.listItem, {
|
: url
|
||||||
[styles.hidden]: index >= visibleCount,
|
return (
|
||||||
})}
|
<li
|
||||||
>
|
key={hotel.id}
|
||||||
<HotelListingItem hotel={hotel} url={url} />
|
className={cx(styles.listItem, {
|
||||||
</li>
|
[styles.hidden]: index >= visibleCount,
|
||||||
))}
|
})}
|
||||||
|
>
|
||||||
|
<HotelListingItem
|
||||||
|
hotel={hotel}
|
||||||
|
url={urlWithOptionalBookingCode}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{showButton ? (
|
{showButton ? (
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ interface CampaignHotelListingProps {
|
|||||||
heading: string
|
heading: string
|
||||||
preamble?: string | null
|
preamble?: string | null
|
||||||
hotelIds: string[]
|
hotelIds: string[]
|
||||||
|
bookingCode?: string | null
|
||||||
visibleCountMobile?: 3 | 6
|
visibleCountMobile?: 3 | 6
|
||||||
visibleCountDesktop?: 3 | 6
|
visibleCountDesktop?: 3 | 6
|
||||||
isMainBlock?: boolean
|
isMainBlock?: boolean
|
||||||
@@ -28,6 +29,7 @@ export default async function CampaignHotelListing({
|
|||||||
heading,
|
heading,
|
||||||
preamble,
|
preamble,
|
||||||
hotelIds,
|
hotelIds,
|
||||||
|
bookingCode,
|
||||||
visibleCountMobile = 3,
|
visibleCountMobile = 3,
|
||||||
visibleCountDesktop = 6,
|
visibleCountDesktop = 6,
|
||||||
isMainBlock = false,
|
isMainBlock = false,
|
||||||
@@ -66,6 +68,7 @@ export default async function CampaignHotelListing({
|
|||||||
<CampaignHotelListingClient
|
<CampaignHotelListingClient
|
||||||
heading={heading}
|
heading={heading}
|
||||||
preamble={preamble}
|
preamble={preamble}
|
||||||
|
bookingCode={bookingCode}
|
||||||
visibleCountMobile={visibleCountMobile}
|
visibleCountMobile={visibleCountMobile}
|
||||||
visibleCountDesktop={visibleCountDesktop}
|
visibleCountDesktop={visibleCountDesktop}
|
||||||
isMainBlock={isMainBlock}
|
isMainBlock={isMainBlock}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
|
|
||||||
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
|
||||||
|
|
||||||
import CardsGrid from "@/components/Blocks/CardsGrid"
|
import CardsGrid from "@/components/Blocks/CardsGrid"
|
||||||
import CarouselCards from "@/components/Blocks/CarouselCards"
|
import CarouselCards from "@/components/Blocks/CarouselCards"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
|
||||||
|
|
||||||
import CampaignHotelListing from "@/components/Blocks/CampaignHotelListing"
|
import CampaignHotelListing from "@/components/Blocks/CampaignHotelListing"
|
||||||
import CarouselCards from "@/components/Blocks/CarouselCards"
|
import CarouselCards from "@/components/Blocks/CarouselCards"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Suspense } from "react"
|
import { Suspense } from "react"
|
||||||
|
|
||||||
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
|
||||||
|
|
||||||
import AccordionSection from "@/components/Blocks/Accordion"
|
import AccordionSection from "@/components/Blocks/Accordion"
|
||||||
import CampaignHotelListing from "@/components/Blocks/CampaignHotelListing"
|
import CampaignHotelListing from "@/components/Blocks/CampaignHotelListing"
|
||||||
@@ -8,7 +8,11 @@ import CampaignHotelListingSkeleton from "@/components/Blocks/CampaignHotelListi
|
|||||||
import CarouselCards from "@/components/Blocks/CarouselCards"
|
import CarouselCards from "@/components/Blocks/CarouselCards"
|
||||||
import Essentials from "@/components/Blocks/Essentials"
|
import Essentials from "@/components/Blocks/Essentials"
|
||||||
|
|
||||||
import type { BlocksProps } from "@/types/components/blocks"
|
import type { Block as CampaignPageBlock } from "@scandic-hotels/trpc/types/campaignPage"
|
||||||
|
|
||||||
|
interface BlocksProps {
|
||||||
|
blocks: CampaignPageBlock[]
|
||||||
|
}
|
||||||
|
|
||||||
export default function Blocks({ blocks }: BlocksProps) {
|
export default function Blocks({ blocks }: BlocksProps) {
|
||||||
return blocks.map(async (block) => {
|
return blocks.map(async (block) => {
|
||||||
@@ -39,6 +43,7 @@ export default function Blocks({ blocks }: BlocksProps) {
|
|||||||
heading={block.hotel_listing.heading}
|
heading={block.hotel_listing.heading}
|
||||||
hotelIds={block.hotel_listing.hotelIds}
|
hotelIds={block.hotel_listing.hotelIds}
|
||||||
isMainBlock={true}
|
isMainBlock={true}
|
||||||
|
bookingCode={block.hotel_listing.bookingCode}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
|
||||||
|
|
||||||
import { useDestinationDataStore } from "@/stores/destination-data"
|
import { useDestinationDataStore } from "@/stores/destination-data"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Title from "@scandic-hotels/design-system/Title"
|
import Title from "@scandic-hotels/design-system/Title"
|
||||||
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
|
||||||
|
|
||||||
import { getStartPage } from "@/lib/trpc/memoizedRequests"
|
import { getStartPage } from "@/lib/trpc/memoizedRequests"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
|
||||||
import { DynamicContentEnum } from "@scandic-hotels/trpc/types/dynamicContent"
|
import { DynamicContentEnum } from "@scandic-hotels/trpc/types/dynamicContent"
|
||||||
|
|
||||||
import Overview from "@/components/Blocks/DynamicContent/Overview"
|
import Overview from "@/components/Blocks/DynamicContent/Overview"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
|
||||||
|
|
||||||
import CardsGrid from "@/components/Blocks/CardsGrid"
|
import CardsGrid from "@/components/Blocks/CardsGrid"
|
||||||
import DynamicContent from "@/components/Blocks/DynamicContent"
|
import DynamicContent from "@/components/Blocks/DynamicContent"
|
||||||
@@ -8,7 +8,6 @@ import { getLang } from "@/i18n/serverContext"
|
|||||||
import { modWebviewLink } from "@/utils/webviews"
|
import { modWebviewLink } from "@/utils/webviews"
|
||||||
|
|
||||||
import type { BlocksProps } from "@/types/components/blocks"
|
import type { BlocksProps } from "@/types/components/blocks"
|
||||||
// import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
|
|
||||||
|
|
||||||
export default async function Blocks({ blocks }: BlocksProps) {
|
export default async function Blocks({ blocks }: BlocksProps) {
|
||||||
const lang = await getLang()
|
const lang = await getLang()
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import type { CardGallery } from "@/types/trpc/routers/contentstack/blocks"
|
import type { CardGallery } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface CardGalleryProps extends Pick<CardGallery, "card_gallery"> {}
|
export interface CardGalleryProps extends Pick<CardGallery, "card_gallery"> {}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import type { CardsGrid } from "@/types/trpc/routers/contentstack/blocks"
|
import type { CardsGrid } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface CardsGridProps extends Pick<CardsGrid, "cards_grid"> {}
|
export interface CardsGridProps extends Pick<CardsGrid, "cards_grid"> {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { CarouselCards } from "@/types/trpc/routers/contentstack/blocks"
|
import type { CarouselCards } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface CarouselCardsProps
|
export interface CarouselCardsProps
|
||||||
extends Pick<CarouselCards, "carousel_cards"> {}
|
extends Pick<CarouselCards, "carousel_cards"> {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { DynamicContent } from "@/types/trpc/routers/contentstack/blocks"
|
import type { DynamicContent } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
interface PartialDynamicContent
|
interface PartialDynamicContent
|
||||||
extends Pick<DynamicContent, "dynamic_content"> {}
|
extends Pick<DynamicContent, "dynamic_content"> {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { HotelListing } from "@/types/trpc/routers/contentstack/blocks"
|
import type { HotelListing } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface HotelListingProps {
|
export interface HotelListingProps {
|
||||||
heading?: string
|
heading?: string
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { Shortcut } from "@/types/trpc/routers/contentstack/blocks"
|
import type { Shortcut } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface ShortcutsListProps extends Shortcut {}
|
export interface ShortcutsListProps extends Shortcut {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { TableData } from "@/types/trpc/routers/contentstack/blocks"
|
import type { TableData } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface TableBlockProps {
|
export interface TableBlockProps {
|
||||||
data: TableData
|
data: TableData
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import type { TextCols } from "@/types/trpc/routers/contentstack/blocks"
|
import type { TextCols } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface TextColProps extends Pick<TextCols, "text_cols"> {}
|
export interface TextColProps extends Pick<TextCols, "text_cols"> {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { UspGrid } from "@/types/trpc/routers/contentstack/blocks"
|
import type { UspGrid } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface UspGridProps extends Pick<UspGrid, "usp_grid"> {}
|
export interface UspGridProps extends Pick<UspGrid, "usp_grid"> {}
|
||||||
export type UspIcon = UspGrid["usp_grid"]["usp_card"][number]["icon"]
|
export type UspIcon = UspGrid["usp_grid"]["usp_card"][number]["icon"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { HotelListingHotelData } from "@scandic-hotels/trpc/types/hotel"
|
import { type HotelListingHotelData } from "@scandic-hotels/trpc/types/hotel"
|
||||||
|
|
||||||
import type { HotelListing } from "@/types/trpc/routers/contentstack/blocks"
|
import type { HotelListing } from "@scandic-hotels/trpc/types/blocks"
|
||||||
|
|
||||||
export interface HotelListingItemProps {
|
export interface HotelListingItemProps {
|
||||||
hotelData: HotelListingHotelData
|
hotelData: HotelListingHotelData
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import type { blocksSchema } from "@scandic-hotels/trpc/routers/contentstack/accountPage/output"
|
import type { blocksSchema } from "@scandic-hotels/trpc/routers/contentstack/accountPage/output"
|
||||||
|
import type { DynamicContent } from "@scandic-hotels/trpc/types/blocks"
|
||||||
import type { Reward } from "@scandic-hotels/trpc/types/rewards"
|
import type { Reward } from "@scandic-hotels/trpc/types/rewards"
|
||||||
import type { Dispatch, SetStateAction } from "react"
|
import type { Dispatch, SetStateAction } from "react"
|
||||||
import type { z } from "zod"
|
import type { z } from "zod"
|
||||||
|
|
||||||
import type { DynamicContent } from "@/types/trpc/routers/contentstack/blocks"
|
|
||||||
|
|
||||||
export interface AccountPageContentProps
|
export interface AccountPageContentProps
|
||||||
extends Pick<DynamicContent, "dynamic_content"> {}
|
extends Pick<DynamicContent, "dynamic_content"> {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import type { TeaserCard } from "@scandic-hotels/trpc/types/blocks"
|
||||||
import type { ImageVaultAsset } from "@scandic-hotels/trpc/types/imageVault"
|
import type { ImageVaultAsset } from "@scandic-hotels/trpc/types/imageVault"
|
||||||
import type { VariantProps } from "class-variance-authority"
|
import type { VariantProps } from "class-variance-authority"
|
||||||
|
|
||||||
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
||||||
import type { teaserCardVariants } from "@/components/TempDesignSystem/TeaserCard/variants"
|
import type { teaserCardVariants } from "@/components/TempDesignSystem/TeaserCard/variants"
|
||||||
import type { TeaserCard } from "../trpc/routers/contentstack/blocks"
|
|
||||||
|
|
||||||
interface SidePeekButton {
|
interface SidePeekButton {
|
||||||
call_to_action_text: string
|
call_to_action_text: string
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import type { cardGallerySchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/cardGallery"
|
|
||||||
import type { teaserCardBlockSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/cards/teaserCard"
|
|
||||||
import type { cardsGridSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/cardsGrid"
|
|
||||||
import type { carouselCardsSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/carouselCards"
|
|
||||||
import type { contentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/content"
|
|
||||||
import type { dynamicContentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/dynamicContent"
|
|
||||||
import type { contentPageHotelListingSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/hotelListing"
|
|
||||||
import type { shortcutsSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/shortcuts"
|
|
||||||
import type { tableSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/table"
|
|
||||||
import type { textColsSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/textCols"
|
|
||||||
import type { uspGridSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/uspGrid"
|
|
||||||
import type { z } from "zod"
|
|
||||||
|
|
||||||
export interface TeaserCard extends z.output<typeof teaserCardBlockSchema> {}
|
|
||||||
export interface CardsGrid extends z.output<typeof cardsGridSchema> {}
|
|
||||||
export interface Content extends z.output<typeof contentSchema> {}
|
|
||||||
export interface DynamicContent extends z.output<typeof dynamicContentSchema> {}
|
|
||||||
export interface Shortcuts extends z.output<typeof shortcutsSchema> {}
|
|
||||||
export type Shortcut = Shortcuts["shortcuts"]
|
|
||||||
export interface TableBlock extends z.output<typeof tableSchema> {}
|
|
||||||
export type TableData = TableBlock["table"]
|
|
||||||
export interface TextCols extends z.output<typeof textColsSchema> {}
|
|
||||||
export interface UspGrid extends z.output<typeof uspGridSchema> {}
|
|
||||||
interface GetHotelListing
|
|
||||||
extends z.output<typeof contentPageHotelListingSchema> {}
|
|
||||||
export type HotelListing = GetHotelListing["hotel_listing"]
|
|
||||||
export interface CarouselCards extends z.output<typeof carouselCardsSchema> {}
|
|
||||||
export interface CardGallery extends z.output<typeof cardGallerySchema> {}
|
|
||||||
@@ -28,6 +28,9 @@ query GetCampaignPage($locale: String!, $uid: String!) {
|
|||||||
...Accordion_CampaignPage
|
...Accordion_CampaignPage
|
||||||
...HotelListing_CampaignPage
|
...HotelListing_CampaignPage
|
||||||
}
|
}
|
||||||
|
page_settings {
|
||||||
|
booking_code
|
||||||
|
}
|
||||||
system {
|
system {
|
||||||
...System
|
...System
|
||||||
created_at
|
created_at
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
linkConnectionSchema,
|
linkConnectionSchema,
|
||||||
} from "../schemas/linkConnection"
|
} from "../schemas/linkConnection"
|
||||||
import { systemSchema } from "../schemas/system"
|
import { systemSchema } from "../schemas/system"
|
||||||
|
import { getCarouselCardsBlockWithBookingCodeLinks } from "./utils"
|
||||||
|
|
||||||
const campaignPageEssentials = z
|
const campaignPageEssentials = z
|
||||||
.object({
|
.object({
|
||||||
@@ -123,6 +124,11 @@ export const campaignPageSchema = z
|
|||||||
second_column: z.string(),
|
second_column: z.string(),
|
||||||
}),
|
}),
|
||||||
blocks: discriminatedUnionArray(blocksSchema.options),
|
blocks: discriminatedUnionArray(blocksSchema.options),
|
||||||
|
page_settings: z
|
||||||
|
.object({
|
||||||
|
booking_code: z.string().nullish(),
|
||||||
|
})
|
||||||
|
.nullish(),
|
||||||
system: systemSchema.merge(
|
system: systemSchema.merge(
|
||||||
z.object({
|
z.object({
|
||||||
created_at: z.string(),
|
created_at: z.string(),
|
||||||
@@ -134,27 +140,35 @@ export const campaignPageSchema = z
|
|||||||
url: z.string(),
|
url: z.string(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.transform((data) => {
|
.transform(({ campaign_page, ...data }) => {
|
||||||
const blocks = data.campaign_page.blocks.map((block) => {
|
const { blocks, page_settings, included_hotels, ...campaignPageData } =
|
||||||
if (
|
campaign_page
|
||||||
block.__typename === CampaignPageEnum.ContentStack.blocks.HotelListing
|
const bookingCode = page_settings?.booking_code || null
|
||||||
) {
|
const mappedBlocks = blocks.map((block) => {
|
||||||
return {
|
switch (block.__typename) {
|
||||||
...block,
|
case CampaignPageEnum.ContentStack.blocks.HotelListing:
|
||||||
hotel_listing: {
|
return {
|
||||||
...block.hotel_listing,
|
...block,
|
||||||
hotelIds: data.campaign_page.included_hotels,
|
hotel_listing: {
|
||||||
},
|
...block.hotel_listing,
|
||||||
}
|
hotelIds: included_hotels,
|
||||||
|
bookingCode,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
case CampaignPageEnum.ContentStack.blocks.CarouselCards:
|
||||||
|
return getCarouselCardsBlockWithBookingCodeLinks(block, bookingCode)
|
||||||
|
case CampaignPageEnum.ContentStack.blocks.Essentials:
|
||||||
|
case CampaignPageEnum.ContentStack.blocks.Accordion:
|
||||||
|
default:
|
||||||
|
return block
|
||||||
}
|
}
|
||||||
return block
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...data,
|
...data,
|
||||||
campaign_page: {
|
campaign_page: {
|
||||||
...data.campaign_page,
|
...campaignPageData,
|
||||||
blocks: [...blocks],
|
blocks: [...mappedBlocks],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import { CampaignPageEnum } from "../../../types/campaignPage"
|
import {
|
||||||
|
CampaignPageEnum,
|
||||||
|
type CampaignPageRefs,
|
||||||
|
} from "../../../types/campaignPage"
|
||||||
import { generateTag, generateTagsFromSystem } from "../../../utils/generateTag"
|
import { generateTag, generateTagsFromSystem } from "../../../utils/generateTag"
|
||||||
|
|
||||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||||
|
|
||||||
import type { CampaignPageRefs } from "../../../types/campaignPage"
|
import type { CarouselCardsBlock } from "../../../types/campaignPage"
|
||||||
import type { System } from "../schemas/system"
|
import type { System } from "../schemas/system"
|
||||||
|
|
||||||
export function generatePageTags(
|
export function generatePageTags(
|
||||||
@@ -43,3 +46,35 @@ export function getConnections({ campaign_page }: CampaignPageRefs) {
|
|||||||
|
|
||||||
return connections
|
return connections
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCarouselCardsBlockWithBookingCodeLinks(
|
||||||
|
block: CarouselCardsBlock,
|
||||||
|
bookingCode: string | null
|
||||||
|
): CarouselCardsBlock {
|
||||||
|
if (!bookingCode) {
|
||||||
|
return block
|
||||||
|
}
|
||||||
|
|
||||||
|
const { link, cards, ...carousel_cards } = block.carousel_cards
|
||||||
|
return {
|
||||||
|
...block,
|
||||||
|
carousel_cards: {
|
||||||
|
...carousel_cards,
|
||||||
|
link: link
|
||||||
|
? {
|
||||||
|
...link,
|
||||||
|
href: `${link.href}?bookingCode=${bookingCode}`,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
cards: cards.map(({ link, ...card }) => ({
|
||||||
|
...card,
|
||||||
|
link: link
|
||||||
|
? {
|
||||||
|
...link,
|
||||||
|
href: `${link.href}?bookingCode=${bookingCode}`,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import {
|
import {
|
||||||
linkRefsUnionSchema,
|
linkRefsUnionSchema,
|
||||||
linkUnionSchema,
|
linkUnionSchema,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import {
|
import {
|
||||||
contentCardRefSchema,
|
contentCardRefSchema,
|
||||||
contentCardSchema,
|
contentCardSchema,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { scriptedCardThemeEnum } from "../../../../enums/scriptedCard"
|
import { scriptedCardThemeEnum } from "../../../../enums/scriptedCard"
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import {
|
import {
|
||||||
CardsGridEnum,
|
CardsGridEnum,
|
||||||
CardsGridLayoutEnum,
|
CardsGridLayoutEnum,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import {
|
import {
|
||||||
contentCardRefSchema,
|
contentCardRefSchema,
|
||||||
contentCardSchema,
|
contentCardSchema,
|
||||||
@@ -66,6 +66,7 @@ const carouselCardGroupsNoFilterSchema = z
|
|||||||
.filter((card): card is NonNullable<typeof card> => card !== null)
|
.filter((card): card is NonNullable<typeof card> => card !== null)
|
||||||
.map((card) => ({
|
.map((card) => ({
|
||||||
...card,
|
...card,
|
||||||
|
filterId: "", // No filter for these cards
|
||||||
}))
|
}))
|
||||||
return {
|
return {
|
||||||
cards,
|
cards,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { ContentEnum } from "../../../../types/content"
|
import { ContentEnum } from "../../../../types/content"
|
||||||
import {
|
import {
|
||||||
accountPageSchema,
|
accountPageSchema,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { DynamicContentEnum } from "../../../../types/dynamicContent"
|
import { DynamicContentEnum } from "../../../../types/dynamicContent"
|
||||||
import {
|
import {
|
||||||
linkRefsUnionSchema,
|
linkRefsUnionSchema,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
|
|
||||||
export const essentialsSchema = z.object({
|
export const essentialsSchema = z.object({
|
||||||
essentials: z.object({
|
essentials: z.object({
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import * as pageLinks from "../../../../routers/contentstack/schemas/pageLinks"
|
import * as pageLinks from "../../../../routers/contentstack/schemas/pageLinks"
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { tempImageVaultAssetSchema } from "../imageVault"
|
import { tempImageVaultAssetSchema } from "../imageVault"
|
||||||
import { systemSchema } from "../system"
|
import { systemSchema } from "../system"
|
||||||
import { buttonSchema } from "./utils/buttonLinkSchema"
|
import { buttonSchema } from "./utils/buttonLinkSchema"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { HotelPageEnum } from "../../../../types/hotelPageEnum"
|
import { HotelPageEnum } from "../../../../types/hotelPageEnum"
|
||||||
import {
|
import {
|
||||||
accordionItemsSchema,
|
accordionItemsSchema,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { Country } from "../../../../types/country"
|
import { Country } from "../../../../types/country"
|
||||||
|
|
||||||
export const locationFilterSchema = z
|
export const locationFilterSchema = z
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { tempImageVaultAssetSchema } from "../imageVault"
|
import { tempImageVaultAssetSchema } from "../imageVault"
|
||||||
import { buttonSchema } from "./utils/buttonLinkSchema"
|
import { buttonSchema } from "./utils/buttonLinkSchema"
|
||||||
import { linkConnectionRefsSchema } from "./utils/linkConnection"
|
import { linkConnectionRefsSchema } from "./utils/linkConnection"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import {
|
import {
|
||||||
linkRefsUnionSchema,
|
linkRefsUnionSchema,
|
||||||
linkUnionSchema,
|
linkUnionSchema,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
|
|
||||||
export const tableSchema = z.object({
|
export const tableSchema = z.object({
|
||||||
typename: z
|
typename: z
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { ContentEnum } from "../../../../types/content"
|
import { ContentEnum } from "../../../../types/content"
|
||||||
import {
|
import {
|
||||||
linkRefsUnionSchema,
|
linkRefsUnionSchema,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { sysAssetSchema } from "./sysAsset"
|
import { sysAssetSchema } from "./sysAsset"
|
||||||
|
|
||||||
export const textContentSchema = z.object({
|
export const textContentSchema = z.object({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { BlocksEnums } from "../../../../types/blocks"
|
import { BlocksEnums } from "../../../../types/blocksEnum"
|
||||||
import { UspGridEnum } from "../../../../types/uspGrid"
|
import { UspGridEnum } from "../../../../types/uspGrid"
|
||||||
import {
|
import {
|
||||||
linkRefsUnionSchema,
|
linkRefsUnionSchema,
|
||||||
|
|||||||
@@ -1,21 +1,28 @@
|
|||||||
export namespace BlocksEnums {
|
import type { cardGallerySchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/cardGallery"
|
||||||
export const enum block {
|
import type { teaserCardBlockSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/cards/teaserCard"
|
||||||
Accordion = "Accordion",
|
import type { cardsGridSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/cardsGrid"
|
||||||
CardGallery = "CardGallery",
|
import type { carouselCardsSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/carouselCards"
|
||||||
CardsGrid = "CardsGrid",
|
import type { contentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/content"
|
||||||
CarouselCards = "CarouselCards",
|
import type { dynamicContentSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/dynamicContent"
|
||||||
Content = "Content",
|
import type { contentPageHotelListingSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/hotelListing"
|
||||||
DynamicContent = "DynamicContent",
|
import type { shortcutsSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/shortcuts"
|
||||||
FullWidthCampaign = "FullWidthCampaign",
|
import type { tableSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/table"
|
||||||
CampaignOverviewPageHotelListing = "CampaignOverviewPageHotelListing",
|
import type { textColsSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/textCols"
|
||||||
CampaignPageHotelListing = "CampaignPageHotelListing",
|
import type { uspGridSchema } from "@scandic-hotels/trpc/routers/contentstack/schemas/blocks/uspGrid"
|
||||||
ContentPageHotelListing = "ContentPageHotelListing",
|
import type { z } from "zod"
|
||||||
JoinScandicFriends = "JoinScandicFriends",
|
|
||||||
Shortcuts = "Shortcuts",
|
export interface TeaserCard extends z.output<typeof teaserCardBlockSchema> {}
|
||||||
Table = "Table",
|
export interface CardsGrid extends z.output<typeof cardsGridSchema> {}
|
||||||
TextCols = "TextCols",
|
export interface Content extends z.output<typeof contentSchema> {}
|
||||||
TextContent = "TextContent",
|
export interface DynamicContent extends z.output<typeof dynamicContentSchema> {}
|
||||||
UspGrid = "UspGrid",
|
export interface Shortcuts extends z.output<typeof shortcutsSchema> {}
|
||||||
Essentials = "Essentials",
|
export type Shortcut = Shortcuts["shortcuts"]
|
||||||
}
|
export interface TableBlock extends z.output<typeof tableSchema> {}
|
||||||
}
|
export type TableData = TableBlock["table"]
|
||||||
|
export interface TextCols extends z.output<typeof textColsSchema> {}
|
||||||
|
export interface UspGrid extends z.output<typeof uspGridSchema> {}
|
||||||
|
interface GetHotelListing
|
||||||
|
extends z.output<typeof contentPageHotelListingSchema> {}
|
||||||
|
export type HotelListing = GetHotelListing["hotel_listing"]
|
||||||
|
export interface CarouselCards extends z.output<typeof carouselCardsSchema> {}
|
||||||
|
export interface CardGallery extends z.output<typeof cardGallerySchema> {}
|
||||||
|
|||||||
21
packages/trpc/lib/types/blocksEnum.ts
Normal file
21
packages/trpc/lib/types/blocksEnum.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
export namespace BlocksEnums {
|
||||||
|
export const enum block {
|
||||||
|
Accordion = "Accordion",
|
||||||
|
CardGallery = "CardGallery",
|
||||||
|
CardsGrid = "CardsGrid",
|
||||||
|
CarouselCards = "CarouselCards",
|
||||||
|
Content = "Content",
|
||||||
|
DynamicContent = "DynamicContent",
|
||||||
|
FullWidthCampaign = "FullWidthCampaign",
|
||||||
|
CampaignOverviewPageHotelListing = "CampaignOverviewPageHotelListing",
|
||||||
|
CampaignPageHotelListing = "CampaignPageHotelListing",
|
||||||
|
ContentPageHotelListing = "ContentPageHotelListing",
|
||||||
|
JoinScandicFriends = "JoinScandicFriends",
|
||||||
|
Shortcuts = "Shortcuts",
|
||||||
|
Table = "Table",
|
||||||
|
TextCols = "TextCols",
|
||||||
|
TextContent = "TextContent",
|
||||||
|
UspGrid = "UspGrid",
|
||||||
|
Essentials = "Essentials",
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
campaignPageSchema,
|
campaignPageSchema,
|
||||||
heroSchema,
|
heroSchema,
|
||||||
} from "../routers/contentstack/campaignPage/output"
|
} from "../routers/contentstack/campaignPage/output"
|
||||||
|
import type { carouselCardsSchema } from "../routers/contentstack/schemas/blocks/carouselCards"
|
||||||
import type { essentialsSchema } from "../routers/contentstack/schemas/blocks/essentials"
|
import type { essentialsSchema } from "../routers/contentstack/schemas/blocks/essentials"
|
||||||
|
|
||||||
export namespace CampaignPageEnum {
|
export namespace CampaignPageEnum {
|
||||||
@@ -31,6 +32,8 @@ export interface CampaignPageRefs
|
|||||||
|
|
||||||
export type Block = CampaignPageData["blocks"][number]
|
export type Block = CampaignPageData["blocks"][number]
|
||||||
|
|
||||||
|
export interface CarouselCardsBlock
|
||||||
|
extends z.output<typeof carouselCardsSchema> {}
|
||||||
export type EssentialsBlock = z.output<typeof essentialsSchema>["essentials"]
|
export type EssentialsBlock = z.output<typeof essentialsSchema>["essentials"]
|
||||||
|
|
||||||
export type Hero = z.output<typeof heroSchema>
|
export type Hero = z.output<typeof heroSchema>
|
||||||
|
|||||||
Reference in New Issue
Block a user