import { useState, useEffect } from 'react'; import ReactDOM from 'react-dom'; import { useAuth } from '../../contexts/AuthContext'; export interface SeoConsentModalProps { onClose: () => void; } const SeoConsentModal = ({ onClose }: SeoConsentModalProps) => { const { seoConsent, updateSeoConsent } = useAuth(); const [isEnabled, setIsEnabled] = useState(seoConsent); const [isSubmitting, setIsSubmitting] = useState(false); useEffect(() => { setIsEnabled(seoConsent); }, [seoConsent]); const toggleConsent = async () => { if (isSubmitting) return; const newValue = !isEnabled; setIsEnabled(newValue); // Optimistic update setIsSubmitting(true); try { await updateSeoConsent(newValue); } catch (error) { console.error("Failed to update consent:", error); setIsEnabled(!newValue); // Revert on error } finally { setIsSubmitting(false); } }; const modalContent = (

Content Usage Preference

How We Use Your Conversations

To help the WordPress community, we may publish anonymized versions of helpful conversations as articles.

  • All personal information is removed.
  • Your questions and our solutions become a resource for others.
  • You can change this setting at any time.

Your choice is saved automatically.

); return ReactDOM.createPortal(modalContent, document.body); }; export default SeoConsentModal;