'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 ? (
) : (
{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 */}
)
})}
)}
)
}