In this PR I refactored and merged all the code we had on these three topics. The working version can be applied to Cart, Checkout, Single Product page and Hall of Fame. The resulting local storage hooks are used in 2 contexts: user and cart, but they are reusable could be potentially applied to the new contexts.
For #44, this solution can remove items from cart through reducer.
If need to add the part to clear localStorage entirely - call localStorage.clear()
For #54, this solution works for all of the cart action types: incrementing, decrementing, adding, removing items.
For #53, this solution works for all of the action types on the single product page: increasing and decreasing ice cream quantity, toppings. On Hall of Fame page, local storage seems to persist items.
@larkinds hi! I fixed all the requested changes and wanted to ask if you have any other comments. Otherwise, we might need this to be approved and merged for the next issues.
In this PR I refactored and merged all the code we had on these three topics. The working version can be applied to Cart, Checkout, Single Product page and Hall of Fame. The resulting local storage hooks are used in 2 contexts: user and cart, but they are reusable could be potentially applied to the new contexts.
For #44, this solution can remove items from cart through reducer.
For #54, this solution works for all of the cart action types: incrementing, decrementing, adding, removing items.
For #53, this solution works for all of the action types on the single product page: increasing and decreasing ice cream quantity, toppings. On Hall of Fame page, local storage seems to persist items.