-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckoutProduct.js
45 lines (34 loc) · 1.15 KB
/
CheckoutProduct.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
import React from 'react';
import "./CheckoutProduct.css";
import { useStateValue } from './StateProvider';
function CheckoutProduct({id,title,image,price,rating}) {
const [{},dispatch] = useStateValue();
// console.log(id,title,image,price,rating);
const removeFromBasket = () =>{
dispatch({
type: "REMOVE_FROM_BASKET",
id:id,
});
}
return (
<div className='checkoutProduct'>
<img className='checkoutProduct__image' src={image} alt="" />
<div className="checkoutProduct__info">
<p className='checkoutProduct__title'>{title}</p>
<p className='checkoutProduct__price'>
<small>₹</small>
<strong>{price}</strong>
</p>
<div className="checkoutProduct__rating">
{Array(rating)
.fill()
.map((_, i)=>(
<p>⭐</p>
))}
</div>
<button onClick={removeFromBasket}>Remove from Basket</button>
</div>
</div>
)
}
export default CheckoutProduct;