source: frontend/src/components/Product.js@ b612ab1

Last change on this file since b612ab1 was b612ab1, checked in by Nace Gjorgjievski <nace.gorgievski123@…>, 22 months ago

Basic functions added

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import React, { useContext } from "react";
2import "../styles/Product.css";
3import ShoppingBasketIcon from "@mui/icons-material/ShoppingCart";
4import { Link } from "react-router-dom";
5import { Store } from "../Store";
6
7function Product({ product }) {
8 const { state, dispatch: ctxDispatch } = useContext(Store);
9 const addToCartHandler = () => {
10 ctxDispatch({
11 type: "CART_ADD_ITEM",
12 payload: { ...product, quantity: 1 },
13 });
14 };
15 return (
16 <div className="product__container">
17 <Link to={`/product/${product.slug}`}>
18 <div className="product__img">
19 <img src={product.image} alt="product"></img>
20 </div>
21 </Link>
22 <div className="product__textContainer">
23 <Link to={`/product/${product.slug}`}>
24 <div className="product__name">
25 <h3>{product.name}</h3>
26 </div>
27 </Link>
28 <div className="product__price">
29 <h5>{product.price}ден</h5>
30 </div>
31 </div>
32 <div className="product__addToCart">
33 <button onClick={addToCartHandler}>
34 <ShoppingBasketIcon />
35 </button>
36 </div>
37 </div>
38 );
39}
40
41export default Product;
Note: See TracBrowser for help on using the repository browser.