import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X, Cookie, Shield, Settings } from 'lucide-react'; import { Button } from './ui/button'; export const CookieConsent = () => { const [isVisible, setIsVisible] = useState(false); const [showSettings, setShowSettings] = useState(false); useEffect(() => { // Check if user has already made a choice const consent = localStorage.getItem('cookieConsent'); if (!consent) { // Show banner after a short delay const timer = setTimeout(() => { setIsVisible(true); }, 1000); return () => clearTimeout(timer); } }, []); const handleAcceptAll = () => { localStorage.setItem('cookieConsent', 'accepted'); localStorage.setItem('cookiePreferences', JSON.stringify({ necessary: true, analytics: true, marketing: true, functional: true })); setIsVisible(false); }; const handleDeclineAll = () => { localStorage.setItem('cookieConsent', 'declined'); localStorage.setItem('cookiePreferences', JSON.stringify({ necessary: true, analytics: false, marketing: false, functional: false })); setIsVisible(false); }; const handleSavePreferences = () => { localStorage.setItem('cookieConsent', 'customized'); // In a real app, you would save the specific preferences here setIsVisible(false); setShowSettings(false); }; const handleClose = () => { setIsVisible(false); }; if (!isVisible) return null; return (
{!showSettings ? ( // Main Cookie Consent Banner
{/* Icon and Message */}

We use cookies to enhance your experience

We use cookies to analyze site performance, deliver personalized content, and improve your browsing experience. By clicking "Accept All", you consent to our use of cookies.{' '} Learn more

{/* Action Buttons */}
{/* Close Button */}
) : ( // Cookie Settings Panel

Cookie Preferences

{/* Necessary Cookies */}

Necessary Cookies

These cookies are essential for the website to function properly. They cannot be disabled.

{/* Analytics Cookies */}

Analytics Cookies

Help us understand how visitors interact with our website by collecting anonymous information.

{/* Marketing Cookies */}

Marketing Cookies

Used to track visitors across websites to display relevant advertisements.

{/* Settings Action Buttons */}
)}
); };