"use client" import { useEffect, useState } from "react" import { Bell, Check, Trash2, Info, CheckCircle, AlertTriangle, XCircle } from "lucide-react" import { Button } from "@/components/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { ScrollArea } from "@/components/ui/scroll-area" import { useNotificationsStore } from "@/lib/store/notifications-store" import { cn } from "@/lib/utils" import { Badge } from "@/components/ui/badge" const getIcon = (type: string) => { switch (type) { case 'success': return ; case 'warning': return ; case 'error': return ; default: return ; } } export function NotificationsDropdown() { const { notifications, unreadCount, fetchNotifications, markAsRead, markAllAsRead } = useNotificationsStore() const [open, setOpen] = useState(false) useEffect(() => { // Fetch on mount and set up polling every 30s fetchNotifications() const interval = setInterval(fetchNotifications, 30000) return () => clearInterval(interval) }, [fetchNotifications]) return (

Notifications

{unreadCount > 0 && ( )}
{notifications.length === 0 ? (
No notifications
) : (
{notifications.map((notification) => (
markAsRead(notification.id)} >
{getIcon(notification.type)}

{notification.title}

{notification.message}

{new Date(notification.createdAt).toLocaleDateString()}

{!notification.readAt && (
)}
))}
)}
) }