From d298d5c2ff38b22026088433342edfce35e09e57 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Thu, 9 Oct 2025 12:46:17 +0000 Subject: [PATCH] feat(BOOK-436): Added manage cookie bot dynamic content to content pages Approved-by: Linus Flood --- .../cookieConsentButton.module.css | 3 ++ .../CookieConsentButton/index.tsx | 36 +++++++++++++++++++ .../ManageCookieConsent/index.tsx | 30 ++++++++++++++++ .../Blocks/DynamicContent/index.tsx | 3 ++ apps/scandic-web/components/Sidebar/index.tsx | 3 ++ apps/scandic-web/types/window.d.ts | 10 +++--- packages/trpc/lib/types/dynamicContent.ts | 2 ++ 7 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/cookieConsentButton.module.css create mode 100644 apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/index.tsx create mode 100644 apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/index.tsx diff --git a/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/cookieConsentButton.module.css b/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/cookieConsentButton.module.css new file mode 100644 index 000000000..c7b33fbd6 --- /dev/null +++ b/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/cookieConsentButton.module.css @@ -0,0 +1,3 @@ +.cookieConsentButton { + justify-self: start; +} diff --git a/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/index.tsx new file mode 100644 index 000000000..fe6a957d1 --- /dev/null +++ b/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton/index.tsx @@ -0,0 +1,36 @@ +"use client" + +import { useIntl } from "react-intl" + +import { Button } from "@scandic-hotels/design-system/Button" +import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" + +import styles from "./cookieConsentButton.module.css" + +export function CookieConsentButton() { + const intl = useIntl() + + function handleClick() { + if (!window?.Cookiebot?.show) { + return + } + + window.Cookiebot.show() + } + + return ( + + ) +} diff --git a/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/index.tsx new file mode 100644 index 000000000..667ec0ea4 --- /dev/null +++ b/apps/scandic-web/components/Blocks/DynamicContent/ManageCookieConsent/index.tsx @@ -0,0 +1,30 @@ +import { CookieConsentButton } from "@/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton" +import SectionContainer from "@/components/Section/Container" +import SectionHeader from "@/components/Section/Header" +import SectionLink from "@/components/Section/Link" + +interface ManageCookieConsentProps { + title?: string + subtitle?: string + link?: { href: string; text: string } +} + +export function ManageCookieConsent({ + title, + subtitle, + link, +}: ManageCookieConsentProps) { + return ( + + + + + + ) +} diff --git a/apps/scandic-web/components/Blocks/DynamicContent/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/index.tsx index 7b6901632..1ee0bad5f 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/index.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/index.tsx @@ -5,6 +5,7 @@ import { DynamicContentEnum } from "@scandic-hotels/trpc/types/dynamicContent" import HowItWorks from "@/components/Blocks/DynamicContent/HowItWorks" import LoyaltyLevels from "@/components/Blocks/DynamicContent/LoyaltyLevels" +import { ManageCookieConsent } from "@/components/Blocks/DynamicContent/ManageCookieConsent" import MyPagesOverviewShortcuts from "@/components/Blocks/DynamicContent/MyPagesOverviewShortcuts" import Overview from "@/components/Blocks/DynamicContent/Overview" import OverviewTable from "@/components/Blocks/DynamicContent/OverviewTable" @@ -46,6 +47,8 @@ function DynamicContentBlocks(props: DynamicContentProps) { return case DynamicContentEnum.Blocks.components.jobylon_feed: return + case DynamicContentEnum.Blocks.components.manage_cookie_consent: + return case DynamicContentEnum.Blocks.components.loyalty_levels: return case DynamicContentEnum.Blocks.components.membership_overview: diff --git a/apps/scandic-web/components/Sidebar/index.tsx b/apps/scandic-web/components/Sidebar/index.tsx index 437825415..bbf16b78f 100644 --- a/apps/scandic-web/components/Sidebar/index.tsx +++ b/apps/scandic-web/components/Sidebar/index.tsx @@ -2,6 +2,7 @@ import { JsonToHtml } from "@scandic-hotels/design-system/JsonToHtml" import { DynamicContentEnum } from "@scandic-hotels/trpc/types/dynamicContent" import { SidebarEnums } from "@scandic-hotels/trpc/types/sidebar" +import { CookieConsentButton } from "@/components/Blocks/DynamicContent/ManageCookieConsent/CookieConsentButton" import EmployeeBenefitsAuthCard from "@/components/DigitalTeamMemberCard/EmployeeBenefits/AuthCard" import ShortcutsList from "../Blocks/ShortcutsList" @@ -33,6 +34,8 @@ export default function Sidebar({ blocks }: SidebarProps) { return ( ) + case DynamicContentEnum.Sidebar.components.cookie_consent_button: + return default: return null } diff --git a/apps/scandic-web/types/window.d.ts b/apps/scandic-web/types/window.d.ts index 58dfb4f4b..316f310ff 100644 --- a/apps/scandic-web/types/window.d.ts +++ b/apps/scandic-web/types/window.d.ts @@ -1,6 +1,6 @@ interface Window { dataLayer: { - [key: string]: any + [key: string]: unknown push: (...args: unknown) => void } adobeDataLayer: { @@ -10,12 +10,12 @@ interface Window { adobe: { OptInCategories: { ANALYTICS: string } optIn: { - approve: (s: string, b: boolean) => {} - deny: (s: string, b: boolean) => {} - complete: () => {} + approve: (s: string, b: boolean) => void + deny: (s: string, b: boolean) => void + complete: () => void } } - Cookiebot: { changed: boolean; consented: boolean } + Cookiebot: { changed: boolean; consented: boolean; show: () => void } ApplePaySession: (() => void) | undefined kindlyChat: { showBubble: () => void diff --git a/packages/trpc/lib/types/dynamicContent.ts b/packages/trpc/lib/types/dynamicContent.ts index 024c0d3aa..d45ba8265 100644 --- a/packages/trpc/lib/types/dynamicContent.ts +++ b/packages/trpc/lib/types/dynamicContent.ts @@ -25,6 +25,7 @@ export namespace DynamicContentEnum { sas_link_account_banner: "sas_link_account_banner", sas_transfer_points: "sas_transfer_points", sas_tier_comparison: "sas_tier_comparison", + manage_cookie_consent: "manage_cookie_consent", unknown: "unknown", } as const @@ -72,6 +73,7 @@ export namespace DynamicContentEnum { export const components = { my_pages_navigation: "my_pages_navigation", employee_benefits_auth_card: "employee_benefits_auth_card", + cookie_consent_button: "cookie_consent_button", unknown: "unknown", } as const