Reverting the production revert so the pm branch can merge cleanly on top of the restored RBAC base. Conflicts against newer integration work resolved by combining: - App.tsx: v7's bot-draft wizard bypass + login returnUrl kept alongside the supervisor gating (no-project block screen, panel scoping) - LoginPage: returnUrl navigation kept, supervisor routing added - migration.sql: bot_drafts table kept, unified-projects ALTERs restored
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { Link } from "react-router-dom";
|
|
import { Button } from "../../components/ui/button";
|
|
|
|
import { useAuthStore } from "../../store/auth";
|
|
|
|
// ناوبری بالای صفحه در پنل انبار — هماهنگ با دیزاینسیستم دکمهها
|
|
export function InventoryTopNav({
|
|
pathname,
|
|
}: {
|
|
pathname: string;
|
|
}) {
|
|
const user = useAuthStore((s) => s.user);
|
|
const isAdmin = user?.role === "admin";
|
|
const isManager = user?.role === "procurement_manager" || user?.role === "pm" || isAdmin;
|
|
|
|
const items: { label: string; to: string; active: boolean }[] = [];
|
|
// سرپرست پروژه از دکمه شناور گرد (+) در پایین صفحه استفاده میکند و دکمه مستطیلی بالای صفحه برای او نمایش داده نمیشود
|
|
if (isAdmin) {
|
|
items.push({
|
|
label: "تغییر موجودی",
|
|
to: "/inventory/change",
|
|
active: pathname.startsWith("/inventory/change"),
|
|
});
|
|
}
|
|
if (isManager) {
|
|
items.push({ label: "کنترل روزانه", to: "/inventory/daily", active: pathname.startsWith("/inventory/daily") });
|
|
items.push({ label: "انبارها", to: "/inventory/warehouses", active: pathname.startsWith("/inventory/warehouses") });
|
|
items.push({ label: "کالاهای در راه", to: "/inventory/arrivals", active: pathname.startsWith("/inventory/arrivals") });
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{items.map((it) => (
|
|
<Button
|
|
key={it.to}
|
|
asChild
|
|
variant={it.active ? "primary" : "slate"}
|
|
>
|
|
<Link to={it.to} className="no-underline">
|
|
{it.label}
|
|
</Link>
|
|
</Button>
|
|
))}
|
|
</>
|
|
);
|
|
} |