Enable quantity updates for basket items on the Baskets page #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements functionality to allow users to increase or decrease the quantity of items in their basket directly from the Baskets page. Users can now adjust quantities using intuitive increment (+) and decrement (-) buttons, with proper validation and persistence.
Problem
Previously, users could only add items to the basket or remove them entirely. There was no way to adjust the quantity of an item once added. This required users to remove and re-add items to change quantities, creating a poor user experience.
Solution
Backend Changes
Added
updateBasketItemQuantityfunction inBasket.Domain.fs:Result<int, string>for proper error handlingAdded
updateQuantityHTTP handler inBasket.Page.fs:Added POST route
/basket/updatequantityto the routing table.Frontend Changes
Updated
Basket.Component.fsto display quantity controls:Validation & Error Handling
Testing
Unit Tests
Created comprehensive test suite in
tests/Basket/UpdateBasketItemQuantity.fs:All 15 tests pass (8 existing + 7 new).
Manual Testing
Verified the following scenarios:
Screenshots
Initial basket with one item (quantity = 1):
Note the disabled "-" indicator and active "+" button.
After incrementing (quantity = 2):
Both "-" and "+" buttons are now active, cost updated from ¤7.25 to ¤14.50.
Multiple items with different quantities:
Demonstrates independent quantity controls for each basket item.
Acceptance Criteria
✅ Users can increase or decrease quantities for each basket item
✅ Invalid inputs trigger appropriate feedback messages
✅ All updates are properly reflected in the basket and persisted in the database
✅ Code adheres to repository standards for F#, Entity Framework, and Falco
✅ All new logic is covered by comprehensive unit tests
Implementation Notes
Original prompt
Fixes #19
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.