import React, { useEffect, useState } from 'react'; import { __, sprintf } from '@wordpress/i18n'; import { useSettings } from '../useSettings'; import { api } from '../api'; import { Card, Button, Badge, Notice, Switch, Segmented, Field, PageState } from './ui'; /** * GDPR / consent settings — the whole consent manager on one screen. * * Left: posture, layout, categories, texts. Right: a live mock of the banner * that re-renders from the same values, so nobody has to open the front end * in a private window to see what a wording change looks like. */ export default function ConsentPanel() { const { data, s, update, save, busy, saved, error } = useSettings('/settings/analytics'); if (!data) return ; const region = s.consent_region || 'eu'; return (
{error && {error}} {saved && ✓ {__('Saved', 'ai-rank-suite')}} update({ consent_enabled: v })} label={s.consent_enabled ? __('Banner on', 'ai-rank-suite') : __('Banner off', 'ai-rank-suite')} />
} >
update({ consent_region: v })} options={[ { id: 'eu', label: __('EU opt-in', 'ai-rank-suite') }, { id: 'us', label: __('US opt-out', 'ai-rank-suite') }, { id: 'auto', label: __('Auto by visitor', 'ai-rank-suite') }, ]} />
update({ consent_layout: v })} options={[{ id: 'card', label: __('Card', 'ai-rank-suite') }, { id: 'bar', label: __('Bar', 'ai-rank-suite') }]} /> update({ consent_position: v })} options={[{ id: 'left', label: __('Left', 'ai-rank-suite') }, { id: 'right', label: __('Right', 'ai-rank-suite') }]} /> update({ consent_theme: v })} options={[{ id: 'auto', label: __('Auto', 'ai-rank-suite') }, { id: 'light', label: __('Light', 'ai-rank-suite') }, { id: 'dark', label: __('Dark', 'ai-rank-suite') }]} />
{__('Categories & signals', 'ai-rank-suite')}
{}} /> {}} /> update({ consent_marketing: v })} label={__('Marketing — show a category for ad and remarketing pixels you add via snippets', 'ai-rank-suite')} /> update({ consent_gcm: v })} label={__('Google Consent Mode v2 — default denied under opt-in, updated live on choice, so GA4 keeps modelled data', 'ai-rank-suite')} /> update({ consent_reopen: v })} label={__('Persistent reopen control (🍪 button in EU, “Do not sell or share” link in US)', 'ai-rank-suite')} />
update({ consent_title: e.target.value })} /> update({ consent_policy: e.target.value })} />