feat(inventory): role-aware header navigation - PM top nav without hamburger, admin top nav plus compact account menu

This commit is contained in:
ali_mohaghegh
2026-08-27 15:04:25 +03:30
parent 5e690a7fc8
commit eb2a50eee1
5 changed files with 164 additions and 37 deletions
@@ -0,0 +1,61 @@
import { Link } from "react-router-dom";
import { cn } from "../../lib/utils";
// ناوبری بالای صفحه در پنل انبار — جایگزین لینک‌های منوی همبرگری
// (مثل سیستم تدارکات: لینک‌ها در بالای صفحه)
//
// - variant="pm": همه بخش‌های مدیر پروژه + «دفتر تدارکات» و «خروج از حساب»
// (منوی همبرگری حذف می‌شود).
// - variant="admin": فقط بخش‌های مدیر تدارکات/ادمین — «بازگشت به دفتر» و
// «خروج از حساب» در منوی همبرگری می‌مانند.
export function InventoryTopNav({
pathname,
onLogout,
variant = "pm",
}: {
pathname: string;
onLogout: () => void;
variant?: "pm" | "admin";
}) {
const items =
variant === "admin"
? [
{ label: "داشبورد انبار", to: "/inventory", active: pathname === "/inventory" },
{ label: "کنترل روزانه", to: "/inventory/daily", active: pathname.startsWith("/inventory/daily") },
{ label: "کالاهای در راه", to: "/inventory/arrivals", active: pathname.startsWith("/inventory/arrivals") },
{ label: "سازمان‌دهی", to: "/inventory/org", active: pathname.startsWith("/inventory/org") },
]
: [
{ label: "داشبورد انبار", to: "/inventory", active: pathname === "/inventory" },
{ label: "تغییر موجودی", to: "/inventory/change", active: pathname.startsWith("/inventory/change") },
{ label: "کنترل روزانه", to: "/inventory/daily", active: pathname.startsWith("/inventory/daily") },
{ label: "انبارها", to: "/inventory/warehouses", active: pathname.startsWith("/inventory/warehouses") },
{ label: "کالاهای در راه", to: "/inventory/arrivals", active: pathname.startsWith("/inventory/arrivals") },
];
return (
<>
{items.map((it) => (
<Link
key={it.to}
to={it.to}
className={cn(
"btn-line-file no-underline",
it.active && "border-accent bg-accent text-white hover:bg-accent-dark",
)}
>
{it.label}
</Link>
))}
{variant === "pm" && (
<>
<Link to="/" className="btn-line-file no-underline">
دفتر تدارکات
</Link>
<button type="button" onClick={onLogout} className="btn-line-file cursor-pointer border-red/30 text-red hover:bg-red/10">
خروج از حساب
</button>
</>
)}
</>
);
}