@@ -97,31 +97,31 @@ class PartyRegistration extends React.Component {
97
97
handleChange = ( name ) => event => {
98
98
if ( name === 'phone' ) {
99
99
this . setState ( { errorTextPhone : '' } ) ;
100
- }
100
+ }
101
101
if ( name === 'fax' ) {
102
102
this . setState ( { errorTextFax : '' } ) ;
103
- }
103
+ }
104
104
if ( name === 'address' ) {
105
105
this . setState ( { errorTextAddress : '' } ) ;
106
- }
106
+ }
107
107
if ( name === 'title' ) {
108
108
this . setState ( { errorTextTitle : '' } ) ;
109
- }
109
+ }
110
110
if ( name === 'partyName' ) {
111
111
this . setState ( { errorTextPartyName : '' } ) ;
112
- }
112
+ }
113
113
if ( name === 'partyType' ) {
114
114
this . setState ( { errorTextPartyType : '' } ) ;
115
- }
115
+ }
116
116
if ( name === 'abbreviation' ) {
117
117
this . setState ( { errorTextAbbreviation : '' } ) ;
118
- }
118
+ }
119
119
if ( name === 'approvedSymbol' ) {
120
120
this . setState ( { errorTextApprovedSymbol : '' } ) ;
121
- }
121
+ }
122
122
if ( name === 'secretaryName' ) {
123
123
this . setState ( { errorTextSecretaryName : '' } ) ;
124
- }
124
+ }
125
125
this . setState ( {
126
126
[ name ] : event . target . value ,
127
127
} ) ;
@@ -157,7 +157,7 @@ class PartyRegistration extends React.Component {
157
157
this . setState ( { errorTextAddress : 'emptyField' } ) ;
158
158
goNext = false ;
159
159
}
160
-
160
+
161
161
if ( this . state . approvedSymbol === '' || this . state . approvedSymbol === null ) {
162
162
this . setState ( { errorTextApprovedSymbol : 'emptyField' } ) ;
163
163
goNext = false ;
@@ -167,7 +167,7 @@ class PartyRegistration extends React.Component {
167
167
this . setState ( { errorTextSecretaryName : 'emptyField' } ) ;
168
168
goNext = false ;
169
169
}
170
-
170
+
171
171
if ( this . state . phoneList . length === 0 || this . state . phoneList . length === null ) {
172
172
this . setState ( { errorTextPhone : 'emptyField' } ) ;
173
173
goNext = false ;
@@ -187,19 +187,19 @@ class PartyRegistration extends React.Component {
187
187
handleUploadView = sid => ( ) => {
188
188
this . props . getUploadPath ( sid ) ;
189
189
} ;
190
-
190
+
191
191
showFlagToStyle = ( flag ) => (
192
192
{ display : flag ? "" : "none" }
193
193
) ;
194
194
195
195
onSelectFiles = evt => {
196
196
evt . preventDefault ( ) ;
197
197
evt . stopPropagation ( ) ;
198
-
198
+
199
199
this . setState ( {
200
200
status : evt . type ,
201
201
} ) ;
202
-
202
+
203
203
// Fetch files
204
204
const { files } = evt . target ;
205
205
this . uploadFiles ( files ) ;
@@ -208,26 +208,26 @@ class PartyRegistration extends React.Component {
208
208
uploadFiles = files => {
209
209
let error = false ;
210
210
const errorMessages = [ ] ;
211
-
211
+
212
212
const data = {
213
213
error : null ,
214
214
files
215
- } ;
216
-
215
+ } ;
216
+
217
217
const { allowedTypes, allowedSize } = this . state ;
218
-
218
+
219
219
if ( files && files . length > 0 ) {
220
220
for ( let i = 0 ; i < files . length ; i += 1 ) {
221
221
const file = files [ i ] ;
222
-
222
+
223
223
// Validate file type
224
224
if ( allowedTypes && allowedTypes . length > 0 ) {
225
225
if ( ! allowedTypes . includes ( file . type ) ) {
226
226
error = true ;
227
227
errorMessages . push ( "Invalid file type(s)" ) ;
228
228
}
229
229
}
230
-
230
+
231
231
// Validate fileSize
232
232
if ( allowedSize && allowedSize > 0 ) {
233
233
if ( file . size / 1048576 > allowedSize ) {
@@ -237,7 +237,7 @@ class PartyRegistration extends React.Component {
237
237
}
238
238
}
239
239
}
240
-
240
+
241
241
if ( error ) {
242
242
data . error = errorMessages ;
243
243
data . files = null ;
@@ -250,34 +250,34 @@ class PartyRegistration extends React.Component {
250
250
headers : {
251
251
'Content-Type' : 'multipart/form-data'
252
252
} ,
253
-
253
+
254
254
onUploadProgress : ( progressEvent ) => {
255
255
let percentCompleted = ( progressEvent . loaded * 100 ) / progressEvent . total ;
256
256
this . setState (
257
257
{ progress : percentCompleted }
258
258
) ;
259
259
console . log ( percentCompleted ) ;
260
260
}
261
-
262
-
261
+
262
+
263
263
} ) . then ( ( response ) => {
264
-
265
-
266
-
264
+
265
+
267
266
const obj = { 'filename' :response . data . filename , 'originalname' :response . data . originalname } ;
268
-
267
+
269
268
this . setState (
270
269
{
271
270
status : "uploaded" ,
272
271
currentSdocId : response . data . originalname ,
273
- filename :response . data . filename
272
+ filename :response . data . filename ,
273
+ file : URL . createObjectURL ( files [ 0 ] )
274
274
}
275
275
) ;
276
276
} ) ;
277
277
}
278
278
} ;
279
279
280
- addPhone = ( ) => {
280
+ addPhone = ( ) => {
281
281
if ( this . state . phone === undefined || this . state . phone === '' ) {
282
282
this . setState ( { errorTextPhone :'emptyField' } ) ;
283
283
}
@@ -288,7 +288,7 @@ class PartyRegistration extends React.Component {
288
288
if ( this . state . phone !== undefined || this . state . phone !== '' ) {
289
289
phoneList . push ( phone ) ;
290
290
this . setState ( { phoneList } ) ;
291
- }
291
+ }
292
292
}
293
293
294
294
removePhone = ( index ) => ( ) => {
@@ -297,7 +297,7 @@ class PartyRegistration extends React.Component {
297
297
this . setState ( { ...this . state , phoneList} ) ;
298
298
}
299
299
300
- addFax = ( ) => {
300
+ addFax = ( ) => {
301
301
if ( this . state . fax === undefined || this . state . fax === '' ) {
302
302
this . setState ( { errorTextFax :'emptyField' } ) ;
303
303
}
@@ -308,9 +308,9 @@ class PartyRegistration extends React.Component {
308
308
if ( this . state . fax !== undefined || this . state . fax !== '' ) {
309
309
faxList . push ( fax ) ;
310
310
this . setState ( { faxList } ) ;
311
- }
311
+ }
312
312
}
313
-
313
+
314
314
removeFax = ( index ) => ( ) => {
315
315
const faxList = this . state . faxList ;
316
316
faxList . splice ( index , 1 ) ;
@@ -320,7 +320,7 @@ class PartyRegistration extends React.Component {
320
320
render ( ) {
321
321
const { classes, onCloseModal} = this . props ;
322
322
const { errorTextPartyType, errorTextSecretaryName, errorTextAbbreviation, errorTextApprovedSymbol, errorTextAddress, errorTextTitle, errorTextPartyName, errorTextPhone, errorTextFax } = this . state ;
323
-
323
+
324
324
325
325
const doneElement = ( < div className = { classes . done } style = { this . showFlagToStyle ( this . state . status === "uploading" ) } >
326
326
< DoneOutline color = "secondary" />
@@ -348,7 +348,7 @@ class PartyRegistration extends React.Component {
348
348
</ Grid >
349
349
</ Grid >
350
350
< Grid style = { { marginLeft : 12 , marginBottom :20 } } container direction = "row" justify = "flex-start" alignItems = "stretch" spacing = { 2 } >
351
-
351
+
352
352
< Grid container item lg = { 4 } >
353
353
< FormControl style = { { width :'100%' } } error = { ( errorTextPartyType ) ? true : false } >
354
354
< Select
@@ -365,10 +365,10 @@ class PartyRegistration extends React.Component {
365
365
</ MenuItem >
366
366
< MenuItem value = { 'RPP' } > Registered Political Party ( RPP )</ MenuItem >
367
367
< MenuItem value = { 'IND' } > Indipendent Group ( IND )</ MenuItem >
368
- </ Select >
368
+ </ Select >
369
369
< FormHelperText style = { { marginLeft :18 } } > { ( errorTextPartyType === 'emptyField' ) ? 'This field is required!' : '' } </ FormHelperText >
370
370
</ FormControl >
371
- </ Grid >
371
+ </ Grid >
372
372
< Grid container item lg = { 3 } >
373
373
< TextField
374
374
error = { errorTextAbbreviation }
@@ -425,10 +425,10 @@ class PartyRegistration extends React.Component {
425
425
< MenuItem value = { 'Mr' } > Mr</ MenuItem >
426
426
< MenuItem value = { 'Mrs' } > Mrs</ MenuItem >
427
427
< MenuItem value = { 'Ms' } > Ms</ MenuItem >
428
- </ Select >
428
+ </ Select >
429
429
< FormHelperText style = { { marginLeft :18 } } > { ( errorTextTitle === 'emptyField' ) ? 'This field is required!' : '' } </ FormHelperText >
430
430
</ FormControl >
431
- </ Grid >
431
+ </ Grid >
432
432
< Grid container item lg = { 4 } >
433
433
< TextField
434
434
id = "outlined-multiline-static"
@@ -442,8 +442,8 @@ class PartyRegistration extends React.Component {
442
442
// defaultValue="Enter Address"
443
443
variant = "outlined"
444
444
helperText = { errorTextAddress === "emptyField" ? 'This field is required!' : '' }
445
- />
446
- </ Grid >
445
+ />
446
+ </ Grid >
447
447
</ Grid >
448
448
< Grid direction = "column" style = { { marginLeft : 12 } } container spacing = { 2 } >
449
449
< Grid container item lg = { 6 } >
@@ -521,40 +521,32 @@ class PartyRegistration extends React.Component {
521
521
} )
522
522
}
523
523
</ Grid >
524
-
524
+
525
525
< Grid style = { { marginLeft : 12 , marginTop :25 } } container spacing = { 2 } xs = { 12 } >
526
526
< Grid container item lg = { 6 } >
527
-
528
-
527
+
528
+
529
529
< Grid container item lg = { 6 } >
530
530
{
531
-
531
+
532
532
this . state . status === "uploaded" ? < div className = { classes . done } >
533
533
< DoneOutline style = { { marginTop :30 , marginLeft :- 20 } } onClick = { this . handleUploadView ( this . state . filename ) } color = "secondary" />
534
534
{ /* <img src={`http://localhost:9001/src/uploads/${sdoc.filename}`} style={{maxWidth: 60,margin:25}} className="img-fluid" alt="logo" /> */ }
535
535
</ div > : ' '
536
-
536
+
537
537
}
538
538
< span >
539
539
< Typography style = { { color :"rgba(0, 0, 0, 0.54)" , fontSize :12 } } variant = "subtitle1" > Attach party symbol</ Typography >
540
540
< span > < FileUpload value = { this . state . paySlip } doneElement = { doneElement } onSelectFiles = { this . onSelectFiles } /> </ span >
541
541
</ span >
542
542
</ Grid >
543
543
< Grid style = { { marginTop :30 , marginLeft :- 10 } } container item lg = { 4 } >
544
- {
545
- this . state . status === "uploaded" ?
546
- < Typography variant = "caption" gutterBottom >
547
- { this . state . currentSdocId } < div className = { classes . done } >
548
- < AttachFile color = "red" />
549
- </ div >
550
- </ Typography >
551
- : 'No file attached'
552
- }
544
+ < img src = { this . state . file } />
553
545
</ Grid >
554
546
</ Grid >
555
-
547
+
556
548
</ Grid >
557
-
549
+
558
550
< Grid style = { { marginLeft : 12 } } container direction = "row" justify = "flex-start" alignItems = "stretch" spacing = { 2 } >
559
551
< Grid container spacing = { 12 } >
560
552
< Grid style = { { textAlign : 'right' , marginRight : '25px' } } className = { classes . label } item lg = { 12 } >
0 commit comments