import React from 'react' import { useNavigate } from 'react-router-dom' import { Heart, MessageCircle, Users, Bell, Settings, Check } from 'lucide-react' import { useNotificationStore } from '../../store/notificationStore' import { NotificationType } from '../../types' const typeIcon = (type: NotificationType) => { const props = { size: 14 } switch (type) { case 'like': return case 'comment': return case 'collaboration': return case 'follow': return case 'system': return default: return } } function timeAgo(dateStr: string): string { const diff = Date.now() - new Date(dateStr).getTime() const mins = Math.floor(diff / 60000) if (mins < 1) return 'just now' if (mins < 60) return `${mins}m ago` const hrs = Math.floor(mins / 60) if (hrs < 24) return `${hrs}h ago` return `${Math.floor(hrs / 24)}d ago` } interface Props { onClose: () => void } export const NotificationDropdown: React.FC = ({ onClose }) => { const navigate = useNavigate() const { notifications, markAllRead, markRead } = useNotificationStore() const recent = notifications.slice(0, 5) return (
Notifications
{recent.length === 0 ? (
No notifications yet
) : ( recent.map(n => (
{ markRead(n.notification_id) if (n.link) { navigate(n.link); onClose() } }} >
{typeIcon(n.type)}

{n.title}

{n.message}

{timeAgo(n.created_at)}

{!n.is_read && (
)}
)) )}
) }