Devendra174's picture
Upload folder using huggingface_hub
f5071ca verified
import React from "react";
import "./Product.css";
import { useStateValue } from "./StateProvider";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
function Product({ title, image, id, price, rating }) {
const [{ basket }, dispatch] = useStateValue();
const addToBasket = () => {
dispatch({
type: "ADD_TO_BASKET",
item: {
id,
title,
image,
price,
rating,
},
});
toast("Added item to basket!");
};
return (
<div className="product">
<div className="product__bestseller">BESTSELLER</div>
<div className="product__info">
<p>{title}</p>
<div className="product__price">
<small>$</small>
<strong>{price}</strong>
</div>
<div className="product__rating">
{Array(rating)
.fill()
.map((rate) => (
<p></p>
))}
</div>
</div>
<img src={image} alt="" />
<button onClick={addToBasket}>Add to Basket</button>
</div>
);
}
export default Product;