SessionExpired.js
3.91 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React, { Component } from 'react'
import ReactModal from 'react-modal';
import {NavLink} from 'react-router-dom';
import * as SelectActionCreators from '../actions/profilationSelect'
import { connect } from 'react-redux';
import closeIcon from '../../img/closed_modal.svg'
import endActivation from './img/end_activation.svg'
import data from './data.json'
class SessionExpired extends Component {
constructor(props) {
super(props);
this.state = {
email:'',
name:'',
privacy:true,
buttonDisabled: true
};
this.handleChange = this.handleChange.bind(this);
this.handleCheckbox = this.handleCheckbox.bind(this);
this.redirect=this.redirect.bind(this)
}
redirect(){
window.location.href='http://www.repower.com'
}
handleCheckbox(e){
const target = e.currentTarget;
this.form.validateFields(target);
const checkbox= !this.state.privacy
const disable= !checkbox
this.setState({
name:this.state.name,
email: this.state.email,
privacy: checkbox,
buttonDisabled: disable
});
}
handleChange(e) {
const target = e.currentTarget;
this.form.validateFields(target);
const isValid=this.form.fieldsStore.fields.email.warnings.size===0 &&
this.form.fieldsStore.fields.email.errors.size===0 &&
this.state.email!=='' &&
this.form.fieldsStore.fields.name.warnings.size===0 &&
this.form.fieldsStore.fields.name.errors.size===0 &&
this.state.name!==''
const checkbox= this.state.privacy
const disable= !isValid
this.setState({
privacy: checkbox,
[target.name]: target.value,
buttonDisabled: disable
});
}
render(){
return(
<ReactModal
isOpen={true}
onRequestClose={() => this.props.hideModal()}
portalClassName='modal modal-mask modal_repower modal_repower__contact modal_repower__contact_confirm modal-confirm isOpen'
overlayClassName='modal-wrapper'
className='modal-container'
>
<div className="close_modal" onClick={()=>this.props.updateStoreValue('modalOpen',[])}><img src={closeIcon} alt="" /></div>
<div className=" modal-header">
<img src={endActivation} alt="" />
<h3>{data.modalStrings.sessionExpired.title}</h3>
</div>
<div className="modal-body">
<p className="modal-description">{data.modalStrings.sessionExpired.text}</p>
</div>
<div className="modal-footer">
<NavLink to={`/`} activeClassName="active">
<button className="btn btn__red"
onClick={() => this.props.hideModal()}>Aggiorna soluzione
</button>
</NavLink>
</div>
</ReactModal>
)
}
}
const mapStateToProps = state => {
return {
steps:state.ProfilationSelectReducer.steps,
solutions:state.ProfilationSelectReducer.solutions,
modalOpen:state.ProfilationSelectReducer.modalOpen,
modalContacts:state.ProfilationSelectReducer.modalContacts
}};
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)(SessionExpired);