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:
Erik Tiekstra
2025-07-04 10:15:01 +00:00
parent fa7214cb58
commit 270249c6c4
44 changed files with 187 additions and 115 deletions

View File

@@ -24,6 +24,7 @@ import styles from "./campaignHotelListing.module.css"
interface CampaignHotelListingClientProps {
heading: string
preamble?: string | null
bookingCode?: string | null
visibleCountMobile: 3 | 6
visibleCountDesktop: 3 | 6
isMainBlock: boolean
@@ -35,6 +36,7 @@ export default function CampaignHotelListingClient({
visibleCountMobile,
visibleCountDesktop,
isMainBlock,
bookingCode,
}: CampaignHotelListingClientProps) {
const intl = useIntl()
const isMobile = useMediaQuery("(max-width: 767px)")
@@ -119,16 +121,24 @@ export default function CampaignHotelListingClient({
) : null}
</header>
<ul className={styles.list}>
{activeHotels.map(({ hotel, url }, index) => (
<li
key={hotel.id}
className={cx(styles.listItem, {
[styles.hidden]: index >= visibleCount,
})}
>
<HotelListingItem hotel={hotel} url={url} />
</li>
))}
{activeHotels.map(({ hotel, url }, index) => {
const urlWithOptionalBookingCode = bookingCode
? `${url}?bookingCode=${bookingCode}`
: url
return (
<li
key={hotel.id}
className={cx(styles.listItem, {
[styles.hidden]: index >= visibleCount,
})}
>
<HotelListingItem
hotel={hotel}
url={urlWithOptionalBookingCode}
/>
</li>
)
})}
</ul>
{showButton ? (

View File

@@ -19,6 +19,7 @@ interface CampaignHotelListingProps {
heading: string
preamble?: string | null
hotelIds: string[]
bookingCode?: string | null
visibleCountMobile?: 3 | 6
visibleCountDesktop?: 3 | 6
isMainBlock?: boolean
@@ -28,6 +29,7 @@ export default async function CampaignHotelListing({
heading,
preamble,
hotelIds,
bookingCode,
visibleCountMobile = 3,
visibleCountDesktop = 6,
isMainBlock = false,
@@ -66,6 +68,7 @@ export default async function CampaignHotelListing({
<CampaignHotelListingClient
heading={heading}
preamble={preamble}
bookingCode={bookingCode}
visibleCountMobile={visibleCountMobile}
visibleCountDesktop={visibleCountDesktop}
isMainBlock={isMainBlock}

View File

@@ -1,6 +1,6 @@
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 CarouselCards from "@/components/Blocks/CarouselCards"

View File

@@ -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 CarouselCards from "@/components/Blocks/CarouselCards"

View File

@@ -1,6 +1,6 @@
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 CampaignHotelListing from "@/components/Blocks/CampaignHotelListing"
@@ -8,7 +8,11 @@ import CampaignHotelListingSkeleton from "@/components/Blocks/CampaignHotelListi
import CarouselCards from "@/components/Blocks/CarouselCards"
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) {
return blocks.map(async (block) => {
@@ -39,6 +43,7 @@ export default function Blocks({ blocks }: BlocksProps) {
heading={block.hotel_listing.heading}
hotelIds={block.hotel_listing.hotelIds}
isMainBlock={true}
bookingCode={block.hotel_listing.bookingCode}
/>
</Suspense>
)

View File

@@ -1,6 +1,6 @@
"use client"
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
import { BlocksEnums } from "@scandic-hotels/trpc/types/blocksEnum"
import { useDestinationDataStore } from "@/stores/destination-data"

View File

@@ -1,5 +1,5 @@
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"

View File

@@ -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 Overview from "@/components/Blocks/DynamicContent/Overview"

View File

@@ -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 DynamicContent from "@/components/Blocks/DynamicContent"
@@ -8,7 +8,6 @@ import { getLang } from "@/i18n/serverContext"
import { modWebviewLink } from "@/utils/webviews"
import type { BlocksProps } from "@/types/components/blocks"
// import { BlocksEnums } from "@scandic-hotels/trpc/types/blocks"
export default async function Blocks({ blocks }: BlocksProps) {
const lang = await getLang()

View File

@@ -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"> {}

View File

@@ -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"> {}

View File

@@ -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
extends Pick<CarouselCards, "carousel_cards"> {}

View File

@@ -1,4 +1,4 @@
import type { DynamicContent } from "@/types/trpc/routers/contentstack/blocks"
import type { DynamicContent } from "@scandic-hotels/trpc/types/blocks"
interface PartialDynamicContent
extends Pick<DynamicContent, "dynamic_content"> {}

View File

@@ -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 {
heading?: string

View File

@@ -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 {}

View File

@@ -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 {
data: TableData

View File

@@ -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"> {}

View File

@@ -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 type UspIcon = UspGrid["usp_grid"]["usp_card"][number]["icon"]

View File

@@ -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 {
hotelData: HotelListingHotelData

View File

@@ -1,10 +1,9 @@
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 { Dispatch, SetStateAction } from "react"
import type { z } from "zod"
import type { DynamicContent } from "@/types/trpc/routers/contentstack/blocks"
export interface AccountPageContentProps
extends Pick<DynamicContent, "dynamic_content"> {}

View File

@@ -1,9 +1,9 @@
import type { TeaserCard } from "@scandic-hotels/trpc/types/blocks"
import type { ImageVaultAsset } from "@scandic-hotels/trpc/types/imageVault"
import type { VariantProps } from "class-variance-authority"
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
import type { teaserCardVariants } from "@/components/TempDesignSystem/TeaserCard/variants"
import type { TeaserCard } from "../trpc/routers/contentstack/blocks"
interface SidePeekButton {
call_to_action_text: string

View File

@@ -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> {}