Skip to content

Commit d662bad

Browse files
authored
Merge pull request #284 from yasirunilan/master
fixes related to showing party logo on add party modal
2 parents 6c7260f + 1e60696 commit d662bad

File tree

2 files changed

+117
-124
lines changed

2 files changed

+117
-124
lines changed

client/src/components/AddParty/index.js

Lines changed: 50 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,31 @@ class PartyRegistration extends React.Component {
9797
handleChange = (name) => event => {
9898
if (name === 'phone') {
9999
this.setState({ errorTextPhone: '' });
100-
}
100+
}
101101
if (name === 'fax') {
102102
this.setState({ errorTextFax: '' });
103-
}
103+
}
104104
if (name === 'address') {
105105
this.setState({ errorTextAddress: '' });
106-
}
106+
}
107107
if (name === 'title') {
108108
this.setState({ errorTextTitle: '' });
109-
}
109+
}
110110
if (name === 'partyName') {
111111
this.setState({ errorTextPartyName: '' });
112-
}
112+
}
113113
if (name === 'partyType') {
114114
this.setState({ errorTextPartyType: '' });
115-
}
115+
}
116116
if (name === 'abbreviation') {
117117
this.setState({ errorTextAbbreviation: '' });
118-
}
118+
}
119119
if (name === 'approvedSymbol') {
120120
this.setState({ errorTextApprovedSymbol: '' });
121-
}
121+
}
122122
if (name === 'secretaryName') {
123123
this.setState({ errorTextSecretaryName: '' });
124-
}
124+
}
125125
this.setState({
126126
[name]: event.target.value,
127127
});
@@ -157,7 +157,7 @@ class PartyRegistration extends React.Component {
157157
this.setState({ errorTextAddress: 'emptyField' });
158158
goNext = false;
159159
}
160-
160+
161161
if (this.state.approvedSymbol === '' || this.state.approvedSymbol === null) {
162162
this.setState({ errorTextApprovedSymbol: 'emptyField' });
163163
goNext = false;
@@ -167,7 +167,7 @@ class PartyRegistration extends React.Component {
167167
this.setState({ errorTextSecretaryName: 'emptyField' });
168168
goNext = false;
169169
}
170-
170+
171171
if (this.state.phoneList.length === 0 || this.state.phoneList.length === null) {
172172
this.setState({ errorTextPhone: 'emptyField' });
173173
goNext = false;
@@ -187,19 +187,19 @@ class PartyRegistration extends React.Component {
187187
handleUploadView = sid => () => {
188188
this.props.getUploadPath(sid);
189189
};
190-
190+
191191
showFlagToStyle = (flag) => (
192192
{display: flag ? "" : "none"}
193193
);
194194

195195
onSelectFiles = evt => {
196196
evt.preventDefault();
197197
evt.stopPropagation();
198-
198+
199199
this.setState({
200200
status: evt.type,
201201
});
202-
202+
203203
// Fetch files
204204
const { files } = evt.target;
205205
this.uploadFiles(files);
@@ -208,26 +208,26 @@ class PartyRegistration extends React.Component {
208208
uploadFiles = files => {
209209
let error = false;
210210
const errorMessages = [];
211-
211+
212212
const data = {
213213
error: null,
214214
files
215-
};
216-
215+
};
216+
217217
const { allowedTypes, allowedSize } = this.state;
218-
218+
219219
if (files && files.length > 0) {
220220
for (let i = 0; i < files.length; i += 1) {
221221
const file = files[i];
222-
222+
223223
// Validate file type
224224
if (allowedTypes && allowedTypes.length > 0) {
225225
if (!allowedTypes.includes(file.type)) {
226226
error = true;
227227
errorMessages.push("Invalid file type(s)");
228228
}
229229
}
230-
230+
231231
// Validate fileSize
232232
if (allowedSize && allowedSize > 0) {
233233
if (file.size / 1048576 > allowedSize) {
@@ -237,7 +237,7 @@ class PartyRegistration extends React.Component {
237237
}
238238
}
239239
}
240-
240+
241241
if (error) {
242242
data.error = errorMessages;
243243
data.files = null;
@@ -250,34 +250,34 @@ class PartyRegistration extends React.Component {
250250
headers: {
251251
'Content-Type': 'multipart/form-data'
252252
},
253-
253+
254254
onUploadProgress: (progressEvent) => {
255255
let percentCompleted = (progressEvent.loaded * 100) / progressEvent.total;
256256
this.setState(
257257
{progress: percentCompleted}
258258
);
259259
console.log(percentCompleted);
260260
}
261-
262-
261+
262+
263263
}).then((response) => {
264-
265-
266-
264+
265+
267266
const obj = {'filename':response.data.filename, 'originalname':response.data.originalname};
268-
267+
269268
this.setState(
270269
{
271270
status: "uploaded",
272271
currentSdocId: response.data.originalname,
273-
filename:response.data.filename
272+
filename:response.data.filename,
273+
file: URL.createObjectURL(files[0])
274274
}
275275
);
276276
});
277277
}
278278
};
279279

280-
addPhone = () => {
280+
addPhone = () => {
281281
if(this.state.phone===undefined || this.state.phone===''){
282282
this.setState({errorTextPhone:'emptyField'});
283283
}
@@ -288,7 +288,7 @@ class PartyRegistration extends React.Component {
288288
if(this.state.phone!==undefined || this.state.phone!==''){
289289
phoneList.push(phone);
290290
this.setState({ phoneList });
291-
}
291+
}
292292
}
293293

294294
removePhone = (index) => () => {
@@ -297,7 +297,7 @@ class PartyRegistration extends React.Component {
297297
this.setState({...this.state, phoneList});
298298
}
299299

300-
addFax = () => {
300+
addFax = () => {
301301
if(this.state.fax===undefined || this.state.fax===''){
302302
this.setState({errorTextFax:'emptyField'});
303303
}
@@ -308,9 +308,9 @@ class PartyRegistration extends React.Component {
308308
if(this.state.fax!==undefined || this.state.fax!==''){
309309
faxList.push(fax);
310310
this.setState({ faxList });
311-
}
311+
}
312312
}
313-
313+
314314
removeFax = (index) => () => {
315315
const faxList = this.state.faxList;
316316
faxList.splice(index, 1);
@@ -320,7 +320,7 @@ class PartyRegistration extends React.Component {
320320
render() {
321321
const { classes, onCloseModal} = this.props;
322322
const { errorTextPartyType,errorTextSecretaryName,errorTextAbbreviation,errorTextApprovedSymbol,errorTextAddress,errorTextTitle,errorTextPartyName,errorTextPhone,errorTextFax } = this.state;
323-
323+
324324

325325
const doneElement = (<div className={classes.done} style={this.showFlagToStyle(this.state.status === "uploading")}>
326326
<DoneOutline color="secondary"/>
@@ -348,7 +348,7 @@ class PartyRegistration extends React.Component {
348348
</Grid>
349349
</Grid>
350350
<Grid style={{ marginLeft: 12,marginBottom:20 }} container direction="row" justify="flex-start" alignItems="stretch" spacing={2}>
351-
351+
352352
<Grid container item lg={4}>
353353
<FormControl style={{width:'100%'}} error={(errorTextPartyType) ? true : false} >
354354
<Select
@@ -365,10 +365,10 @@ class PartyRegistration extends React.Component {
365365
</MenuItem>
366366
<MenuItem value={'RPP'}>Registered Political Party ( RPP )</MenuItem>
367367
<MenuItem value={'IND'}>Indipendent Group ( IND )</MenuItem>
368-
</Select>
368+
</Select>
369369
<FormHelperText style={{marginLeft:18}}>{(errorTextPartyType==='emptyField') ? 'This field is required!' : ''}</FormHelperText>
370370
</FormControl>
371-
</Grid>
371+
</Grid>
372372
<Grid container item lg={3}>
373373
<TextField
374374
error={errorTextAbbreviation}
@@ -425,10 +425,10 @@ class PartyRegistration extends React.Component {
425425
<MenuItem value={'Mr'}>Mr</MenuItem>
426426
<MenuItem value={'Mrs'}>Mrs</MenuItem>
427427
<MenuItem value={'Ms'}>Ms</MenuItem>
428-
</Select>
428+
</Select>
429429
<FormHelperText style={{marginLeft:18}}>{(errorTextTitle==='emptyField') ? 'This field is required!' : ''}</FormHelperText>
430430
</FormControl>
431-
</Grid>
431+
</Grid>
432432
<Grid container item lg={4}>
433433
<TextField
434434
id="outlined-multiline-static"
@@ -442,8 +442,8 @@ class PartyRegistration extends React.Component {
442442
// defaultValue="Enter Address"
443443
variant="outlined"
444444
helperText={errorTextAddress === "emptyField" ? 'This field is required!' : ''}
445-
/>
446-
</Grid>
445+
/>
446+
</Grid>
447447
</Grid>
448448
<Grid direction="column" style={{ marginLeft: 12}} container spacing={2}>
449449
<Grid container item lg={6}>
@@ -521,40 +521,32 @@ class PartyRegistration extends React.Component {
521521
})
522522
}
523523
</Grid>
524-
524+
525525
<Grid style={{ marginLeft: 12,marginTop:25 }} container spacing={2} xs={12}>
526526
<Grid container item lg={6}>
527-
528-
527+
528+
529529
<Grid container item lg={6}>
530530
{
531-
531+
532532
this.state.status === "uploaded" ? <div className={classes.done} >
533533
<DoneOutline style={{marginTop:30,marginLeft:-20}} onClick={this.handleUploadView(this.state.filename)} color="secondary"/>
534534
{/* <img src={`http://localhost:9001/src/uploads/${sdoc.filename}`} style={{maxWidth: 60,margin:25}} className="img-fluid" alt="logo" /> */}
535535
</div> : ' '
536-
536+
537537
}
538538
<span>
539539
<Typography style={{color:"rgba(0, 0, 0, 0.54)",fontSize:12}} variant="subtitle1" >Attach party symbol</Typography>
540540
<span ><FileUpload value={this.state.paySlip} doneElement={doneElement} onSelectFiles={this.onSelectFiles} /></span>
541541
</span>
542542
</Grid>
543543
<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}/>
553545
</Grid>
554546
</Grid>
555-
547+
556548
</Grid>
557-
549+
558550
<Grid style={{ marginLeft: 12 }} container direction="row" justify="flex-start" alignItems="stretch" spacing={2}>
559551
<Grid container spacing={12}>
560552
<Grid style={{ textAlign: 'right', marginRight: '25px' }} className={classes.label} item lg={12}>

0 commit comments

Comments
 (0)