// Notification bell icon + dropdown for sidebar import { useState, useEffect, useRef } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../contexts/AuthContext'; import { useNotifications } from '../hooks/useNotifications'; export default function NotificationBell() { const { user } = useAuth(); const navigate = useNavigate(); const [open, setOpen] = useState(false); const ref = useRef(null); const userId = user?.id; const { notifications, unreadCount, markAsRead, markAllAsRead } = useNotifications(userId); // Close on outside click useEffect(() => { function handleClick(e: MouseEvent) { if (ref.current && !ref.current.contains(e.target as Node)) { setOpen(false); } } if (open) document.addEventListener('mousedown', handleClick); return () => document.removeEventListener('mousedown', handleClick); }, [open]); return (
{open && (

알림

{unreadCount > 0 && ( )}
{notifications.length === 0 ? (

알림이 없습니다

) : ( notifications.slice(0, 10).map((n) => ( )) )}
)}
); }