- header: icon box + dynamic subheader '[user] | [role] – [project/همه پروژهها]' on every warehouse page; module context kept in the hamburger (items 1-2) - project manager view: office button + inline logout removed; hamburger contains only «خروج از حساب»; sub-views get «بازگشت به داشبورد» (Header backTo/goBack); «افزایش موجود» primary button on the dashboard (item 8) - daily control: cells render the day-of-month (was the Jalali year), month nav uses real Jalali months, header is pure Jalali «امروز ۸ شهریور ۱۴۰۵», today gets a blue accent (item 3) - arrivals: partial (item/qty) receipt — any valid item is enough to submit, ceiling + allocation-sum validation with inline errors, Received/In-Transit badges; ledger shows «رسیده X از Y» / «در راه Z» + «رسید جزیی» badge (item 4) - api client: multipart uploads no longer send Content-Type json (fixes the invoice/proforma 400 «دادهی ارسالشده نامعتبر است»); undefined query params are dropped (fixes empty admin project filter, item 5) - organization: user-creation card removed, role column read-only for procurement manager, Casdoor sync button (item 6) - admin panel (/admin): Casdoor user sync + grant/revoke «مدیر تدارکات»; Developer Mode is a 3-step admin-gated flow on the login page (item 7)
84 lines
4.2 KiB
TypeScript
84 lines
4.2 KiB
TypeScript
import type { MenuItem } from "../../components/PanelMenu";
|
||
import { useAuthStore } from "../../store/auth";
|
||
|
||
// خروج از حساب — پاککردن نشست و بازگشت به صفحهی ورود
|
||
export function useLogout() {
|
||
return () => {
|
||
useAuthStore.getState().logout();
|
||
window.location.href = "/login";
|
||
};
|
||
}
|
||
|
||
const ROLE_LABELS: Record<string, string> = {
|
||
pm: "مدیر پروژه",
|
||
procurement_manager: "مدیر تدارکات",
|
||
admin: "ادمین",
|
||
};
|
||
|
||
// زیرعنوان پویای سربرگ پنل انبار:
|
||
// [نام کاربر] | [نقش] – [پروژه / همه پروژهها]
|
||
// مدیر پروژه → نام پروژهی خودش؛ مدیر تدارکات/ادمین → «همه پروژهها».
|
||
export function inventorySubheader(user: { display_name?: string; first_name: string; last_name: string; role: string | null; role_label: string | null; project_name: string | null } | null | undefined): string {
|
||
if (!user) return "در حال بارگذاری…";
|
||
const name = user.display_name || `${user.first_name} ${user.last_name}`.trim() || "کاربر";
|
||
const role = user.role_label || (user.role ? ROLE_LABELS[user.role] : "بدون نقش");
|
||
const proj = user.role === "pm" ? user.project_name || "پروژه نامشخص" : "همه پروژهها";
|
||
return `${name} | ${role} – ${proj}`;
|
||
}
|
||
|
||
// منوی همبرگریِ مختصر برای مدیر تدارکات/ادمین: بخشها بالای صفحه هستند و
|
||
// اینجا فقط «بازگشت به دفتر» و «خروج از حساب» میماند.
|
||
export function accountMenuItems(onLogout?: () => void): MenuItem[] {
|
||
const items: MenuItem[] = [{ label: "بازگشت به دفتر", to: "/" }];
|
||
if (onLogout) {
|
||
items.push({ divider: true });
|
||
items.push({ label: "خروج از حساب", onClick: onLogout });
|
||
}
|
||
return items;
|
||
}
|
||
|
||
// منوی همبرگری مدیر پروژه در پنل انبار — فقط «خروج از حساب»
|
||
// (مدیر پروژه به دفتر تدارکات دسترسی ندارد و دکمهی خروجِ تکی هم حذف شده).
|
||
export function pmMenuItems(onLogout?: () => void): MenuItem[] {
|
||
const items: MenuItem[] = [];
|
||
if (onLogout) {
|
||
items.push({ label: "خروج از حساب", onClick: onLogout });
|
||
}
|
||
return items;
|
||
}
|
||
|
||
// آیتمهای منوی همبرگری پنل مدیریت انبار — با نشانگر پنل فعلی + «بازگشت به دفتر» + خروج
|
||
//
|
||
// دسترسیها (v2.6):
|
||
// - ادمین / مدیر تدارکات (یک نفر): داشبورد، کنترل روزانه، کالاهای در راه، سازماندهی —
|
||
// بدون «تغییر موجودی» و بدون «انبارها».
|
||
// - مدیر پروژه: داشبورد، تغییر موجودی، کنترل روزانه، انبارها، کالاهای در راه —
|
||
// بدون «سازماندهی».
|
||
export function panelMenuItems(pathname: string, role: string | null | undefined, onLogout?: () => void): MenuItem[] {
|
||
const isAdmin = role === "admin" || role === "procurement_manager";
|
||
const isPM = role === "pm";
|
||
const items: MenuItem[] = [
|
||
{ label: "داشبورد انبار", to: "/inventory", active: pathname === "/inventory" },
|
||
];
|
||
if (isPM) {
|
||
items.push({ label: "تغییر موجودی", to: "/inventory/change", active: pathname.startsWith("/inventory/change") });
|
||
}
|
||
items.push({ label: "کنترل روزانه", to: "/inventory/daily", active: pathname.startsWith("/inventory/daily") });
|
||
if (isPM) {
|
||
items.push({ label: "انبارها", to: "/inventory/warehouses", active: pathname.startsWith("/inventory/warehouses") });
|
||
}
|
||
items.push({ label: "کالاهای در راه", to: "/inventory/arrivals", active: pathname.startsWith("/inventory/arrivals") });
|
||
if (isAdmin) {
|
||
items.push({ label: "سازماندهی", to: "/inventory/org", active: pathname.startsWith("/inventory/org") });
|
||
}
|
||
if (isAdmin) {
|
||
items.push({ divider: true });
|
||
items.push({ label: "بازگشت به دفتر", to: "/" });
|
||
}
|
||
if (onLogout) {
|
||
items.push({ divider: true });
|
||
items.push({ label: "خروج از حساب", onClick: onLogout });
|
||
}
|
||
return items;
|
||
}
|