Commit d83ca88e authored by Shaphen's avatar Shaphen

[AFP-47 Shaphen Pangburn]: Add basic style formatting and add logic to not...

[AFP-47 Shaphen Pangburn]: Add basic style formatting and add logic to not include null products in list display
parent 5273149e
...@@ -24,34 +24,39 @@ export default class ProductMarket extends Component { ...@@ -24,34 +24,39 @@ export default class ProductMarket extends Component {
products.forEach(prod => { products.forEach(prod => {
promotions.forEach(promo => { promotions.forEach(promo => {
if (prod.sku === promo.productSku) { if (prod.sku === promo.productSku) {
debugger prod.promo = (promo.discountPercentage * 100);
prod.promo = promo.discountPercentage;
} }
}); });
}); });
return ( return (
<div> <div className="product-market-container">
<h1 id="product-market-title">Product Market</h1>
<div className="products-container">
{this.props.products.map(prod => { {this.props.products.map(prod => {
return ( return (
prod.productName ? <div className="product-item">
{prod.productName ?
<div key={ prod.sku }> <div key={ prod.sku }>
<p>{ prod.productName }</p> <img id="prod-img" src={ prod.productImageUrl ? prod.productImageUrl : "-no photo-" } />
<p>{ prod.productDescription }</p> <p id="prod-name">{ prod.productName }</p>
<p>${ prod.price }</p> <p id="prod-description">{ prod.productDescription }</p>
<p> <p id="prod-price">${ prod.price }</p>
{ prod.promo ? "This has a promotion for " <p id="prod-promotion">
{ prod.promo ? "Order now for "
+ prod.promo + prod.promo
+ "% off, making it now " + "% off, making it "
+ this.calculateDiscount(prod.price, prod.promo) + this.calculateDiscount(prod.price, prod.promo)
+ "!" : "" } + "!" : "" }
</p> </p>
<button>Add to Cart</button> <button id="add-to-cart-button">Add to Cart</button>
<p>_________________________________</p> </div>
</div> : "" : ""}
</div>
) )
})} })}
</div> </div>
</div>
) )
} }
} }
.product-market-container {
width: 100%;
display: flex;
justify-content: center;
flex-wrap: wrap;
}
#product-market-title {
width: 100%;
text-align: center;
}
.products-container {
width: 100%;
display: flex;
flex-wrap: wrap;
}
#prod-img {
width: 250px;
}
\ No newline at end of file
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