'use client'; import { useEffect } from 'react'; import { BarChart3 } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { Card } from '@/components/ui/Card'; import { useConsentStore } from '@/stores/consent'; /** * The "change your mind later" the Cookie Policy promises, rendered at the * bottom of /cookies. Shows the current analytics decision and lets the user * flip it — effective immediately, no reload: every pageview is an explicit, * consent-gated call (see `Analytics`), so withdrawing consent simply stops * the calls. * * On deployments without analytics configured it says so instead of offering * a toggle for something that does not exist. */ export function ConsentManager({ analyticsAvailable }: { analyticsAvailable: boolean }) { const hydrated = useConsentStore((state) => state.hydrated); const analytics = useConsentStore((state) => state.analytics); const hydrate = useConsentStore((state) => state.hydrate); const decide = useConsentStore((state) => state.decide); useEffect(() => { hydrate(); }, [hydrate]); // Same reason as the notice: rendering before localStorage is read would // mismatch the server-rendered markup. if (!hydrated) return null; return (

Your analytics choice

{analyticsAvailable ? ( <>

Analytics is currently{' '} {analytics ? 'on' : 'off'} {' '} for this browser. It counts visits to our public pages only — self-hosted, cookieless, anonymous. Change it any time; the change takes effect immediately.

{analytics ? ( ) : ( )}
) : (

Analytics is not enabled on this deployment. There is nothing to opt in to.

)}
); }