ContactConfirm.js
3.86 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
import React, { Component } from 'react'
import ReactModal from 'react-modal';
import * as SelectActionCreators from '../actions/profilationSelect'
import { connect } from 'react-redux';
import greenCheck from './img/greenCheck.svg'
/*
<div className="Modal Modal-mask modal_repower Modal--save isOpen">
<div className="Modal-wrapper">
<div className="Modal-container" >
*/
class ContactModal 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);
}
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
});
console.log('isValid',this.state)
}
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
console.log('isValid',this.form.fieldsStore.fields)
const disable= !isValid
this.setState({
privacy: checkbox,
[target.name]: target.value,
buttonDisabled: disable
});
console.log('isValid',this.state)
}
render(){
return(
<ReactModal
isOpen={true}
onRequestClose={() => this.props.hideModal()}
portalClassName='modal modal-mask modal_repower modal_repower__contact modal_repower__contact_confirm 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 class=" modal-header">
<img src={greenCheck} alt="" />
<h3> Perfetto, abbiamo ricevuto la tua richiesta!</h3>
</div>
<div class="modal-body">
<p class="modal-description">Sarai contattato da un nostro personal trainer che ti potrà guidare nella scelta di un'offerta adatta alle tue esigenze.</p>
<p class="modal-description">Nell'attesa, scopri tutte le offerte per energia e gas nel nostro portale.</p>
</div>
<div class="modal-footer">
<button className='btn__red'>Vai su Repower.com</button>
</div>
</ReactModal>
)
}
}
const mapStateToProps = state => {
return {
steps:state.ProfilationSelectReducer.steps,
solutions:state.ProfilationSelectReducer.solutions,
modalOpen:state.ProfilationSelectReducer.modalOpen
}};
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)(ContactModal);