import { Bell, BellOff, BellRing } from 'lucide-react'; import { useNotifications } from '../hooks/useNotifications'; interface NotificationSettingsProps { compact?: boolean; } export function NotificationSettings({ compact = false }: NotificationSettingsProps) { const { permission, requestPermission, isEnabled, setEnabled } = useNotifications(); const handleToggle = async () => { if (permission === 'unsupported') { return; } if (!isEnabled) { // Enabling - request permission if needed if (permission !== 'granted') { const granted = await requestPermission(); if (granted) { setEnabled(true); } } else { setEnabled(true); } } else { // Disabling setEnabled(false); } }; if (permission === 'unsupported') { return null; } const getIcon = () => { if (!isEnabled) return ; if (permission === 'denied') return ; return ; }; const getStatus = () => { if (permission === 'denied') return 'Blocked'; if (!isEnabled) return 'Off'; return 'On'; }; if (compact) { return ( ); } return (
Desktop Notifications
{permission === 'denied' ? 'Blocked by browser - enable in browser settings' : isEnabled ? 'Get notified when new best solutions are found' : 'Enable to receive optimization updates'}
); } export default NotificationSettings;