8.26 Adding Price To Order Summary
BurgerBuilder.js
BurgerBuilder.js
...
return (
<Fragment>
<Modal
show={this.state.purchasing}
modalClosed={this.purchaseCancelHandler}
>
<OrderSummary
ingredients={this.state.ingredients}
purchaseCancelled={this.purchaseCancelHandler}
purchaseContinued={this.purchaseContinueHandler}
price={this.state.totalPrice}
/>
</Modal>
...
OrderSummary.js
OrderSummary.js
import React, { Fragment } from "react";
import Button from "../../UI/Button/Button";
const orderSummary = (props) => {
const ingredientSummary = Object.keys(props.ingredients).map((igKey) => {
return (
<li key={igKey}>
<span style={{ textTransform: "capitalize" }}>{igKey}</span>:{" "}
{props.ingredients[igKey]}
</li>
);
});
return (
<Fragment>
<h3>Your Order</h3>
<p>A delicious burger with the following ingredients:</p>
<ul>{ingredientSummary}</ul>
<p>
<strong>Total Price: {props.price.toFixed(2)}</strong>
</p>
<p>Continue to Checkout?</p>
<Button btnType="Danger" clicked={props.purchaseCancelled}>
CANCEL
</Button>
<Button btnType="Success" clicked={props.purchaseContinued}>
CONTINUE
</Button>
</Fragment>
);
};
export default orderSummary;