From 7f25d30facf15efc3a0e7967e41fd25eb8daac47 Mon Sep 17 00:00:00 2001 From: Deploy Date: Wed, 26 Aug 2026 22:43:01 +0200 Subject: [PATCH] fix(admin): add pagination to /admin/orders with prev/next and total counter --- backlog/features.json | 2 +- .../admin/src/app/(dashboard)/orders/page.tsx | 40 ++++++++++++++++++- work/runtime-status.json | 18 ++++++++- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/backlog/features.json b/backlog/features.json index c2750c1..0dcd34d 100644 --- a/backlog/features.json +++ b/backlog/features.json @@ -8146,7 +8146,7 @@ "description": "Admin orders page shows only 20 orders with no pagination. Add offset/limit controls, prev/next buttons, and total counter.", "priority": "med", "risk": "low", - "status": "pending", + "status": "in_progress", "created_at": "2026-08-26", "gates": { "reviewer": false, diff --git a/project/apps/admin/src/app/(dashboard)/orders/page.tsx b/project/apps/admin/src/app/(dashboard)/orders/page.tsx index 9a90c2c..a658a6e 100644 --- a/project/apps/admin/src/app/(dashboard)/orders/page.tsx +++ b/project/apps/admin/src/app/(dashboard)/orders/page.tsx @@ -65,6 +65,9 @@ export default function OrdersPage() { const [filterState, setFilterState] = useState(''); const [search, setSearch] = useState(''); const [debouncedSearch, setDebouncedSearch] = useState(''); + const [total, setTotal] = useState(0); + const [offset, setOffset] = useState(0); + const limit = 20; useEffect(() => { const t = setTimeout(() => setDebouncedSearch(search), 400); @@ -78,14 +81,21 @@ export default function OrdersPage() { const data = await ordersApi.list({ status: filterState || undefined, q: debouncedSearch || undefined, - limit: 20, + limit, + offset, }); setOrders(data.items); + setTotal(data.total); } catch (err) { setError(err instanceof Error ? err.message : 'Error al cargar'); } finally { setLoading(false); } + }, [filterState, debouncedSearch, offset]); + + // Reset to first page when filters change + useEffect(() => { + setOffset(0); }, [filterState, debouncedSearch]); useEffect(() => { load(); }, [load]); @@ -95,7 +105,7 @@ export default function OrdersPage() { {/* Header */}

Pedidos

-

{orders?.length ?? 0} pedidos

+

{total} pedidos

{/* Filters */} @@ -206,6 +216,32 @@ export default function OrdersPage() { )} + {/* Pagination footer */} + {!loading && !error && orders && orders.length > 0 && ( +
+

+ Mostrando {offset + 1}–{Math.min(offset + limit, total)} de {total} +

+
+ + +
+
+ )} ); diff --git a/work/runtime-status.json b/work/runtime-status.json index d03e982..f6f2ae5 100644 --- a/work/runtime-status.json +++ b/work/runtime-status.json @@ -2,11 +2,11 @@ "feature_id": "CHECKOUT-STOCK-RECHECK", "stage": "build", "agent": "implementer", - "action": "Implementar admin Club: endpoints backend + página dashboard", + "action": "Add pagination to admin orders page", "state": "running", "next_agent": "reviewer", "waiting_for": "build", - "updated_at": "2026-08-26T18:49:57.402761Z", + "updated_at": "2026-08-26T20:42:28.158071Z", "timeline": [ { "ts": "2026-08-26T17:21:37Z", @@ -245,6 +245,20 @@ "stage": "build", "state": "running", "message": "Implementar recovery codes para CLUB-004" + }, + { + "ts": "2026-08-26T20:42:28.158071Z", + "agent": "architect", + "stage": "design", + "state": "done", + "message": "Diseño: pagination prev/next + total counter" + }, + { + "ts": "2026-08-26T20:42:28.158071Z", + "agent": "implementer", + "stage": "build", + "state": "running", + "message": "Add pagination to admin orders page" } ], "gates": {