WayoutModal.js
4.04 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import React, { Component } from 'react'
import ReactModal from 'react-modal';
import * as SelectActionCreators from '../actions/profilationSelect'
import { connect } from 'react-redux';
import wayoutIcon from '../../img/wayOut.svg'
/*
<div className="Modal Modal-mask modal_repower Modal--save isOpen">
<div className="Modal-wrapper">
<div className="Modal-container" >
*/
class WayoutModal extends Component {
constructor(props){
super(props)
this.handleSubmit=this.handleSubmit.bind(this)
}
handleSubmit(){
this.props.hideModal()
this.props.showModal('SAVE_MODAL')
}
redirect(){
window.location.href='http://www.repower.com'
}
render(){
const saved=(this.props.activationSteps[2].isComplete||this.props.modalContacts.activationSaveModal.contact.valid)
return(
<ReactModal
isOpen={true}
onRequestClose={() => this.props.hideModal()}
portalClassName='modal modal-mask modal_repower quit-modal isOpen'
overlayClassName='modal-wrapper'
className='modal-container'
>
<div className="close_modal" onClick={() => this.props.hideModal()}><img src="https://d33wubrfki0l68.cloudfront.net/c0553300c767c895ee4900759828af6476c3e9e9/55953/img/closed_modal.svg" alt="" /></div>
<div className=" modal-header">
<img src={wayoutIcon} alt="" />
<h3> Sei sicuro di voler uscire e abbandonare l'attivazione?</h3>
</div>
<div className="modal-body">
{saved && <p className="modal-description">Ricorda che il tuo processo è salvato e che potrai comunque riprendere l’attivazione in un qualsiasi momento con la funzione “riprendi attivazione”
inserendo il tuo indirizzo email e il codice repower.</p>}
{saved &&<p>
Codice Repower:<br/>
<strong>{this.props.activationCode}</strong>
</p>}
{!saved &&
<p>
Abbandonando il processo di attivazione perderai tutti i progressi fatti fino ad ora
e sarai costretto ad iniziare una nuova configurazione. Se preferisci puoi salvare la configurazione
e continuare con l'attivazione in un secondo momento.
</p>
}
<div className='modal-flex'>
<a className='button-link' onClick={()=>this.redirect()} ><button className="btn__outline">
Abbandona attivazione
</button></a>
{saved && <a className='button-link'><button className="btn__red" onClick={() => this.props.hideModal()}>
Continua con l'attivazione
</button></a>}
{ !saved && <a className='button-link'><button className="btn__red" onClick={() => this.handleSubmit()}>
Salva e riprendi dopo
</button></a>}
</div>
</div>
</ReactModal>
)
}
}
const mapStateToProps = state => {
return {
activationSteps:state.ProfilationSelectReducer.activationSteps,
steps:state.ProfilationSelectReducer.steps,
solutions:state.ProfilationSelectReducer.solutions,
modalOpen:state.ProfilationSelectReducer.modalOpen,
modalContacts:state.ProfilationSelectReducer.modalContacts,
activationCode:state.ProfilationSelectReducer.activationCode,
}};
const mapDispatchToProps = dispatch => ({
updatePropValue: (prop,value,index,complete) =>
dispatch(SelectActionCreators.changeValue(prop,value,index,complete)),
updateStoreValue: (prop,value) =>
dispatch(SelectActionCreators.changeProp(prop,value)),
hideModal: () =>
dispatch(SelectActionCreators.hideModal()),
showModal: (modalName) =>
dispatch(SelectActionCreators.showModal(modalName)),
});
export default connect(mapStateToProps, mapDispatchToProps)(WayoutModal);