ActivationStep1.js
8.3 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
import React, { Component } from 'react';
import DocumentBox from '../components/DocumentBox'
import stepOne from '../../../img/stepone.svg'
import greenCheck from '../../../img/outlineGreenCheck.svg'
import idIcon from '../../../img/id.svg'
import cfIcon from '../../../img/codice_fiscale_icon.svg'
import RightBox from '../components/RightBox'
import Sticky from 'react-sticky-el';
import * as SelectActionCreators from '../../actions/profilationSelect'
import {connect} from 'react-redux';
import { Motion, spring} from 'react-motion';
class ActivationStep1 extends Component{
constructor(props){
super(props)
this.state={
idSamefile:this.props.idSamefile,
cfSamefile:this.props.cfSamefile,
isComplete: false,
scrollTop:0
}
this.handleCheckbox = this.handleCheckbox.bind(this);
this.nextStep = this.nextStep.bind(this);
//this.editStep = this.editStep.bind(this);
}
/*editStep(){
this.setState({
...this.state,
})
this.props.updateStoreValue('activationActiveStep',0)
for (var i = this.props.activationSteps.length - 1; i >= 0; i--) {
this.props.updateActivation(i,'isActive',i===this.props.index)
}
}*/
nextStep(){
this.setState({
...this.state,
scrollTop:0
})
this.props.updateActivation(this.props.index,'isActive',false)
this.props.updateActivation(this.props.index+1,'isActive',true)
this.props.updateStoreValue('activationActiveStep',1)
}
handleCheckbox(check){
const checkVal=!this.state[check.checkId]
this.setState({
...this.state,
[check.checkId]:checkVal
})
this.props.updateStoreValue(check.checkId,checkVal)
console.log('checkval',checkVal)
var nofile='NoFile'
if(!checkVal)
nofile=''
this.props.updateActivation(this.props.index,check.docId,nofile)
var complete=checkVal;
for (var property in this.props.step) {
if (this.props.step.hasOwnProperty(property)) {
if(property!=='isComplete'&&property!=='isActive' && property!==check.docId){
console.log(this.props.step, property, this.props.step[property])
complete=complete&&this.props.step[property]!==''
}
}
}
this.props.updateActivation(this.props.index,'isComplete',complete)
}
render() {
const activationStep=this.props.activationSteps[this.props.index]
const loading=activationStep.idCard_front_loading||
activationStep.idCard_back_loading||
activationStep.cfCard_front_loading||
activationStep.cfCard_back_loading
var stepClass='attivazione-step attivazione-step-1'
if(this.props.step.isActive)
{
stepClass=stepClass+' open'
}
else
{
stepClass=stepClass+' closed'
}
if(this.props.step.isComplete)
{
stepClass=stepClass+' complete'
}
return(
<div id='activation-step1' className={stepClass}>
<div className='attivazione-step-left-col attivazione-steps-inner'>
<div className='attivazione-head'>
<div className="wrapper-attivazione-head">
<figure>
{this.props.step.isComplete && <img className="attivazione-head-step-icon" src={greenCheck} alt='' />}
{!this.props.step.isComplete && <img className="attivazione-head-step-icon" src={stepOne} alt='' />}
</figure>
<h2>Carica documenti intestatario</h2>
</div>
<h2 className='edit-step' data-step-id='1' onClick={() => this.props.editStep(this.props.index)}>Modifica</h2>
{ (this.props.step.isActive && window.innerWidth<768) &&
<p>
Formati accettati; jpg, png, tiff e pdf
</p>
}
{ (this.props.step.isActive && window.innerWidth>=1024) &&
<p>
Carica la carta d'identità e il codice fiscale dell'intestatario del contratto di fornitura.
<br/>Le scansioni, o le fotografie, devono essere nitide e ben leggibili in formato jpg, png, tiff, pdf.
</p>}
</div>
<div className='attivazione-step-body'>
<div className='attivazione-document-section '>
<h2>
Carta d'identità
</h2>
<p>
<input type="checkbox" name="samefile" id="idCard" className='samefile' onChange={() => this.handleCheckbox({checkId:'idSamefile',docId:'idCard_back'})} value={this.props.idSamefile} checked={!!this.props.idSamefile}/>
<label htmlFor="idCard"><span className="isCheckbox"></span>Fronte e retro nello stesso file</label>
</p>
</div>
<ul className='attivazione-doc-list'>
<DocumentBox
name="Carta d'identità"
icon={idIcon}
side={this.state.idSamefile? 'Fronte e retro':'Fronte'}
defaultFilename=''
index={this.props.index}
propName='idCard_front'
step={this.props.step}
maxPhotos={this.state.idSamefile? 2:1}
/>
{!this.props.idSamefile &&<DocumentBox
name="Carta d'identità"
icon={idIcon}
side="Retro"
defaultFilename=''
index={this.props.index}
propName='idCard_back'
step={this.props.step}
maxPhotos={this.state.idSamefile? 2:1}
/>}
</ul>
<div className='attivazione-document-section attivazione-document-section__cf'>
<h2>
Codice Fiscale
</h2>
<p>
<input type="checkbox"
name="samefile"
id="cfCard"
className='samefile'
onChange={() => this.handleCheckbox({checkId:'cfSamefile',docId:'cfCard_back'})}
value={this.props.cfSamefile}
checked={!!this.props.cfSamefile}/>
<label htmlFor="cfCard"><span className="isCheckbox"></span>Fronte e retro nello stesso file</label>
</p>
</div>
<ul className='attivazione-doc-list'>
<DocumentBox
name="Codice Fiscale"
icon={cfIcon}
side={this.state.cfSamefile? 'Fronte e retro':'Fronte'}
defaultFilename=''
index={this.props.index}
propName='cfCard_front'
step={this.props.step}
maxPhotos={this.state.cfSamefile? 2:1}
/>
{!this.props.cfSamefile &&<DocumentBox
name="Codice Fiscale"
icon={cfIcon}
side="Retro"
defaultFilename=''
index={this.props.index}
propName='cfCard_back'
step={this.props.step}
maxPhotos={this.state.cfSamefile? 2:1}
/>}
</ul>
</div>
{
this.props.step.isActive &&
<button className={(this.props.step.isComplete && !loading)? "btn__red":"btn__grayLighter no-events"} onClick={() => this.nextStep()} >Prosegui</button>
}
</div>
{window.innerWidth>=1192 &&
<Sticky className='right-box-sticky' mode='top' boundaryElement='.attivazione-step-1' hideOnBoundaryHit={false} topOffset={-70} bottomOffset={80}>
<RightBox stepIndex={0} openModal={false} />
</Sticky>
}
</div>
)
}
}
const mapStateToProps = state => {
return {
steps: state.ProfilationSelectReducer.steps,
activeStep: state.ProfilationSelectReducer.activeStep || 0,
activationSteps: state.ProfilationSelectReducer.activationSteps,
idSamefile: state.ProfilationSelectReducer.idSamefile,
cfSamefile: state.ProfilationSelectReducer.cfSamefile,
}
};
const mapDispatchToProps = dispatch => ({
updateStoreValue: (prop,value) =>
dispatch(SelectActionCreators.changeProp(prop,value)),
updatePropValue: (steps, activeStep) => dispatch(SelectActionCreators.changeValue(steps, activeStep)),
updateActivation: (index,prop,value) => dispatch(SelectActionCreators.updateActivation(index,prop,value))
});
/*Profilation.propTypes = {
steps: PropTypes.array.isRequired,
activeStep: PropTypes.number.isRequired,
updatePropValue: PropTypes.func.isRequired
}*/
export default connect(mapStateToProps, mapDispatchToProps)(ActivationStep1);