diff --git a/src/pages/Supplies.tsx b/src/pages/Supplies.tsx index 531a165..7ae5e4f 100644 --- a/src/pages/Supplies.tsx +++ b/src/pages/Supplies.tsx @@ -34,7 +34,7 @@ import { resolveProductType, type ProductTypeKey } from '../productClassificatio import { getPlanningStock } from '../planningStock'; import type { CuttingSettings, DateRange, ProductAnalyticsItem, StockData, SupplyFabricPlan, SupplyLot, SupplyMovement, SupplyPurchaseNeed, SupplyReceipt, SupplySummary } from '../types'; -type InventoryTab = 'dashboard' | 'tiny_stock' | 'balance' | 'receipts' | 'inventory' | 'movements'; +type InventoryTab = 'dashboard' | 'stock' | 'balance' | 'receipts' | 'inventory' | 'movements'; type ReceiptView = 'new' | 'pending' | 'history'; const pageClassName = 'flex w-full flex-col gap-6'; @@ -100,7 +100,7 @@ const exportCsv = (filename: string, rows: Array = [ { id: 'dashboard', name: 'Dashboard', icon: Warehouse }, - { id: 'tiny_stock', name: 'Estoque Tiny', icon: PackageSearch }, + { id: 'stock', name: 'Estoque', icon: PackageSearch }, { id: 'balance', name: 'Saldo', icon: BarChart3 }, { id: 'receipts', name: 'Recebimentos', icon: Truck }, { id: 'inventory', name: 'Inventário', icon: ClipboardCheck }, @@ -959,7 +959,7 @@ const ReceiptsTab = ({ ); }; -const TinyStockTab = ({ +const StockTab = ({ stock, onRefresh, }: { @@ -968,6 +968,8 @@ const TinyStockTab = ({ }) => { const [search, setSearch] = useState(''); const [stockFilter, setStockFilter] = useState('all'); + const [currentPage, setCurrentPage] = useState(1); + const [itemsPerPage, setItemsPerPage] = useState(20); const normalizedSearch = normalizeSearch(search); const totalBalance = stock.reduce((total, item) => total + Number(item.saldo || 0), 0); const updatedItems = stock.filter(item => Number(item.delta_estoque || 0) !== 0).length; @@ -987,12 +989,16 @@ const TinyStockTab = ({ (stockFilter === 'changed' && delta !== 0); return matchesSearch && matchesFilter; }).sort((a, b) => Number(b.saldo || 0) - Number(a.saldo || 0)); + const totalPages = Math.ceil(visibleStock.length / itemsPerPage); + const safeCurrentPage = Math.min(currentPage, totalPages || 1); + const startIndex = (safeCurrentPage - 1) * itemsPerPage; + const paginatedStock = visibleStock.slice(startIndex, startIndex + itemsPerPage); return (
-

SKUs Tiny

+

SKUs

{formatNumber(stock.length, 0)}

@@ -1012,13 +1018,13 @@ const TinyStockTab = ({
-

Estoque vindo do Tiny

-

Saldo de produtos sincronizado pelo fluxo Tiny para Graphs.

+

Estoque

+

Saldo de produtos sincronizado pelo fluxo de estoque para Graphs.