"use client"; import { Bell, Check, 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 { Badge } from "@/components/ui/badge"; 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 getStatusBadge = (notification: Notification) => { const status = notification.metadata?.status as string | undefined; if (!status) return null; switch (status) { case "in_progress": return ( In Progress ); case "completed": return ( Completed ); case "failed": return ( Failed ); default: return null; } }; return (
{/* Header */}

Notifications

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

No notifications

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