Files
web/apps/scandic-web/app/[lang]/(live)/(protected)/my-pages/layout.tsx
Matilda Landström 26f3b5bdd0 Merged in feat/LOY-484-consent-alert (pull request #3184)
feat(LOY-484): Change toast to alert for Profiling Consent

* feat(LOY-484): change toast to alert using context

* refactor(LOY-484): remove uneccesary code

* chore(LOY-484): small UI fixes


Approved-by: Chuma Mcphoy (We Ahead)
2025-11-26 12:13:04 +00:00

70 lines
2.2 KiB
TypeScript

import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
import {
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"
export default async function MyPagesLayout({
breadcrumbs,
children,
}: React.PropsWithChildren<{
breadcrumbs: React.ReactNode
}>) {
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()
return (
<ProfilingConsentAlertProvider>
<div className={styles.container}>
<div className={styles.layout}>
{breadcrumbs}
<div className={styles.content}>
<ProfilingConsentAlert />
{children}
</div>
</div>
{eurobonusMembership && <SASLevelUpgradeCheck />}
<Surprises />
{memberKey && profilingConsent && !hasConsent ? (
<>
<ProfilingConsentModal
memberKey={memberKey}
content={profilingConsent.modal}
iconIdentifier={profilingConsent.icon}
/>
<TrackingSDK
pageData={{ domainLanguage: lang, ...ModalTracking }}
/>
</>
) : null}
</div>
</ProfilingConsentAlertProvider>
)
}