'use client' import { useEffect, useState } from 'react' import { useLanguage } from '@/lib/i18n' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { getConsent, setConsent } from '@/lib/consent/cookie-consent' import { toast } from 'sonner' interface CookiePreferencesDialogProps { open: boolean onOpenChange: (open: boolean) => void } export function CookiePreferencesDialog({ open, onOpenChange }: CookiePreferencesDialogProps) { const { t } = useLanguage() const [analytics, setAnalytics] = useState(false) useEffect(() => { if (!open) return const current = getConsent() setAnalytics(current?.analytics ?? false) }, [open]) const handleSave = () => { setConsent({ analytics, marketing: false }) toast.success(t('consent.preferences.saved')) onOpenChange(false) } return ( {t('consent.preferences.title')} {t('consent.preferences.description')} onOpenChange(false)} className="px-5 py-2.5 text-[10px] font-bold uppercase tracking-[0.2em] text-concrete hover:text-ink transition-colors" > {t('common.cancel')} {t('consent.preferences.save')} ) } function CategoryRow({ title, description, checked, onChange, locked, }: { title: string description: string checked: boolean onChange?: (v: boolean) => void locked?: boolean }) { return ( {title} {description} {locked && ( {title.includes('—') ? '' : ''} )} onChange?.(e.target.checked)} /> ) } /** Avoid pulling motion into dialog — plain wrapper */ function motionless({ children, className }: { children: React.ReactNode; className?: string }) { return {children} }
{title}
{description}
{title.includes('—') ? '' : ''}