// File: app/components/layout/Topbar.tsx "use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; // FIX: Import both clearAuth and getStoredUser so the topbar can show the // authenticated user's role and handle logout properly. import { clearAuth, getStoredUser } from "../../../lib/auth"; export function Topbar() { const router = useRouter(); function handleLogout() { // FIX: clearAuth already existed and is correct — it removes both the // token and user from localStorage, fully ending the session. clearAuth(); router.replace("/login"); } // FIX: Read the stored user to display their real role in the header // instead of the hardcoded "Manager" placeholder. const user = getStoredUser(); // Capitalize the role label for display (e.g. "admin" → "Admin") const roleLabel = user?.role ? user.role.charAt(0).toUpperCase() + user.role.slice(1) : "—"; return (

Operations dashboard

Logistics delivery management

Overview {/* FIX: Replace the hardcoded "Manager" string with the actual authenticated user's role read from localStorage. */}
{roleLabel}
); }