"use client"; import { useState } from "react"; import { usePathname } from "next/navigation"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Badge } from "@/components/ui/badge"; import { ScrollArea } from "@/components/ui/scroll-area"; import { useNotifications } from "@/contexts/notification-context"; import { Bell, Check, CheckCheck, Trash2, ExternalLink, AlertCircle, CheckCircle, Info, AlertTriangle, } from "lucide-react"; import { formatDistanceToNow } from "date-fns"; import { enUS } from "date-fns/locale"; import Link from "next/link"; import { motion, AnimatePresence } from "framer-motion"; export function NotificationDropdown() { const pathname = usePathname(); const isCompanyDashboard = pathname?.startsWith("/dashboard/company"); const notificationsUrl = isCompanyDashboard ? "/dashboard/company/notifications" : "/dashboard/candidate/notifications"; const { notifications, unreadCount, markAsRead, markAllAsRead, removeNotification, clearAllNotifications, } = useNotifications(); const [isOpen, setIsOpen] = useState(false); const getNotificationIcon = (type: string) => { switch (type) { case "success": return ; case "error": return ; case "warning": return ; default: return ; } }; const recentNotifications = notifications.slice(0, 10); return ( Notifications {unreadCount > 0 && (
)}
{recentNotifications.length === 0 ? (
No notifications
) : (
{recentNotifications.map((notification, index) => (
!notification.read && markAsRead(notification.id) } >
{getNotificationIcon(notification.type)}

{notification.title}

{!notification.read && ( )}

{notification.message}

{formatDistanceToNow( new Date(notification.createdAt), { addSuffix: true, locale: enUS, } )} {notification.actionUrl && notification.actionLabel && ( )}
{!notification.read && (
)}
))}
)} {notifications.length > 0 && ( <>
)} ); }