import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK" import { getEurobonusMembership, scandicMembershipTypes, } from "@scandic-hotels/trpc/routers/user/helpers" import { env } from "@/env/server" import { getBasicProfileSafely, getProfileSafely, getProfilingConsent, } from "@/lib/trpc/memoizedRequests" import ProfilingConsentAlert from "@/components/MyPages/ProfilingConsent/Alert" import { ProfilingConsentAlertProvider } from "@/components/MyPages/ProfilingConsent/Alert/AlertContext" import ProfilingConsentModal from "@/components/MyPages/ProfilingConsent/Modal" import { userHasConsent } from "@/components/MyPages/ProfilingConsent/utils" import { SASLevelUpgradeCheck } from "@/components/MyPages/SASLevelUpgradeCheck" import Surprises from "@/components/MyPages/Surprises" import { getLang } from "@/i18n/serverContext" import { ModalTracking } from "@/utils/tracking/profilingConsent" import styles from "./layout.module.css" type MyPagesLayoutProps = React.PropsWithChildren<{ breadcrumbs: React.ReactNode }> export default async function MyPagesLayout(props: MyPagesLayoutProps) { if (env.ENABLE_PROFILE_CONSENT) { return } return } async function MyPagesLayoutWithConsent({ breadcrumbs, children, }: MyPagesLayoutProps) { const profile = await getProfileSafely() const eurobonusMembership = profile?.loyalty ? getEurobonusMembership(profile.loyalty) : null const memberKey = profile?.membership?.membershipNumber || profile?.profileId || "" const profilingConsentData = await getProfilingConsent() const profilingConsent = profilingConsentData?.profiling_consent const hasConsent = userHasConsent(profile?.profilingConsent) const lang = await getLang() const showConsentModal = memberKey && profilingConsent && !hasConsent return (
{breadcrumbs}
{children}
{eurobonusMembership && } {showConsentModal && ( <> )}
) } async function MyPagesLayoutBase({ breadcrumbs, children, }: MyPagesLayoutProps) { const profile = await getBasicProfileSafely() const eurobonusMembership = profile?.loyalty?.memberships?.find( (m) => m.membershipType === scandicMembershipTypes.SAS_EB ) return (
{breadcrumbs}
{children}
{eurobonusMembership && }
) }