Merged in fix/BOOK-755-alert-content (pull request #3523)

fix(BOOK-755, BOOK-787): Fixed issue for phone number and sidepeeks not showing

* fix(BOOK-755): Fixed issue for phone number and sidepeeks not showing

* fix(BOOK-755): fix issue phonenumber alert

* fix(BOOK-755): fix issue phonenumber


Approved-by: Matilda Landström
This commit is contained in:
Erik Tiekstra
2026-02-03 15:28:23 +00:00
committed by Bianca Widstam
parent b3c4761ae5
commit 0cda37808e
5 changed files with 20 additions and 43 deletions

View File

@@ -1,13 +1,29 @@
import { Alert } from "@scandic-hotels/design-system/Alert"
import { getAlertPhoneContactData } from "@scandic-hotels/trpc/routers/contentstack/base/utils"
import { serverClient } from "@/lib/trpc/server"
import type { AlertBlock } from "@scandic-hotels/trpc/types/blocks"
interface AlertBlockProps extends Pick<AlertBlock, "alert"> {}
export function AlertBlock({ alert }: AlertBlockProps) {
export async function AlertBlock({ alert }: AlertBlockProps) {
const caller = await serverClient()
const contactConfig = await caller.contentstack.base.contact()
if (!alert) {
return null
}
return <Alert {...alert} />
const phoneContact =
alert.phoneContact && contactConfig
? getAlertPhoneContactData(alert, contactConfig)
: null
return (
<Alert
{...alert}
phoneContact={phoneContact}
sidepeekCtaText={alert.sidepeekButton?.cta_text}
/>
)
}

View File

@@ -4,9 +4,7 @@ import { nodesToHtml } from "./utils"
import styles from "./jsontohtml.module.css"
import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
import { ImageVaultAsset } from "@scandic-hotels/common/utils/imageVault"
import { AlertSidepeekContent } from "../../types/sidepeekContent"
import { ContentBlockType } from "./types/rte/enums"
import type { RTENode } from "./types/rte/node"
import type { RenderOptions } from "./types/rte/option"
@@ -17,7 +15,7 @@ export type Node<T> = {
export type Embeds =
| {
__typename: Exclude<ContentBlockType, "ImageContainer" | "Alert">
__typename: Exclude<ContentBlockType, "ImageContainer">
system?: { uid: string } | null
url?: string | null
permanent_url?: string | null
@@ -31,25 +29,6 @@ export type Embeds =
image_left?: ImageVaultAsset
image_right?: ImageVaultAsset
}
| {
__typename: "Alert"
system?: { uid: string } | null
type: AlertTypeEnum
heading: string | null
text: string
phoneContact?: {
displayText: string
phoneNumber: string
footnote?: string | null
} | null
sidepeekContent?: AlertSidepeekContent | null
sidepeekCtaText?: string | null
link?: {
url: string
title: string
keepSearchParams?: boolean
} | null
}
export type EmbedByUid = Record<string, Node<Embeds>>

View File

@@ -20,7 +20,6 @@ import {
mapImageVaultAssetResponseToImageVaultAsset,
mapInsertResponseToImageVaultAsset,
} from "@scandic-hotels/common/utils/imageVault"
import { Alert } from "../Alert"
import { TextLink } from "../TextLink"
import type { EmbedByUid } from "./JsonToHtml"
import type { Attributes } from "./types/rte/attrs"
@@ -459,8 +458,6 @@ export const renderOptions: RenderOptions = {
)
}
return null
} else if (entry?.node.__typename === "Alert") {
return <Alert key={node.uid} {...entry.node} />
} else if (
entry?.node.__typename === "AccountPage" ||
entry?.node.__typename === "CampaignOverviewPage" ||

View File

@@ -1,6 +1,5 @@
import { gql } from "graphql-tag"
import { Alert } from "../Alert.graphql"
import { ImageContainer } from "../ImageContainer.graphql"
import { AccountPageLink } from "../PageLink/AccountPageLink.graphql"
import { CampaignOverviewPageLink } from "../PageLink/CampaignOverviewPageLink.graphql"
@@ -25,7 +24,6 @@ export const Content_ContentPage = gql`
node {
__typename
...SysAsset
...Alert
...ImageContainer
...AccountPageLink
...CampaignOverviewPageLink
@@ -47,7 +45,6 @@ export const Content_ContentPage = gql`
}
}
${SysAsset}
${Alert}
${ImageContainer}
${AccountPageLink}
${CampaignOverviewPageLink}

View File

@@ -1,8 +1,6 @@
import { z } from "zod"
import { BlocksEnums } from "../../../../types/blocksEnum"
import { ContentEnum } from "../../../../types/content"
import { alertSchema, transformAlertSchema } from "../alert"
import { rawLinkUnionSchema, transformPageLink } from "../pageLinks"
import { imageContainerSchema } from "./imageContainer"
import { sysAssetSchema } from "./sysAsset"
@@ -24,11 +22,7 @@ export const contentSchema = z.object({
.discriminatedUnion("__typename", [
imageContainerSchema,
sysAssetSchema,
alertSchema.merge(
z.object({
__typename: z.literal(ContentEnum.blocks.Alert),
})
),
...rawLinkUnionSchema.options,
])
.transform((data) => {
@@ -36,12 +30,6 @@ export const contentSchema = z.object({
if (link) {
return link
}
if (data.__typename === ContentEnum.blocks.Alert) {
return {
__typename: data.__typename,
...transformAlertSchema(data),
}
}
return data
}),
})