"use client"; import { Bell, CheckCheck, Loader2, AlertCircle, CheckCircle2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Separator } from "@/components/ui/separator"; import type { Notification } from "@/hooks/use-notifications"; import { formatDistanceToNow } from "date-fns"; import { cn } from "@/lib/utils"; interface NotificationPopupProps { notifications: Notification[]; unreadCount: number; loading: boolean; markAsRead: (id: number) => Promise; markAllAsRead: () => Promise; } export function NotificationPopup({ notifications, unreadCount, loading, markAsRead, markAllAsRead, }: NotificationPopupProps) { const handleMarkAsRead = async (id: number) => { await markAsRead(id); }; const handleMarkAllAsRead = async () => { await markAllAsRead(); }; const formatTime = (dateString: string) => { try { return formatDistanceToNow(new Date(dateString), { addSuffix: true }); } catch { return "Recently"; } }; const getStatusIcon = (notification: Notification) => { const status = notification.metadata?.status as string | undefined; switch (status) { case "in_progress": return ; case "completed": return ; case "failed": return ; default: return ; } }; return (
{/* Header */}

Notifications

{unreadCount > 0 && ( )}
{/* Notifications List */} {loading ? (
) : notifications.length === 0 ? (

No notifications

) : (
{notifications.map((notification, index) => (
{index < notifications.length - 1 && }
))}
)}
); }