the-fellowship-1804 / fellowship-of-shoppers

Grace shopper project meant to save the world from terrible, terrible doom
MIT License
2 stars 0 forks source link

Refactor order history component so it tracks order events, not individual items, and takes advantage of the new DB format for OrderHistory #27

Closed SpencerWhitehead7 closed 6 years ago

SpencerWhitehead7 commented 6 years ago

The OrderHistory component was designed assuming that the orderHistory property on the Users DB model would be an array of integers representing product IDs; we have since changed it to an array of arrays, where each array is a cart that was checked out and ordered, containing objects with a product and its quantity.

Order history: [ [ {Product: {Object representing product}, Quantity: integer}, {another productObj} ], [another order event], [more order events] ]

The OrderHistory component should be updated so that it displays a list of the orderHistory sub-arrays (which could be just divs with styling we write if we have time, or maybe be components in their own right), each one containing a set of ProductCard components. It should get the necessary data from user.OrderHistory, and not make any new database calls or filter anything. When this is done, we can also remove the DB call for allproducts from the SingleUser component.

I think the best time to do this is after we finish creating the checkout functionality, which is what will actually push carts into the orderHistory field on the User model.

SpencerWhitehead7 commented 6 years ago

Ah did it.