'use client' import React, { useState, useEffect } from 'react' import { Cookie, Check, X } from 'lucide-react' import { useConsentContext } from '@intecion/ipal-kit/client' const CONSENT_CATEGORIES = ['necessary', 'functional', '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]) // Lock background page scroll while settings modal is open useEffect(() => { if (showSettings) { const originalOverflow = document.body.style.overflow document.body.style.overflow = 'hidden' return () => { document.body.style.overflow = originalOverflow } } }, [showSettings]) if (decided) { return null } const toggle = (cat: ConsentCat) => { if (cat === 'necessary') return setChoices((prev) => ({ ...prev, [cat]: !prev[cat], })) } const handleSave = () => { savePreferences(choices) setShowSettings(false) } const handleAcceptAll = () => { acceptAll() setShowSettings(false) } const handleRejectAll = () => { rejectAll() setShowSettings(false) } return ( <> {/* 1. Compact Bottom Banner */} {!showSettings && (

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

)} {/* 2. Modal Window for Cookie Settings */} {showSettings && (
{ if (e.target === e.currentTarget) setShowSettings(false) }} onWheel={(e) => e.stopPropagation()} >
e.stopPropagation()} > {/* Modal Header */}

{texts.settingsTitle}

{/* Scrollable Categories List */}
{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-[#363032] bg-[#2d2728] ${ !isDisabled ? 'cursor-pointer hover:border-primary' : 'opacity-90' } transition-colors`} >
{catData.title}

{catData.description}

{/* Custom Checkbox */}
) })}
{/* Modal Footer Buttons */}
)} ) }