-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProduct.js
40 lines (39 loc) · 1.36 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
import React, { Component } from 'react'
import { ProductWrapper } from './Styling'
import { Link } from 'react-router-dom'
import { ProductConsumer } from '../context'
export default class Product extends Component {
render() {
const { id, title, img, price, inCart } = this.props.product;
return (
<ProductWrapper className="col-9 mx-auto col-md-6 col-lg-3 my-3">
<div className="card">
{/*card header */}
<div className="card-header d-flex justify-content-between">
<p className="title-num align-self-center mb-0">
{id}
</p>
</div>
<div className="img-container p-5" onClick={()=>console.log('you fucked')}>
<Link to="/Detail">
<img src={img} alt="product" className="card-img-top"/>
</Link>
<button className="cart-btn" disabled={inCart?true:false} onClick={()=>{console.log('added to cart')}}>
{inCart ? (<p className="text-capitalize mb-0" disabled>in cart</p>) : (<i className="fas fa-cart-plus" />)}
</button>
</div>
{/*card footer */}
<div className="card-footer d-flex justify-content-between">
<p className="align-self-center mb-0">
{title}
</p>
<h5 className="text-blue font-italic mb-0">
<span className="me-0">$</span>
{price}
</h5>
</div>
</div>
</ProductWrapper>
)
}
}