Skip to content

Bug: Quantity state does not reset when navigating between product detail pages #353

Description

@Aamod-Dev

File: FRONTEND/src/pages/ProductPage.jsx (lines 21, 396-416)

Severity: MEDIUM

Problem: If a user sets quantity to 5 for product A, then navigates to product B with stock 3, the quantity state stays at 5 while maxQty is 3. The + button is disabled but the user sees a quantity they cannot reach.

Fix: Add a useEffect to reset quantity to 1 when the product id changes: useEffect(() => setQuantity(1), [id]).

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfrontendFor any changes in the React UI, components, or Vite setup

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions