// Privacy consent UI — banner + preferences modal + floating trigger // Uses window.KDC_CONSENT for state, useI18n() for strings. const CONSENT_I18N = { en: { bannerTitle: "Your privacy, your choice.", bannerBody: "We use essential cookies to run this site and, with your consent, analytics and marketing cookies to improve it. California residents: you have the right to opt out of the sale or sharing of your personal information.", accept: "Accept all", reject: "Reject non-essential", manage: "Manage preferences", policy: "Privacy policy", // modal modalTitle: "Privacy preferences", modalIntro: "Choose which categories of cookies and data processing you allow. You can change these any time.", essentialH: "Essential", essentialB: "Required for core site functionality — navigation, form submission, security. Always on.", analyticsH: "Analytics", analyticsB: "Aggregate, anonymized usage data that helps us improve pages, fix issues, and understand traffic.", marketingH: "Marketing", marketingB: "Advertising and retargeting cookies that may personalize ads on other sites you visit.", dnsH: "Do Not Sell or Share My Personal Information", dnsB: "California (CCPA/CPRA) right: opt out of the sale or sharing of personal information with third parties.", on: "On", off: "Off", save: "Save preferences", acceptAll: "Accept all", rejectAll: "Reject non-essential", close: "Close", footer: "Learn more in our", trigger: "Privacy choices", formNotice: "By submitting, you agree to our", formNoticeMid: "and consent to being contacted about your project.", }, es: { bannerTitle: "Tu privacidad, tu decisión.", bannerBody: "Usamos cookies esenciales para operar este sitio y, con tu consentimiento, cookies de análisis y marketing para mejorarlo. Residentes de California: tienes derecho a optar por no vender o compartir tu información personal.", accept: "Aceptar todas", reject: "Rechazar no esenciales", manage: "Gestionar preferencias", policy: "Política de privacidad", modalTitle: "Preferencias de privacidad", modalIntro: "Elige qué categorías de cookies y procesamiento de datos permites. Puedes cambiarlo en cualquier momento.", essentialH: "Esenciales", essentialB: "Necesarias para el funcionamiento básico — navegación, envío de formularios, seguridad. Siempre activas.", analyticsH: "Analíticas", analyticsB: "Datos de uso agregados y anónimos que nos ayudan a mejorar páginas, corregir errores y entender el tráfico.", marketingH: "Marketing", marketingB: "Cookies de publicidad y remarketing que pueden personalizar anuncios en otros sitios que visites.", dnsH: "No Vender ni Compartir Mi Información Personal", dnsB: "Derecho bajo California (CCPA/CPRA): optar por no vender o compartir información personal con terceros.", on: "Activado", off: "Desactivado", save: "Guardar preferencias", acceptAll: "Aceptar todas", rejectAll: "Rechazar no esenciales", close: "Cerrar", footer: "Más información en nuestra", trigger: "Privacidad", formNotice: "Al enviar, aceptas nuestra", formNoticeMid: "y consientes que te contactemos sobre tu proyecto.", } }; window.CONSENT_I18N = CONSENT_I18N; function ConsentUI() { const { lang } = useI18n(); const s = CONSENT_I18N[lang]; const [state, setState] = React.useState(() => window.KDC_CONSENT.get()); const [showBanner, setShowBanner] = React.useState(false); const [showModal, setShowModal] = React.useState(false); React.useEffect(() => { const current = window.KDC_CONSENT.get(); setState(current); if (!current.decided) { const t = setTimeout(() => setShowBanner(true), 400); return () => clearTimeout(t); } }, []); React.useEffect(() => { const onOpen = () => { setShowModal(true); setShowBanner(false); }; const onChange = () => setState(window.KDC_CONSENT.get()); window.addEventListener('kdc-consent-open', onOpen); window.addEventListener('kdc-consent-change', onChange); return () => { window.removeEventListener('kdc-consent-open', onOpen); window.removeEventListener('kdc-consent-change', onChange); }; }, []); const acceptAll = () => { window.KDC_CONSENT.set({ analytics: true, marketing: true, doNotSell: false }); setShowBanner(false); setShowModal(false); }; const rejectAll = () => { window.KDC_CONSENT.set({ analytics: false, marketing: false, doNotSell: true }); setShowBanner(false); setShowModal(false); }; const savePrefs = () => { window.KDC_CONSENT.set(state); setShowBanner(false); setShowModal(false); }; return ( <> {/* Banner */} {showBanner && !showModal && (
{s.bannerBody} {s.policy} →
{s.modalIntro}