File size: 3,956 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
71
72
73
74
import React, { Component } from 'react'
import {ProductConsumer} from '../context';
import {Link} from 'react-router-dom';
import {ButtonContainer} from './Button';
import { ThemeConsumer } from './context/ThemeContexts';

export default class Details extends Component {
    render() {
        return (
            <ThemeConsumer>
            {({ theme }) => (
            <ProductConsumer>
                {value=>{
                   const {id, company, img, info, price, title, inCart} = value.detailProduct; 
                   return(
                       <div className={theme ? "container py-5 bg-slate-900" : "container py-5 "}>
                           {/*title*/}
                            <div className="row>">
                                <div className={theme? "col-10 mx-auto text-center text-slanted text-primary my-5" : "col-10 mx-auto text-center text-slanted text-blue my-5"}>
                                    <h1>{title}</h1>
                                </div>
                            </div>
                            {/*end of title*/}
                            {/*product info*/}
                            <div className="row">
                                <div className="col-10 mx-auto col-md-6 my-3 text-capitalize">
                                    <img src={img} className="img-fluid" alt="product" />
                                </div>
                            {/*product text*/}
                                <div className={theme ? "col-10 mx-auto col-md-6 my-3 text-capitalize text-light" : "col-10 mx-auto col-md-6 my-3 text-capitalize"}>
                                    <h2>model:{title}</h2>
                                    <h4 className={theme ? "text-title text-uppercase text-white mt-3 mb-2" : "text-title text-uppercase text-muted mt-3 mb-2"}>
                                        made by: <span className="text-uppercase">{company}</span>
                                    </h4>
                                    <h4 className={theme ? "text-primary" : "text-blue"}>
                                        <strong>
                                            Price : <span>$</span>{price}
                                        </strong>
                                    </h4>
                                    <p className={theme ? "text-capitalize font-weight-bold mt-3 mb-0 text-info" : "text-capitalize font-weight-bold mt-3 mb-0"}>
                                            some info about product
                                    </p>
                                    <p className={theme ? "lead text-light" :"text-muted lead"}>
                                        {info}
                                    </p>
                                    {/*buttons*/}
                                    <div>
                                       <Link to="/">
                                           <ButtonContainer>
                                               back to products
                                           </ButtonContainer>
                                        </Link>
                                            <ButtonContainer cart disabled={inCart ? true : false}
                                                onClick={() => {
                                                    value.addToCart(id);
                                                    value.openModal(id);
                                                }}>
                                               {inCart ? "inCart" : "add to cart"}
                                            </ButtonContainer>
                                    </div>
                                </div>
                            </div>
                        </div>
                      
                       
                   ); 
                }}
            </ProductConsumer>
             )}
             </ThemeConsumer>
        )
    }
}