Files
Erik Tiekstra 0cda37808e 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
2026-02-03 15:28:23 +00:00

58 lines
1.3 KiB
TypeScript

import { cx } from "class-variance-authority"
import { nodesToHtml } from "./utils"
import styles from "./jsontohtml.module.css"
import { ImageVaultAsset } from "@scandic-hotels/common/utils/imageVault"
import { ContentBlockType } from "./types/rte/enums"
import type { RTENode } from "./types/rte/node"
import type { RenderOptions } from "./types/rte/option"
export type Node<T> = {
node: T
}
export type Embeds =
| {
__typename: Exclude<ContentBlockType, "ImageContainer">
system?: { uid: string } | null
url?: string | null
permanent_url?: string | null
title?: string | null
}
| {
__typename: "ImageContainer"
system?: { uid: string } | null
url?: string | null
title?: string | null
image_left?: ImageVaultAsset
image_right?: ImageVaultAsset
}
export type EmbedByUid = Record<string, Node<Embeds>>
export type JsonToHtmlProps = {
embeds: Node<Embeds>[]
nodes: RTENode[]
renderOptions?: RenderOptions
className?: string
}
export function JsonToHtml({
embeds,
nodes,
renderOptions = {},
className,
}: JsonToHtmlProps) {
if (!Array.isArray(nodes) || !nodes.length) {
return null
}
return (
<section className={cx(styles.container, className)}>
{nodesToHtml(nodes, embeds, renderOptions).filter(Boolean)}
</section>
)
}