Commit 121f21bd authored by Kyle Muldoon's avatar Kyle Muldoon

Quantity field repaired, each list item given a key, IDs on list-items changed to className

parent 5a11c551
...@@ -9,25 +9,25 @@ export default function CartItem(props) { ...@@ -9,25 +9,25 @@ export default function CartItem(props) {
{/* Flex-Direction: Row */} {/* Flex-Direction: Row */}
{/* Left image div */} {/* Left image div */}
<div id="productImageContainer"> <div className="productImageContainer">
<img className="productImage" alt="" src={props.productInfo.productImageUrl} /> <img className="productImage" alt="Product" src={props.productInfo.productImageUrl} />
</div> </div>
{/* Name and Product details */} {/* Name and Product details */}
<div id="nameAndDetails"> <div className="nameAndDetails">
<div id="productName">{props.productInfo.productName}</div> <div className="productName">{props.productInfo.productName}</div>
<div id="productStock">{props.productInfo.availableStock} left in stock</div> <div className="productStock">{props.productInfo.availableStock} left in stock</div>
<div id="quantityControls"> <div className="quantityControls">
<select id="productQuantitySelect"><option>{props.productInfo.quantity}</option></select> <select className="productQuantitySelect"><option>{props.quantity}</option></select>
<button>Delete</button> <button>Delete</button>
</div> </div>
</div> </div>
{/* Price and promotions */} {/* Price and promotions */}
<div id="priceAndPromotions"> <div className="priceAndPromotions">
<div id="productPrice">${props.productInfo.price.toFixed(2)}</div> <div className="productPrice">${props.productInfo.price.toFixed(2)}</div>
</div> </div>
</div> </div>
......
...@@ -34,13 +34,13 @@ ...@@ -34,13 +34,13 @@
justify-content: space-between; justify-content: space-between;
} }
#productName { .productName {
padding-top: 25px; padding-top: 25px;
margin-bottom: 15px; margin-bottom: 15px;
font-size: 125%; font-size: 125%;
} }
#productImageContainer { .productImageContainer {
display: flex; display: flex;
width: 30%; width: 30%;
margin-right: 20px; margin-right: 20px;
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
/* max-height: 100%; */ /* max-height: 100%; */
} }
#nameAndDetails { .nameAndDetails {
display: flex; display: flex;
width: 45%; width: 45%;
height: 200px; height: 200px;
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
text-align: left; text-align: left;
} }
#priceAndPromotions { .priceAndPromotions {
display: flex; display: flex;
width: 10%; width: 10%;
height: 200px; height: 200px;
...@@ -73,20 +73,20 @@ ...@@ -73,20 +73,20 @@
align-items: flex-end; align-items: flex-end;
} }
#productPrice { .productPrice {
margin-top: 40px; margin-top: 40px;
font-size: 125%; font-size: 125%;
font-weight: bold; font-weight: bold;
} }
#quantityControls{ .quantityControls{
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: flex-start;
align-items: flex-end; align-items: flex-end;
} }
#productQuantitySelect { .productQuantitySelect {
width: 40px; width: 40px;
} }
......
...@@ -16,12 +16,16 @@ export default function ShoppingCart() { ...@@ -16,12 +16,16 @@ export default function ShoppingCart() {
const productsFromRefs = [] const productsFromRefs = []
cartRefs.map((cartRef) => { cartRefs.map((cartRef) => {
productsFromRefs.push(allProducts.filter((currProduct) => currProduct.sku === cartRef.productRef.sku)[0]) let tempCartItem = {
product: allProducts.filter((currProduct) => currProduct.sku === cartRef.productRef.sku)[0],
quantity: cartRef.quantity
}
productsFromRefs.push(tempCartItem)
}) })
setCartItems(productsFromRefs) setCartItems(productsFromRefs)
}, [cartRefs]) }, [cartRefs])
...@@ -33,7 +37,7 @@ export default function ShoppingCart() { ...@@ -33,7 +37,7 @@ export default function ShoppingCart() {
<div id="cartItemList"> <div id="cartItemList">
{cartItems.map((currItem) => { {cartItems.map((currItem) => {
return ( return (
<CartItem productInfo={currItem} /> <CartItem productInfo={currItem.product} quantity={currItem.quantity} key={currItem.product.sku}/>
) )
})} })}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment