From ed68a636f5f8430918d7b35a7424184ca24d3d2c Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Date: Mon, 6 Apr 2026 15:06:29 +0200 Subject: [PATCH] feat(dashboard): add notification bell with unread count polling - Add unreadCount state and polling interval (30s) to DashboardDesignPreview - Fetch from GET /api/me/notifications/unread-count with auth - Display orange dot badge on bell when unreadCount > 0 - Uses existing bell icon in header; integrates with notifications page Implements PRD item: Notification bell on dashboard --- .../admin/DashboardDesignPreview.tsx | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/admin/DashboardDesignPreview.tsx b/src/components/admin/DashboardDesignPreview.tsx index 1f89d1f..e73d9b7 100644 --- a/src/components/admin/DashboardDesignPreview.tsx +++ b/src/components/admin/DashboardDesignPreview.tsx @@ -1041,6 +1041,32 @@ export default function DashboardDesignPreview(props: { }) { const [isVerified, setIsVerified] = createSignal(false); const [verificationPending, setVerificationPending] = createSignal(false); + const [unreadCount, setUnreadCount] = createSignal(0); + + // Fetch unread notification count + const fetchUnreadCount = async () => { + try { + const token = getToken(); + if (!token) return; + const res = await fetch('/api/me/notifications/unread-count', { + headers: { Authorization: `Bearer ${token}` }, + credentials: 'include', + }); + if (res.ok) { + const data = await res.json(); + setUnreadCount(data.unread_count || 0); + } + } catch (e) { + console.error('Failed to fetch unread count:', e); + } + }; + + // Start polling on mount + onMount(() => { + fetchUnreadCount(); + const interval = setInterval(fetchUnreadCount, 30000); + return () => clearInterval(interval); + }); const isProfessionalRoleKey = (roleKey: string) => { const role = normalizeRoleKey(roleKey); @@ -6657,7 +6683,12 @@ export default function DashboardDesignPreview(props: {
- +