Last change
on this file since 55ed171 was 55ed171, checked in by Nace Gjorgjievski <nace.gorgievski123@…>, 21 months ago |
Full Admin Functionality Added
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | import React, { useContext } from "react";
|
---|
2 | import "../styles/Product.css";
|
---|
3 | import ShoppingBasketIcon from "@mui/icons-material/ShoppingCart";
|
---|
4 | import { Link } from "react-router-dom";
|
---|
5 | import { Store } from "../Store";
|
---|
6 |
|
---|
7 | function 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}`} style={{ height: "165.91px" }}>
|
---|
18 | <div className="product__img" style={{ height: "100%" }}>
|
---|
19 | <img
|
---|
20 | src={product.image}
|
---|
21 | alt="product"
|
---|
22 | style={{ height: "100%" }}
|
---|
23 | ></img>
|
---|
24 | </div>
|
---|
25 | </Link>
|
---|
26 | <div className="product__textContainer">
|
---|
27 | <Link to={`/product/${product.slug}`}>
|
---|
28 | <div className="product__name">
|
---|
29 | <h3>{product.name}</h3>
|
---|
30 | </div>
|
---|
31 | </Link>
|
---|
32 | <div className="product__price">
|
---|
33 | <h5>{product.price}ден</h5>
|
---|
34 | </div>
|
---|
35 | </div>
|
---|
36 | <div className="product__addToCart">
|
---|
37 | <button onClick={addToCartHandler}>
|
---|
38 | <ShoppingBasketIcon />
|
---|
39 | </button>
|
---|
40 | </div>
|
---|
41 | </div>
|
---|
42 | );
|
---|
43 | }
|
---|
44 |
|
---|
45 | export default Product;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.