File size: 2,670 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
import React, { Component } from 'react'
import styled from 'styled-components';
import {ProductConsumer} from '../context';
import {ButtonContainer} from './Button';
import {Link} from 'react-router-dom';
import { ThemeConsumer } from './context/ThemeContexts';

export default class Modal extends Component {
    render() {
        return (
            <ThemeConsumer>
        {({ theme }) => (
            <ProductConsumer>
                {(value)=>{
                    const {modalOpen,closeModal} =value;
                    const {img, title,price} = value.modalProduct;
                    if(!modalOpen){
                        return null;
                    }else{
                        return (
                            < ModalContainer >
                            <div className="container">
                                <div className="row">
                                    <div id="modal" className=
                                    {theme ? "col-8 mx-auto col-md-6 col-lg-4 text-capitalize text-center p-5 bg-dark" : "col-8 mx-auto col-md-6 col-lg-4 text-capitalize text-center p-5"}
                                    >
                                    <h5 className={theme && "text-white" }>item added to the cart</h5>
                                    <img src={img} className="img-fluid" alt="product" />
                                    <h5 className={theme && "text-light" }>{title}</h5>
                                    <h5 className={theme ? "text-light" : "text-muted"}>price : $ {price}</h5>
                                    <Link to='/'>
                                    <ButtonContainer onClick={()=>closeModal()}>
                                        continue shopiing
                                    </ButtonContainer>
                                    </Link>
                                    <Link to='/cart'>
                                    <ButtonContainer cart onClick={() => closeModal()}>
                                         go to cart
                                    </ButtonContainer>
                                    </Link>
                                    </div>
                                </div>
                            </div>
                        </ModalContainer>
                        );
            }
                
        }}
            </ProductConsumer>
             )}
             </ThemeConsumer>
        );
    }
}
const ModalContainer =styled.div`
position:fixed;
top:0;
left:0;
right:0;
bottom:0;
background:rgba(0,0,0,0.3);
display:flex;
align-items:center;
justify-content:center;
#modal{
    background:var(--mainWhite);
}
`;