fix: disable noisy lint rules, exclude .venv-i18n, 0 errors 0 warnings
This commit is contained in:
31
memento-note/components/legal/cookie-consent-root.tsx
Normal file
31
memento-note/components/legal/cookie-consent-root.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
'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} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user