File size: 2,132 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import React from 'react'
import { ThemeConsumer } from '../context/ThemeContexts';
export default function CartItem ({item,value}) {
const {id, title, img, price, total, count} = item;
const {increment,decrement,removeItem} = value;
return (
<ThemeConsumer>
{({ theme }) => (
<div className="row my-2 text-capitalize text-center">
<div className="col-10 mx-auto col-lg-2">
<img src={img} style={{width:"5rem" , height:"5rem"}}className="img-fluid" alt="product"/>
</div>
<div className={theme ? "col-10 mx-auto col-lg-2 text-light" : "col-10 mx-auto col-lg-2"} >
<span className={theme ? "d-lg-none text-light" : "d-lg-none"}>product : </span>{title}
</div>
<div className={theme ? "col-10 mx-auto col-lg-2 text-light" : "col-10 mx-auto col-lg-2"}>
<span className={theme ? "d-lg-none text-light" : "d-lg-none"}>price : </span>{price}
</div>
<div className="col-10 mx-auto col-lg-2 my-2 my-lg-2-0">
<div className="d-flex justify-content-center">
<div>
<span className={theme ? "btn btn-light mx-1 text-black" : "btn btn-black mx-1"} onClick={()=>decrement(id)}>-</span>
<span className={theme ? "btn btn-light mx-1 text-black" : "btn btn-black mx-1"}>{count}</span>
<span className={theme ? "btn btn-light mx-1 text-black" : "btn btn-black mx-1"} onClick={() => increment(id)}>+</span>
</div>
</div>
</div>
{/**/}
<div className={theme ? "col-10 mx-auto col-lg-2 text-light" : "col-10 mx-auto col-lg-2"} >
<div className="cart-icon" onClick={()=>removeItem(id)}>
<i className="fas fa-trash"></i>
</div>
</div>
<div className={theme ? "col-10 mx-auto col-lg-2 text-light" : "col-10 mx-auto col-lg-2"} >
<strong>item total : $ {total}</strong>
</div>
</div>
)}
</ThemeConsumer>
)
}
|