diff --git a/src/app/(frontend)/[locale]/layout.tsx b/src/app/(frontend)/[locale]/layout.tsx index d66dcde..4d0a077 100644 --- a/src/app/(frontend)/[locale]/layout.tsx +++ b/src/app/(frontend)/[locale]/layout.tsx @@ -7,7 +7,6 @@ import { } from '@intecion/ipal-kit' import { ConsentProvider, - CookieBanner, CookieButton, Analytics, } from '@intecion/ipal-kit/client' @@ -16,6 +15,7 @@ import { getCachedPayload, getConfiguredLocales } from '@/lib/content' import { getSettings } from '@/lib/payload' import { Header, type NavItem } from '@/components/Header' import { Footer, type FooterNavItem } from '@/components/Footer' +import { CustomCookieBanner } from '@/components/CustomCookieBanner' import '../styles.css' import type { Company, Navigation, Page } from '@/payload-types' @@ -125,15 +125,7 @@ export default async function LocaleLayout({ children, params }: LayoutProps) { privacyHref={privacyHref} cookieHref={cookieHref} /> - + diff --git a/src/components/CustomCookieBanner.tsx b/src/components/CustomCookieBanner.tsx new file mode 100644 index 0000000..e2d2d00 --- /dev/null +++ b/src/components/CustomCookieBanner.tsx @@ -0,0 +1,159 @@ +'use client' + +import React, { useState, useEffect } from 'react' +import { Cookie, Check, ArrowRight } from 'lucide-react' +import { useConsentContext } from '@intecion/ipal-kit/client' + +const CONSENT_CATEGORIES = ['necessary', 'analytics', 'marketing'] as const +type ConsentCat = (typeof CONSENT_CATEGORIES)[number] + +export function CustomCookieBanner() { + const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext() + const [showSettings, setShowSettings] = useState(false) + const [choices, setChoices] = useState(state) + + useEffect(() => { + setChoices(state) + }, [state]) + + if (decided) { + return null + } + + const toggle = (cat: ConsentCat) => { + if (cat === 'necessary') return + setChoices((prev) => ({ + ...prev, + [cat]: !prev[cat], + })) + } + + return ( +
+
+ {!showSettings ? ( +
+
+
+ +
+
+

+ {texts.message}{' '} + {texts.privacyLink && ( + + {texts.privacyLink.label} + + )} +

+
+
+ +
+ + + +
+
+ ) : ( +
+
+
+ +
+

+ {texts.settingsTitle} +

+
+ +
    + {CONSENT_CATEGORIES.map((cat) => { + const isChecked = cat === 'necessary' ? true : !!choices[cat] + const isDisabled = cat === 'necessary' + const catData = texts.categories[cat] + + if (!catData) return null + + return ( +
  • !isDisabled && toggle(cat)} + className={`flex items-start justify-between gap-4 p-4 border border-[#333333] bg-[#262626] ${ + !isDisabled ? 'cursor-pointer hover:border-[#FFED00]' : 'opacity-90' + } transition-colors`} + > +
    +
    + {catData.title} +
    +

    + {catData.description} +

    +
    + + {/* Custom Kärcher Checkbox */} +
    +
    + +
    +
    +
  • + ) + })} +
+ +
+ + +
+
+ )} +
+
+ ) +}