diff --git a/frontend/src/pages/Inventory/DailyControlPage.tsx b/frontend/src/pages/Inventory/DailyControlPage.tsx index 05934ee..d1e430a 100644 --- a/frontend/src/pages/Inventory/DailyControlPage.tsx +++ b/frontend/src/pages/Inventory/DailyControlPage.tsx @@ -3,7 +3,8 @@ import { useLocation, useNavigate } from "react-router-dom"; import { Header, PageLayout } from "../../components/layout/Header"; import { useAuthStore } from "../../store/auth"; import { PanelMenu } from "../../components/PanelMenu"; -import { panelMenuItems, useLogout } from "./panelMenu"; +import { accountMenuItems, useLogout } from "./panelMenu"; +import { InventoryTopNav } from "./InventoryTopNav"; import { useInventoryData, unitName, whName } from "./useInventoryData"; import { faNum } from "../../lib/formatters"; import { gregorianToJalali, MONTHS, toFa } from "../../lib/jalali"; @@ -29,10 +30,17 @@ export function DailyControlPage() { const [anchor, setAnchor] = useState(new Date()); const [sel, setSel] = useState(todayKey()); const [actRec, setActRec] = useState(null); + // فیلتر پروژه — فقط برای مدیر تدارکات/ادمین (مدیر پروژه به پروژه خودش محدود است) + const isAdmin = user?.role === "admin" || user?.role === "procurement_manager"; + const [projFilter, setProjFilter] = useState(""); const txByDay = useMemo(() => { const map = new Map(); + const projWhIds = projFilter + ? new Set(data.warehouses.filter((w) => String(w.project_id) === String(projFilter)).map((w) => w.id)) + : null; data.transactions.forEach((t) => { + if (projWhIds && !projWhIds.has(t.warehouse_id)) return; const k = gregKey(new Date(t.transaction_date)); const arr = map.get(k) || []; arr.push(t); @@ -40,7 +48,7 @@ export function DailyControlPage() { }); map.forEach((arr) => arr.sort((a, b) => new Date(a.transaction_date).getTime() - new Date(b.transaction_date).getTime())); return map; - }, [data.transactions]); + }, [data.transactions, data.warehouses, projFilter]); // cells: 42 روز از شنبه قبلِ اولین روز ماه جلالی const cells = useMemo(() => { @@ -99,18 +107,39 @@ export function DailyControlPage() {
} + menu={isAdmin ? : undefined} + actions={isAdmin || isPM ? : undefined} /> + {isAdmin && ( +
+ + + + {projFilter + ? "نمایش کنترل روزانه فقط برای پروژه انتخابی" + : "نمایش کنترل روزانه همه پروژه‌ها"} + +
+ )}
{/* تقویم */}
📅 {monthTitle}
- - + +