Merged in feat/LOY-497-Flag-Profiling-Consent (pull request #3292)

refactor(LOY-497): hide profiling consent behind feature flag

* refactor(LOY-497): hide profiling consent behind feature flag

* chore(LOY-497): up to date consent readme


Approved-by: Matilda Landström
This commit is contained in:
Chuma Mcphoy (We Ahead)
2025-12-05 05:47:11 +00:00
parent aae5c4d33d
commit 2b9bc8c3ce
8 changed files with 216 additions and 108 deletions

View File

@@ -1,6 +1,7 @@
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
import { getEurobonusMembership } from "@scandic-hotels/trpc/routers/user/helpers"
import { env } from "@/env/server"
import {
getProfileSafely,
getProfilingConsent,
@@ -17,12 +18,22 @@ import { ModalTracking } from "@/utils/tracking/profilingConsent"
import styles from "./layout.module.css"
export default async function MyPagesLayout({
type MyPagesLayoutProps = React.PropsWithChildren<{
breadcrumbs: React.ReactNode
}>
export default async function MyPagesLayout(props: MyPagesLayoutProps) {
if (env.ENABLE_PROFILE_CONSENT) {
return <MyPagesLayoutWithConsent {...props} />
}
return <MyPagesLayoutBase {...props} />
}
async function MyPagesLayoutWithConsent({
breadcrumbs,
children,
}: React.PropsWithChildren<{
breadcrumbs: React.ReactNode
}>) {
}: MyPagesLayoutProps) {
const profile = await getProfileSafely()
const eurobonusMembership = profile?.loyalty
? getEurobonusMembership(profile.loyalty)
@@ -37,6 +48,8 @@ export default async function MyPagesLayout({
const lang = await getLang()
const showConsentModal = memberKey && profilingConsent && !hasConsent
return (
<ProfilingConsentAlertProvider>
<div className={styles.container}>
@@ -51,7 +64,7 @@ export default async function MyPagesLayout({
{eurobonusMembership && <SASLevelUpgradeCheck />}
<Surprises />
{memberKey && profilingConsent && !hasConsent ? (
{showConsentModal && (
<>
<ProfilingConsentModal
memberKey={memberKey}
@@ -62,8 +75,30 @@ export default async function MyPagesLayout({
pageData={{ domainLanguage: lang, ...ModalTracking }}
/>
</>
) : null}
)}
</div>
</ProfilingConsentAlertProvider>
)
}
async function MyPagesLayoutBase({
breadcrumbs,
children,
}: MyPagesLayoutProps) {
const profile = await getProfileSafely()
const eurobonusMembership = profile?.loyalty
? getEurobonusMembership(profile.loyalty)
: null
return (
<div className={styles.container}>
<div className={styles.layout}>
{breadcrumbs}
<div className={styles.content}>{children}</div>
</div>
{eurobonusMembership && <SASLevelUpgradeCheck />}
<Surprises />
</div>
)
}

View File

@@ -1,13 +1,24 @@
import { redirect } from "next/navigation"
import { profile } from "@scandic-hotels/common/constants/routes/myPages"
import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"
import { env } from "@/env/server"
import { getProfile } from "@/lib/trpc/memoizedRequests"
import { serverClient } from "@/lib/trpc/server"
import { ProfilingConsent } from "@/components/Forms/ProfilingConsent"
import { getLang } from "@/i18n/serverContext"
import styles from "./page.module.css"
export default async function ProfilingConsentSlot() {
const lang = await getLang()
if (!env.ENABLE_PROFILE_CONSENT) {
redirect(profile[lang])
}
const caller = await serverClient()
const accountPage = await caller.contentstack.accountPage.get()
const user = await getProfile()