diff --git a/src/admin/pages/WarehouseInventory.tsx b/src/admin/pages/WarehouseInventory.tsx index 0fd5821..491c182 100644 --- a/src/admin/pages/WarehouseInventory.tsx +++ b/src/admin/pages/WarehouseInventory.tsx @@ -1,9 +1,9 @@ import { useState } from "react"; import { useNavigate } from "react-router-dom"; +import { motion } from "framer-motion"; +import Box from "@mui/material/Box"; import { useAuth } from "../context/AuthContext"; import Forbidden from "../components/Forbidden"; -import { motion, AnimatePresence } from "framer-motion"; -import Pagination from "../components/Pagination"; import { usePaginatedQuery } from "../hooks/usePaginatedQuery"; import { formatDate } from "../utils/formatters"; @@ -11,12 +11,28 @@ import { warehouseInventoryListOptions, type WarehouseInventorySession, } from "../lib/queries/warehouse"; +import { + Button, + Card, + DataTable, + Pagination, + Select, + StatusChip, + PageHeader, + FilterBar, + EmptyState, + LoadingState, + type DataColumn, +} from "../ui"; const PER_PAGE = 20; -const STATUS_BADGE: Record = { - DRAFT: "admin-badge-warning", - CONFIRMED: "admin-badge-active", +const STATUS_COLOR: Record< + string, + "warning" | "success" | "error" | "info" | "default" +> = { + DRAFT: "warning", + CONFIRMED: "success", }; const STATUS_LABEL: Record = { @@ -24,8 +40,23 @@ const STATUS_LABEL: Record = { CONFIRMED: "Potvrzeno", }; +const PlusIcon = ( + + + + +); + export default function WarehouseInventory() { const { hasPermission } = useAuth(); + const navigate = useNavigate(); const [page, setPage] = useState(1); const [statusFilter, setStatusFilter] = useState(""); @@ -39,190 +70,135 @@ export default function WarehouseInventory() { }), ); - const navigate = useNavigate(); - if (!hasPermission("warehouse.inventory")) return ; - const handleRowClick = (session: WarehouseInventorySession) => { - navigate(`/warehouse/inventory/${session.id}`); - }; - const resetFilters = () => { setStatusFilter(""); setPage(1); }; if (isPending) { - return ( -
-
-
- ); + return ; } + const total = pagination?.total ?? items.length; + const subtitle = `${total} ${ + total === 1 + ? "inventura" + : total >= 2 && total <= 4 + ? "inventury" + : "inventur" + }`; + + const columns: DataColumn[] = [ + { + key: "session_number", + header: "Číslo inventury", + width: "30%", + mono: true, + bold: true, + render: (s) => s.session_number || "—", + }, + { + key: "status", + header: "Stav", + width: "20%", + render: (s) => ( + + ), + }, + { + key: "created_at", + header: "Vytvořeno", + width: "30%", + mono: true, + render: (s) => formatDate(s.created_at), + }, + { + key: "items", + header: "Položky", + width: "20%", + mono: true, + render: (s) => String(s.items?.length ?? 0), + }, + ]; + return ( -
+ -
-

Inventury

-

- {pagination?.total ?? items.length}{" "} - {pagination?.total === 1 - ? "inventura" - : pagination?.total !== undefined && - pagination.total >= 2 && - pagination.total <= 4 - ? "inventury" - : "inventur"} -

-
-
- -
+ Nová inventura + + } + />
- -
-
- - {statusFilter && ( - - )} -
+ + +