import { useState } from 'react'; import { Bell, BellOff, Settings, X, Send, Hammer, Coins, AlertCircle, Info, } from 'lucide-react'; import { useNotificationsStore, NotificationType, requestNotificationPermission, } from '../store/notifications'; interface NotificationsPanelProps { isOpen: boolean; onClose: () => void; } const TYPE_ICONS: Record = { transaction: , mining: , staking: , system: , price: , }; export default function NotificationsPanel({ isOpen, onClose }: NotificationsPanelProps) { const { notifications, preferences, unreadCount, markAsRead, markAllAsRead, removeNotification, clearAll, updatePreferences, } = useNotificationsStore(); const [showSettings, setShowSettings] = useState(false); const handleEnableNotifications = async () => { const granted = await requestNotificationPermission(); if (granted) { updatePreferences({ enabled: true }); } }; const formatTime = (timestamp: number) => { const now = Date.now(); const diff = now - timestamp; if (diff < 60000) return 'Just now'; if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`; if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`; return new Date(timestamp).toLocaleDateString(); }; if (!isOpen) return null; return (
e.stopPropagation()} > {/* Header */}

Notifications

{unreadCount > 0 && ( {unreadCount} )}
{/* Settings Panel */} {showSettings && (

Notification Settings

)} {/* Actions */} {notifications.length > 0 && (
)} {/* Notifications List */}
{notifications.length > 0 ? (
{notifications.map((notification) => (
markAsRead(notification.id)} >
{TYPE_ICONS[notification.type]}

{notification.title}

{notification.message}

{formatTime(notification.timestamp)}
{!notification.read && (
)}
))}
) : (

No notifications

)}
); } // Bell button component to be used in the header/titlebar export function NotificationsBell() { const [isOpen, setIsOpen] = useState(false); const { unreadCount } = useNotificationsStore(); return ( <> setIsOpen(false)} /> ); }