'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} )}
{catData.description}