-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCartItem.js
50 lines (44 loc) · 1.28 KB
/
CartItem.js
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
44
45
46
47
48
49
50
// import React, { useState } from "react";
import FormatPrice from "../Helpers/FormatPrice";
import CartAmountToggle from "./CartAmountToggle";
import { FaTrash } from "react-icons/fa";
import { useCartContext } from "../context/cart_context";
const CartItem = ({ id, name, image, color, price, amount }) => {
const { removeItem, setDecrease, setIncrement } = useCartContext();
return (
<div className="cart_heading grid grid-five-column">
<div className="cart-image--name">
<div>
<figure>
<img src={image} alt={id} />
</figure>
</div>
<div>
<p>{name}</p>
</div>
</div>
{/* price */}
<div className="cart-hide">
<p>
<FormatPrice price={price} />
</p>
</div>
{/* Quantity */}
<CartAmountToggle
amount={amount}
setDecrease={() => setDecrease(id)}
setIncrease={() => setIncrement(id)}
/>
{/* //Subtotal */}
<div className="cart-hide">
<p>
<FormatPrice price={price * amount} />
</p>
</div>
<div>
<FaTrash className="remove_icon" onClick={() => removeItem(id)} />
</div>
</div>
);
};
export default CartItem;