Who: As a developer
What: I want to add a product to shopping cart
Why: so that I can review them in my cart before making an order
Acceptance criteria
"add to cart" functionality shall add Item into local storage quantity and product
as a reviewer you must be able to see the item in shopping cart.
as developer you can check in console that localStorage.get('shoppingCart') shall return data in format {"1": 1, "4": 2}
Implementation
"add to Cart" was using "incomplete" functionality from shoppingContext.
As there was a TODO: from Younes.
onClick={() => {
if (product) {
// TODO: change the quantity to be the real one from the NumberInput instead of a randomly set one
const newQuantity = shoppingCart[product.id]
? shoppingCart[product.id] + 1
: 1;
changeProductQuantity(product, newQuantity);
}
}}
Therefore addToCart functionality does not work as expected.
and same code has been copy to three pages:
FavouritePage
MonthlyArrivalPage
ProductPage.
I have move the fix the code and moved it to ProductDetails Component. because all three page uses same ProductDetails component.
User story
Who: As a developer What: I want to add a product to shopping cart Why: so that I can review them in my cart before making an order
Acceptance criteria
Implementation
"add to Cart" was using "incomplete" functionality from shoppingContext. As there was a TODO: from Younes.
Therefore addToCart functionality does not work as expected. and same code has been copy to three pages: FavouritePage MonthlyArrivalPage ProductPage.
I have move the fix the code and moved it to ProductDetails Component. because all three page uses same ProductDetails component.