Skip to content

fix(admin): prevent inventory page crash from paginated API response - #420

Closed
sujitha-kotyada wants to merge 3 commits into
Nsanjayboruds:mainfrom
sujitha-kotyada:fix/admin-product-list-payload
Closed

fix(admin): prevent inventory page crash from paginated API response#420
sujitha-kotyada wants to merge 3 commits into
Nsanjayboruds:mainfrom
sujitha-kotyada:fix/admin-product-list-payload

Conversation

@sujitha-kotyada

Copy link
Copy Markdown
Contributor

Pull Request

Summary

Fix the Admin Product Inventory page crash by correctly extracting the products array from the paginated API response.

Description

The backend GET /api/product/list endpoint now returns a paginated response object containing both products and pagination. However, the admin inventory page was storing the entire response object in the list state, which is later treated as an array using methods such as .map() and .filter(). This caused a runtime error and prevented the inventory page from loading.

Changes Made

  • Updated the admin product list page to extract the products array from the API response.
  • Added a defensive Array.isArray() check to ensure the component always receives an array before updating state.
  • Preserved the existing backend API contract and pagination support without requiring any backend changes.

Testing

  • Verified the Admin Product Inventory page loads successfully without runtime errors.
  • Confirmed product search, filtering, deletion, product count, and empty-state rendering continue to work correctly.
  • Ran backend tests successfully with no regressions.

Related Issue

Fixes #397

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • UI/UX improvement
  • Refactoring

Checklist

  • Code follows project guidelines
  • Tested locally
  • No console errors

@Nsanjayboruds

Copy link
Copy Markdown
Owner

@sujitha-kotyada fix the backend lint

@sujitha-kotyada sujitha-kotyada closed this by deleting the head repository Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Admin Product Inventory page crashes due to API response payload mismatch

2 participants