From a4cfb8cc44a1594dbfa1d4ee6ddf034e55151477 Mon Sep 17 00:00:00 2001 From: Divine <> Date: Fri, 27 Mar 2026 18:05:21 +0100 Subject: [PATCH] notifications --- frontend/app/(dashboard)/layout.tsx | 32 +++- .../notifications/notification-bell.tsx | 153 ++++++++++++++++++ frontend/hooks/useShipmentSocket.ts | 101 ++++++++++++ frontend/stores/notification.store.ts | 69 ++++++++ 4 files changed, 352 insertions(+), 3 deletions(-) create mode 100644 frontend/components/notifications/notification-bell.tsx create mode 100644 frontend/hooks/useShipmentSocket.ts create mode 100644 frontend/stores/notification.store.ts diff --git a/frontend/app/(dashboard)/layout.tsx b/frontend/app/(dashboard)/layout.tsx index 6b8f386d..1348121f 100644 --- a/frontend/app/(dashboard)/layout.tsx +++ b/frontend/app/(dashboard)/layout.tsx @@ -4,6 +4,13 @@ import Link from "next/link"; import { usePathname } from "next/navigation"; import { cn } from "@/lib/utils"; import { ReactNode } from "react"; +import { useAuthStore } from "../../stores/auth.store"; +import { useShipmentSocket } from "../../hooks/useShipmentSocket"; +import { NotificationBell } from "../../components/notifications/notification-bell"; + +interface DashboardLayoutProps { + children: ReactNode; +} const SHIPPER_NAV = [ { href: '/dashboard', label: 'Dashboard' }, @@ -26,18 +33,37 @@ const ADMIN_NAV = [ { href: '/admin/shipments', label: 'Shipment Oversight' }, ]; +interface DashboardLayoutProps { + children: ReactNode; +} + export default function DashboardLayout({ children }: DashboardLayoutProps) { const pathname = usePathname(); + const user = useAuthStore((state) => state.user); + + // Initialize the WebSocket connection for real-time shipment updates + useShipmentSocket(); + + // Determine nav items based on user role + const getNavItems = () => { + if (!user) return SHIPPER_NAV; + if (user.role === 'admin') return ADMIN_NAV; + if (user.role === 'carrier') return CARRIER_NAV; + return SHIPPER_NAV; + }; + + const navItems = getNavItems(); return (
{/* Sidebar */}