From 9d169a0bdd663fac40ecbb3ded44432dd9301335 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 21 Apr 2026 11:25:20 +0200 Subject: [PATCH] Add pagination to Pricing tab Load data in batches of 100 products per page with navigation controls --- src/components/PricingView.tsx | 63 +++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/src/components/PricingView.tsx b/src/components/PricingView.tsx index a99af10..1f2896a 100644 --- a/src/components/PricingView.tsx +++ b/src/components/PricingView.tsx @@ -51,6 +51,8 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, const [filterMode, setFilterMode] = useState('all_errors'); const [search, setSearch] = useState(''); const [searchMode, setSearchMode] = useState<'all' | 'selected'>('all'); + const [currentPage, setCurrentPage] = useState(1); + const pageSize = 100; const [columnWidths, setColumnWidths] = useState>({ articleNo: 100, articleName: 220, @@ -387,6 +389,14 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, return sorted; }, [filteredRows, sortConfig]); + // ── Pagination ───────────────────────────────────────────────────────── + const paginatedRows = useMemo(() => { + const start = (currentPage - 1) * pageSize; + return sortedRows.slice(start, start + pageSize); + }, [sortedRows, currentPage]); + + const totalPages = Math.ceil(sortedRows.length / pageSize); + const handleSort = (key: string | number) => { setSortConfig(prev => { if (prev.key === key) { @@ -713,7 +723,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, {FILTERS.map(f => ( + + + {currentPage} / {totalPages} + + + + )} -

+ ); }