diff --git a/src/components/DashboardShell.tsx b/src/components/DashboardShell.tsx index 33f0bef..a4a0bfd 100644 --- a/src/components/DashboardShell.tsx +++ b/src/components/DashboardShell.tsx @@ -3,7 +3,7 @@ * Used for pages that need actual backend connectivity * (My Profile, My Portfolio, Verification) instead of the preview mock. */ -import { For, JSX, Show, createMemo } from 'solid-js'; +import { For, JSX, Show, createMemo, createSignal, onMount } from 'solid-js'; import { User, Briefcase, LayoutDashboard, FolderOpen, MapPin, Star, CreditCard, Globe, ShieldCheck, HelpCircle, Settings, @@ -65,6 +65,33 @@ export default function DashboardShell(props: Props) { return k.charAt(0).toUpperCase() + k.slice(1).toLowerCase(); }); + const [unreadCount, setUnreadCount] = createSignal(0); + + // Fetch unread notification count + const fetchUnreadCount = async () => { + try { + const token = typeof window !== 'undefined' ? window.sessionStorage.getItem('nxtgauge_access_token') || '' : ''; + 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); + }); + return (