diff --git a/src/components/notification-bell.tsx b/src/components/notification-bell.tsx new file mode 100644 index 0000000..809f3b8 --- /dev/null +++ b/src/components/notification-bell.tsx @@ -0,0 +1,48 @@ +'use client'; + +import Link from 'next/link'; +import { useQuery } from '@tanstack/react-query'; +import { apiFetch, type Notification } from '../lib/api'; + +export function NotificationBell({ tenantId }: { tenantId: string }) { + const { data: notifications = [] } = useQuery({ + queryKey: ['notifications-unread', tenantId], + queryFn: () => apiFetch('/v1/notifications?filter=unread', { tenantId }), + enabled: Boolean(tenantId), + refetchInterval: 30_000, + staleTime: 20_000, + }); + + const count = notifications.length; + + return ( + 0 ? `${count} notificări necitite` : 'Notificări'} + className="relative flex h-9 w-9 items-center justify-center rounded-lg text-ink-faint + transition-colors hover:bg-paper-sunken hover:text-ink" + > + + {count > 0 && ( + + {count > 99 ? '99+' : count} + + )} + + ); +}