-
Notifications
You must be signed in to change notification settings - Fork 0
/
Product.js
70 lines (69 loc) · 2.58 KB
/
Product.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { useState } from 'react'
import { ArrowUpCircleFill, Chat } from 'react-bootstrap-icons'
import ProductModal from './ProductModal'
import $ from 'jquery'
const Product = (props) => {
const [productVotes, setProductVotes] = useState(props.ProductVotes)
const [showProduct, setShowProduct] = useState(false)
const alt = `Product ${props.id}`
return (
<div>
<div
className="product-info rounded"
onClick={(e) => {
var elementType = $(e.target).prop('nodeName')
console.log(elementType)
if (
elementType == 'BUTTON' ||
elementType == 'svg' ||
elementType == 'path' ||
elementType == 'A'
) {
setShowProduct(false)
} else {
setShowProduct(true)
}
}}
>
<div className="product-image-wrapper">
<img
className="product-image"
src={props.ProductImg}
alt={alt}
></img>
</div>
<div className="product-description">
<h6 className="product-name">{props.ProductName}</h6>
<p className="product-breef">{props.ProductDescription}</p>
<div className="product-footer">
<button className="btn btn-white btn-sm comment-button">
<Chat />
{props.CommentsNum}
</button>
<a className="category-link" href={props.CategoryLink}>
{props.ProductCategory}
</a>
</div>
</div>
<div className="vote-button-warrper">
<button
id="vote-button"
className="btn btn-white vote-button"
onClick={() => {
setProductVotes(productVotes + 1)
}}
>
<ArrowUpCircleFill />
{productVotes}
</button>
</div>
</div>
<ProductModal
{...props}
show={showProduct}
onHide={() => setShowProduct(false)}
/>
</div>
)
}
export default Product