import React, { useState, useRef, useEffect } from 'react' interface NotificationItem { id: string title: string time: string unread?: boolean } const MOCK_NOTIFICATIONS: NotificationItem[] = [ { id: 'n1', title: 'Hà Linh đã gửi 18 ảnh chờ duyệt trong dự án Giao thông đô thị', time: '5 phút trước', unread: true, }, { id: 'n2', title: 'Tuấn Nam hoàn thành gán nhãn lô #04 (120 ảnh)', time: '1 giờ trước', unread: true, }, { id: 'n3', title: 'Xuất bộ nhãn YOLOv8 thành công', time: 'Hôm qua', unread: false, }, ] export const NotificationBell: React.FC<{ isProjectList?: boolean }> = ({ isProjectList = false }) => { const [open, setOpen] = useState(false) const [notifications, setNotifications] = useState(MOCK_NOTIFICATIONS) const ref = useRef(null) useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (ref.current && !ref.current.contains(event.target as Node)) { setOpen(false) } } document.addEventListener('mousedown', handleClickOutside) return () => document.removeEventListener('mousedown', handleClickOutside) }, []) const unreadCount = notifications.filter((n) => n.unread).length const markAllRead = () => { setNotifications((prev) => prev.map((n) => ({ ...n, unread: false }))) } return (
{open && (
Thông báo ({unreadCount}) {unreadCount > 0 && ( )}
{notifications.map((item) => (
{item.unread && ( )}

{item.title}

{item.time}
))}
)}
) }