From e9fef5a1047cb2d3590274c76aa9e595ef0a9cd1 Mon Sep 17 00:00:00 2001 From: Milad Date: Tue, 29 Sep 2026 13:45:37 +0330 Subject: [PATCH] =?UTF-8?q?feat(pm-panel):=20pm=20panel=20level=20gating?= =?UTF-8?q?=20=E2=80=94=20RequirePmPanel/HomeRoute/menu=20honor=20panels.p?= =?UTF-8?q?m=20(full/limited);=20pm-only=20users=20land=20directly=20in=20?= =?UTF-8?q?the=20PM=20panel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b17098a..3004ee2 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -101,6 +101,10 @@ function HomeRoute() { const panels = user?.panels ?? {}; if (panels.inventory) return ; if (panels.procurement === "limited") return ; + // فقط پنل PM: مستقیم به پنل مدیریت پروژه + if (panels.pm && !panels.inventory && !panels.procurement) { + return ; + } if (user?.role === "supervisor") return ; if (user?.role === "pm") return ; return ; @@ -130,10 +134,16 @@ function PmPanelPage() { ); } -// دسترسی پنل PM: همه نقش‌ها دسترسی دارند +// دسترسی پنل PM: ادمین، پنل pm (full/limited) و نقش‌های میراث pm/supervisor — +// مدیر تدارکات (یا هر کاربر بدون پنل pm) دسترسی ندارد function RequirePmPanel({ children }: { children: React.ReactNode }) { const user = useAuthStore((s) => s.user); - const allowed = user?.role === "admin" || user?.role === "procurement_manager" || user?.role === "pm" || user?.role === "supervisor"; + const panels = user?.panels ?? {}; + const allowed = + user?.role === "admin" || + Boolean(panels.pm) || + user?.role === "pm" || + user?.role === "supervisor"; if (!allowed) return ; return <>{children}; }