HackYourFuture-CPH / fp-class18

Interior design webshop
MIT License
1 stars 0 forks source link

AddToCart functionality is not adding data properly to localStorage #253

Closed varsha84 closed 2 years ago

varsha84 commented 2 years ago

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.

 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.