tryandbry / grace-shopper

MIT License
1 stars 0 forks source link

Monica/cart #60

Closed ehacinom closed 7 years ago

ehacinom commented 7 years ago

Summary

In detail, so @gehrj knows what changes were made re: Product.jsx.

Most of these changes were driven by my Cart needing to change quantities of the items inside of it.

Let's call the +/- buttons and new quantity form the ProductQuantityChanger. I moved the buttons into a dumb component ProductQuantityChanger. This is because this is used in both Cart and Product, so it's good to abstract it away.

Both Product and Item (inside Cart) will include this functionality ProductQuantityChanger. HOWEVER, it's a dumb component that needs a class/local state, and the class functions that were attached there.

There's also the button at the bottom, which required another function

I changed all four of these functions. I wrote a lot of checks for addItemToCart because of a few reasons

I composed handleMinusQuantity and handleAddQuantity into --> changeQuantity, adding a few checks so the quantity couldn't get too small or too large.

and finally I kept functionality of handleChange but streamlined the logic.

That's the start of the changes. The rest of the changes were driven by the need to completely restructure everything around the fact that ProductQuantityChanger was abstracted and used by multiple components.

Before, the react component flow was

Product

and

Cart -> Item

Now, the flow is

ProductContainer -> ProductOrItemContainer -> Product -> ProductQuantityChanger

and

Cart -> ProductOrItemContainer -> Item -> ProductQuantityChanger

I was very very very careful to keep all your new css changes, despite the merge meaning the Product component ended being across several files.

Minor changes include updating cart functionality and rewriting a bit of the backend routes.

Hope that's clear!

tryandbry commented 7 years ago

@ehacinom can you write a summary of all the changes you made?

ehacinom commented 7 years ago

summary in the header!