Commit e2db9d87 authored by zarina's avatar zarina 🌊

#5, выведены в корзину данные о заказе

parent 95600ec5
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
border: 3px solid silver; border: 3px solid silver;
min-height: 400px; min-height: 400px;
border-radius: 10px 0 0 10px; border-radius: 10px 0 0 10px;
padding-top: 20px;
} }
\ No newline at end of file
...@@ -2,11 +2,24 @@ import React from "react"; ...@@ -2,11 +2,24 @@ import React from "react";
import BasketItem from "./BasketItem/BaskeItem"; import BasketItem from "./BasketItem/BaskeItem";
import TotalPrice from "./TotalPrice/TotalPrice"; import TotalPrice from "./TotalPrice/TotalPrice";
import './Basket.css' import './Basket.css'
const Basket = props => { const Basket = props => {
let basketElements = Object.keys(props.basket);
let emptyBasket = 'Basket empty. Please, add items';
let createBasket = () => {
return basketElements.map((elem, i) => {
return <BasketItem
key={'BasketItem-' + {elem} + i}
qty={props.basket[elem]}
price={props.menuList[elem].price}
name={elem}/>;
});
}
return ( return (
<div className='Basket'> <div className='Basket'>
<BasketItem/> {basketElements.length > 0 ? createBasket() : emptyBasket}
<TotalPrice/> {props.totalPrice > 0 ? <TotalPrice totalPrice={props.totalPrice}/> : null}
</div> </div>
); );
}; };
......
...@@ -4,9 +4,12 @@ import './BasketItem.css' ...@@ -4,9 +4,12 @@ import './BasketItem.css'
const BasketItem = props => { const BasketItem = props => {
return ( return (
<div className='BasketItem'> <div className='BasketItem'>
<h3> testik </h3> <h3> {props.name} </h3>
<span> 232 KZT </span> <div>
<span>x22</span> </div> <span> {props.price} KZT </span>
<span> <b> x{props.qty} </b></span>
</div>
</div>
); );
}; };
......
.TotalPrice{ .TotalPrice{
border-top: 1px solid black; border-top: 1px solid black;
padding-top: 10px; padding-top: 10px;
margin-top: 10px;
} }
\ No newline at end of file
...@@ -3,7 +3,8 @@ import './TotalPrice.css' ...@@ -3,7 +3,8 @@ import './TotalPrice.css'
const TotalPrice = props => { const TotalPrice = props => {
return ( return (
<div className='TotalPrice'> <div className='TotalPrice'>
4234234 KZT</div> <span>Total price: {props.totalPrice}KZT </span>
</div>
); );
}; };
......
...@@ -47,11 +47,12 @@ class App extends Component { ...@@ -47,11 +47,12 @@ class App extends Component {
let totalPrice = this.state.totalPrice + this.state.menu[name].price; let totalPrice = this.state.totalPrice + this.state.menu[name].price;
this.setState({totalPrice, basket}) this.setState({totalPrice, basket})
}; };
render() {
render() {
return ( return (
<div className='App'> <div className='App'>
<Basket/> <Basket menuList={this.state.menu} totalPrice={this.state.totalPrice} basket={this.state.basket}/>
<Menu menuList={this.state.menu} addElement={this.addElement}/> <Menu menuList={this.state.menu} addElement={this.addElement}/>
</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