diff --git a/src/components/Burger/BuildControls/BuildControl/BuildControl.js b/src/components/Burger/BuildControls/BuildControl/BuildControl.js
index f3a13f1..10b48e5 100644
--- a/src/components/Burger/BuildControls/BuildControl/BuildControl.js
+++ b/src/components/Burger/BuildControls/BuildControl/BuildControl.js
@@ -4,9 +4,9 @@ import classes from './BuildControl.css';
const buildControl = (props) => (
-
{props.Name}
+
{props.name}
-
+
)
diff --git a/src/components/Burger/BuildControls/BuildControls.js b/src/components/Burger/BuildControls/BuildControls.js
index 04c1351..bced256 100644
--- a/src/components/Burger/BuildControls/BuildControls.js
+++ b/src/components/Burger/BuildControls/BuildControls.js
@@ -13,7 +13,10 @@ const controls = [
const buildControls = (props) => (
{controls.map( ctrl => (
-
+ props.ingredientAdded(ctrl.type) }/>
))}
)
diff --git a/src/containers/BurgerBuilder/BurgerBuilder.js b/src/containers/BurgerBuilder/BurgerBuilder.js
index d618045..bd9dcc2 100644
--- a/src/containers/BurgerBuilder/BurgerBuilder.js
+++ b/src/containers/BurgerBuilder/BurgerBuilder.js
@@ -4,6 +4,13 @@ import Aux from '../../hoc/Auxiliary';
import Burger from '../../components/Burger/Burger';
import BuildControls from '../../components/Burger/BuildControls/BuildControls';
+const INGREDIENT_PRICE = {
+ salad: 0.4,
+ bacon: 0.8,
+ cheese: 0.5,
+ meat: 1.3,
+};
+
class BurgerBuilder extends Component {
state = {
@@ -12,14 +19,36 @@ class BurgerBuilder extends Component {
cheese: 0,
salad: 0,
bacon: 0,
- }
+ },
+ totalPrice: 0,
+ }
+
+ addIngredientHandler = (type) => {
+ const oldCount = this.state.ingredients[type];
+ const newCount = oldCount + 1;
+ const updatedIngredient = {
+ ...this.state.ingredients,
+ };
+ updatedIngredient[type] = newCount;
+
+ const priceAddition = INGREDIENT_PRICE[type];
+ const newPrice = this.state.totalPrice + priceAddition;
+ this.setState({
+ totalPrice: newPrice,
+ ingredients: updatedIngredient,
+ });
+ }
+
+ removeIngredientHandler = (type) => {
+
}
render() {
return (
-
+
);
};