From 8fc514bc4515072e590188e346b907a4c6bcd3b8 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Wed, 12 Aug 2026 20:56:59 +0530 Subject: [PATCH] Support paginated REST framework product, order, and return list structures in frontend state --- src/App.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 6f133be..6c9a0d4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -199,6 +199,7 @@ export default function App() { .then(res => res.json()) .then(data => { if (Array.isArray(data)) setProducts(data); + else if (data && Array.isArray(data.results)) setProducts(data.results); }) .catch(err => console.error('Error fetching products:', err)); @@ -207,6 +208,7 @@ export default function App() { .then(res => res.json()) .then(data => { if (Array.isArray(data)) setOrders(data); + else if (data && Array.isArray(data.results)) setOrders(data.results); }) .catch(err => console.error('Error fetching orders:', err)); @@ -215,6 +217,7 @@ export default function App() { .then(res => res.json()) .then(data => { if (Array.isArray(data)) setReturns(data); + else if (data && Array.isArray(data.results)) setReturns(data.results); }) .catch(err => console.error('Error fetching returns:', err)); @@ -600,7 +603,10 @@ export default function App() { // Refresh products from backend apiFetch(`${CONFIG.apiBaseUrl}/api/products/`) .then(r => r.json()) - .then(prods => setProducts(prods)) + .then(prods => { + if (Array.isArray(prods)) setProducts(prods); + else if (prods && Array.isArray(prods.results)) setProducts(prods.results); + }) setIsEditingProduct(false) alert(isEditingProduct ? 'Product modified successfully!' : 'Product uploaded successfully!') }) @@ -668,6 +674,8 @@ export default function App() { const prods = await prodRes.json(); if (Array.isArray(prods)) { setProducts(prods); + } else if (prods && Array.isArray(prods.results)) { + setProducts(prods.results); } setBulkCsvFile(null); setBulkZipFile(null);