From ff527ca577e9882a2e7009b1b13521b7338e2624 Mon Sep 17 00:00:00 2001 From: BOHA Date: Sat, 6 Jun 2026 23:59:18 +0200 Subject: [PATCH] feat(mui): migrate Warehouse Reports (Reporty) onto MUI kit Co-Authored-By: Claude Opus 4.8 (1M context) --- src/admin/pages/WarehouseReports.tsx | 663 ++++++++++++++------------- 1 file changed, 338 insertions(+), 325 deletions(-) diff --git a/src/admin/pages/WarehouseReports.tsx b/src/admin/pages/WarehouseReports.tsx index 111cde8..843c4b5 100644 --- a/src/admin/pages/WarehouseReports.tsx +++ b/src/admin/pages/WarehouseReports.tsx @@ -3,8 +3,7 @@ import { useQuery } from "@tanstack/react-query"; import { useAuth } from "../context/AuthContext"; import Forbidden from "../components/Forbidden"; import { motion } from "framer-motion"; -import FormField from "../components/FormField"; -import AdminDatePicker from "../components/AdminDatePicker"; +import Box from "@mui/material/Box"; import { projectListOptions } from "../lib/queries/projects"; import { warehouseStockStatusOptions, @@ -14,6 +13,22 @@ import { } from "../lib/queries/warehouse"; import apiFetch from "../utils/api"; import { formatCurrency } from "../utils/formatters"; +import { + Button, + Card, + DataTable, + Select, + DateField, + StatusChip, + PageHeader, + FilterBar, + EmptyState, + LoadingState, + Tabs, + TabPanel, + type DataColumn, + type TabDef, +} from "../ui"; type TabId = | "stock-status" @@ -38,17 +53,18 @@ interface MovementLogRow { supplier_or_project: string; } -const TABS: { id: TabId; label: string }[] = [ - { id: "stock-status", label: "Stav zásob" }, - { id: "project-consumption", label: "Spotřeba projektů" }, - { id: "movement-log", label: "Pohyby" }, - { id: "below-minimum", label: "Pod minimem" }, +const TABS: TabDef[] = [ + { value: "stock-status", label: "Stav zásob" }, + { value: "project-consumption", label: "Spotřeba projektů" }, + { value: "movement-log", label: "Pohyby" }, + { value: "below-minimum", label: "Pod minimem" }, ]; -const MOVEMENT_BADGE: Record = { - receipt: "admin-badge-incoming", - issue: "admin-badge-outgoing", - inventory: "admin-badge-info", +// Movement type → StatusChip color (legacy: incoming=success, outgoing=info, inventory=info) +const MOVEMENT_COLOR: Record = { + receipt: "success", + issue: "info", + inventory: "info", }; export default function WarehouseReports() { @@ -73,68 +89,57 @@ export default function WarehouseReports() { if (!hasPermission("warehouse.view")) return ; return ( -
+ -
-

Skladové reporty

-
+
- {/* Tab navigation */} -
-
- {TABS.map((tab) => ( - - ))} -
- - {activeTab === "stock-status" && ( - - )} - {activeTab === "project-consumption" && ( - - )} - {activeTab === "movement-log" && ( - - )} - {activeTab === "below-minimum" && } -
+ setActiveTab(v as TabId)} + tabs={TABS} + />
-
+ + + + + + + + + + + + + + + + + ); } @@ -154,79 +159,91 @@ function StockStatusTab({ }), ); + const columns: DataColumn[] = [ + { + key: "name", + header: "Název", + width: "30%", + bold: true, + render: (item) => item.name, + }, + { + key: "total_quantity", + header: "Celkem", + width: "12%", + mono: true, + render: (item) => String(item.total_quantity ?? 0), + }, + { + key: "available_quantity", + header: "K dispozici", + width: "13%", + mono: true, + render: (item) => String(item.available_quantity ?? 0), + }, + { + key: "stock_value", + header: "Hodnota", + width: "17%", + mono: true, + render: (item) => + item.stock_value != null + ? formatCurrency(item.stock_value, "CZK") + : "0,00 Kč", + }, + { + key: "min_quantity", + header: "Min. množství", + width: "14%", + mono: true, + render: (item) => (item.min_quantity ?? "—").toString(), + }, + { + key: "status", + header: "Stav", + width: "14%", + render: (item) => + item.below_minimum ? ( + + ) : ( + + ), + }, + ]; + return ( -
-
+ + {categories.length > 0 && ( - + + - setProjectId(e.target.value === "" ? "" : Number(e.target.value)) - } - className="admin-form-select" - > - - {projects.map((p) => ( - - ))} - + + setType(e.target.value)} - className="admin-form-select" - > - - - - - - -