import { useEffect, useRef, useState } from "react"; import { useNavigate } from "react-router-dom"; import { useNotifications } from "../context/NotificationsContext"; import { BellIcon } from "./icons"; import { relativeTime } from "../utils"; export function NotificationBell() { const { items, unreadCount, markRead, markAllRead, clear } = useNotifications(); const [open, setOpen] = useState(false); const ref = useRef(null); const navigate = useNavigate(); useEffect(() => { const onClick = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); }; document.addEventListener("mousedown", onClick); return () => document.removeEventListener("mousedown", onClick); }, []); return (
{open && (
Notifications
{items.length === 0 && (

No notifications yet

)} {items.map((n) => ( ))}
)}
); }