Files
Momento/memento-note/components/legal/cookie-consent-root.tsx
Antigravity 65e722a184
Some checks failed
CI / Lint, Test & Build (push) Waiting to run
Deploy to Production / Build and Deploy (push) Has been cancelled
fix: disable noisy lint rules, exclude .venv-i18n, 0 errors 0 warnings
2026-05-16 23:38:11 +00:00

32 lines
984 B
TypeScript

'use client'
import { useEffect, useState } from 'react'
import { OPEN_COOKIE_PREFERENCES_EVENT } from '@/lib/consent/cookie-consent'
import { useCookieConsent } from '@/hooks/use-cookie-consent'
import { CookieConsentBanner } from './cookie-consent-banner'
import { CookiePreferencesDialog } from './cookie-preferences-dialog'
export function CookieConsentRoot() {
const { needsBanner, ready } = useCookieConsent()
const [preferencesOpen, setPreferencesOpen] = useState(false)
useEffect(() => {
const open = () => setPreferencesOpen(true)
window.addEventListener(OPEN_COOKIE_PREFERENCES_EVENT, open)
return () => window.removeEventListener(OPEN_COOKIE_PREFERENCES_EVENT, open)
}, [])
if (!ready) return null
return (
<>
{needsBanner && (
<CookieConsentBanner
onManage={() => setPreferencesOpen(true)}
/>
)}
<CookiePreferencesDialog open={preferencesOpen} onOpenChange={setPreferencesOpen} />
</>
)
}