-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCartItem.jsx
41 lines (32 loc) · 1.33 KB
/
CartItem.jsx
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
import {AiFillDelete} from "react-icons/ai"
import { useDispatch } from "react-redux";
import { remove } from "../redux/Slices/CartSlice";
import { toast } from "react-hot-toast";
const CartItem = ({item, itemIndex}) => {
const dispatch = useDispatch();
const removeFromCart = () => {
dispatch(remove(item.id));
toast.success("Item Removed");
}
return (
<div className="flex items-center p-2 md:p-5 justify-between mt-2 mb-2 md:mx-5 ">
<div className="flex flex-col md:flex-row p-0 md:p-3 gap-5 items-center">
<div className="w-[30%]">
<img className="object-cover " src={item.image} />
</div>
<div className="md:ml-10 self-start space-y-5 w-[100%] md:w-[70%]">
<h1 className="text-xl text-slate-700 font-semibold">{item.title}</h1>
<h1 className="text-base text-slate-700 font-medium">{item.description}</h1>
<div className="flex items-center justify-between">
<p className="font-bold text-lg text-green-600">{item.price}</p>
<div className="text-red-800 bg-red-200 group hover:bg-red-400 transition-transform duration-300 cursor-pointer rounded-full p-3 mr-3"
onClick={removeFromCart}>
<AiFillDelete/>
</div>
</div>
</div>
</div>
</div>
);
};
export default CartItem;