import React, { useState } from 'react'; import { Button, IconButton, Tooltip, Dialog, DialogTitle, DialogContent, DialogActions, Typography, Box, Divider, RadioGroup, Radio, FormControlLabel, FormControl, FormLabel } from '@mui/material'; import CookieIcon from '@mui/icons-material/Cookie'; import consentService, { CONSENT_LEVELS } from '../services/consentService'; /** * Button to open cookie settings dialog * Can be placed in the footer or other accessible areas of the app */ const CookieSettingsButton = ({ variant = 'text', icon = false, label = 'Cookie Settings' }) => { const [open, setOpen] = useState(false); const [consentLevel, setConsentLevel] = useState(() => { const storedConsent = consentService.getStoredConsent(); return storedConsent?.level || CONSENT_LEVELS.NECESSARY; }); const handleOpen = () => { setOpen(true); }; const handleClose = () => { setOpen(false); }; const handleConsentLevelChange = (event) => { setConsentLevel(event.target.value); }; const handleSave = () => { consentService.saveConsent(consentLevel); setOpen(false); }; const handleAcceptAll = () => { const allConsent = CONSENT_LEVELS.ALL; setConsentLevel(allConsent); consentService.saveConsent(allConsent); setOpen(false); }; const handleNecessaryOnly = () => { const necessaryOnly = CONSENT_LEVELS.NECESSARY; setConsentLevel(necessaryOnly); consentService.saveConsent(necessaryOnly); setOpen(false); }; // Render as icon button or regular button if (icon) { return ( <> {renderDialog()} ); } return ( <> {renderDialog()} ); function renderDialog() { return ( Cookie Settings We use cookies to enhance your browsing experience, provide personalized content, and analyze our traffic. You can adjust your privacy settings below. Privacy Settings } label={ Necessary Cookies Only Essential cookies required for basic website functionality. These cannot be disabled. } /> } label={ Functional Cookies Cookies that remember your preferences and enhance website functionality. } /> } label={ Analytics Cookies Cookies that help us understand how you use our website and improve your experience. This includes Microsoft Clarity for analyzing site usage patterns. } /> } label={ All Cookies Accept all cookies including analytics, marketing, and third-party cookies. } /> You can change these settings at any time by clicking on the Cookie Settings link in the footer. ); } }; export default CookieSettingsButton;