fix(marketplace): handle paginated API response in Orders and Inventory pages

This commit is contained in:
Tiago Yamamoto 2025-12-22 16:39:30 -03:00
parent 965cedca05
commit 6477eeb756
2 changed files with 4 additions and 4 deletions

View file

@ -27,8 +27,8 @@ export function InventoryPage() {
try { try {
setLoading(true) setLoading(true)
const params = expiringDays ? `?expires_in_days=${expiringDays}` : '' const params = expiringDays ? `?expires_in_days=${expiringDays}` : ''
const data = await apiClient.get<InventoryItem[]>(`/v1/inventory${params}`) const response = await apiClient.get<{ items: InventoryItem[]; total: number }>(`/v1/inventory${params}`)
setInventory(data || []) setInventory(response?.items || [])
setError(null) setError(null)
} catch (err) { } catch (err) {
setError('Erro ao carregar estoque') setError('Erro ao carregar estoque')

View file

@ -31,8 +31,8 @@ export function OrdersPage() {
const loadOrders = async () => { const loadOrders = async () => {
try { try {
setLoading(true) setLoading(true)
const data = await apiClient.get<Order[]>('/v1/orders') const response = await apiClient.get<{ orders: Order[]; total: number }>('/v1/orders')
setOrders(data || []) setOrders(response?.orders || [])
setError(null) setError(null)
} catch (err) { } catch (err) {
setError('Erro ao carregar pedidos') setError('Erro ao carregar pedidos')