/** * NotificationBell Component * Bell icon with badge showing unread count, opens dropdown on click */ import { useState, useEffect } from 'react'; import { Bell } from 'lucide-react'; import clsx from 'clsx'; import { useNotificationStore } from '../../../stores/notificationStore'; import NotificationDropdown from './NotificationDropdown'; export default function NotificationBell() { const [isOpen, setIsOpen] = useState(false); const { unreadCount, fetchUnreadCount, initializeWebSocket } = useNotificationStore(); // Fetch unread count on mount and setup WebSocket useEffect(() => { fetchUnreadCount(); // Initialize WebSocket for real-time notifications const unsubscribe = initializeWebSocket(); // Refresh count periodically const interval = setInterval(fetchUnreadCount, 60000); return () => { unsubscribe(); clearInterval(interval); }; }, [fetchUnreadCount, initializeWebSocket]); const toggleDropdown = () => { setIsOpen(!isOpen); }; const closeDropdown = () => { setIsOpen(false); }; return (
); }