diff --git a/components/dashboard/promotions/ProductSelector.tsx b/components/dashboard/promotions/ProductSelector.tsx index a0e4422..27bc2b2 100644 --- a/components/dashboard/promotions/ProductSelector.tsx +++ b/components/dashboard/promotions/ProductSelector.tsx @@ -50,7 +50,15 @@ export default function ProductSelector({ setLoading(true); try { const response = await fetchClient('/promotions/products/all'); - setProducts(response); + // Ensure we only set an array to state to avoid runtime errors + if (Array.isArray(response)) { + setProducts(response); + } else if (response && Array.isArray((response as any).products)) { + setProducts((response as any).products); + } else { + console.error('Unexpected products response shape:', response); + setProducts([]); + } } catch (error) { console.error('Error fetching products:', error); } finally { @@ -119,8 +127,8 @@ export default function ProductSelector({ {/* Dropdown using absolute positioning within relative container */} {open && (