@@ -73,7 +73,24 @@ const useStyles = makeStyles(theme => ({
73
73
const ParticipantInfo = observer ( ( ) => {
74
74
const rootStore = useContext ( rootStoreContext )
75
75
const participantStore = rootStore . ParticipantStore
76
- const [ participant , setParticipant ] = React . useState ( { } )
76
+ const [ participant , setParticipant ] = React . useState ( {
77
+ id : 0 ,
78
+ firstName : "" ,
79
+ lastName : "" ,
80
+ lastFourSSN : 0 ,
81
+ dateOfBirth : "" ,
82
+ startDate : "" ,
83
+ ppId : "" ,
84
+ race : "" ,
85
+ gender : "" ,
86
+ hasInsurance : false ,
87
+ insuranceType : "" ,
88
+ insurer : "" ,
89
+ program : "" ,
90
+ service : "" ,
91
+ priority : "" ,
92
+ note : "" ,
93
+ } )
77
94
const [ open , setOpen ] = React . useState ( "" )
78
95
const history = useHistory ( )
79
96
@@ -110,12 +127,6 @@ const ParticipantInfo = observer(() => {
110
127
const createStartDate = ( ) => {
111
128
return format ( new Date ( ) , "yyyy-MM-dd" )
112
129
}
113
- const changeParticipant = ( e , args ) => {
114
- setParticipant ( prevState => ( {
115
- ...prevState ,
116
- [ args ] : e . target . value ,
117
- } ) )
118
- }
119
130
// set store stuff here and update Mobx on submit
120
131
function handleClose ( ) {
121
132
setOpen ( false )
@@ -125,7 +136,6 @@ const ParticipantInfo = observer(() => {
125
136
}
126
137
function handleSubmit ( e ) {
127
138
e . preventDefault ( )
128
- // match participant ID
129
139
participantStore . setParticipant ( {
130
140
id : participantIndex > - 1 ? participant . id : null ,
131
141
first_name : participant . firstName ,
@@ -178,7 +188,12 @@ const ParticipantInfo = observer(() => {
178
188
id = "user_first-name"
179
189
name = "user_first-name"
180
190
value = { participant . firstName }
181
- onChange = { e => changeParticipant ( e , "firstName" ) }
191
+ onChange = { e =>
192
+ setParticipant ( {
193
+ ...participant ,
194
+ firstName : e . target . value ,
195
+ } )
196
+ }
182
197
required
183
198
/>
184
199
</ FormControl >
@@ -190,7 +205,12 @@ const ParticipantInfo = observer(() => {
190
205
id = "user_last-name"
191
206
name = "user_last-name"
192
207
value = { participant . lastName }
193
- onChange = { e => changeParticipant ( e , "lastName" ) }
208
+ onChange = { e =>
209
+ setParticipant ( {
210
+ ...participant ,
211
+ lastName : e . target . value ,
212
+ } )
213
+ }
194
214
required
195
215
/>
196
216
</ FormControl >
@@ -206,7 +226,12 @@ const ParticipantInfo = observer(() => {
206
226
id = "user_birth-date"
207
227
name = "user_birth-date"
208
228
value = { participant . dateOfBirth }
209
- onChange = { e => changeParticipant ( e , "dateOfBirth" ) }
229
+ onChange = { e =>
230
+ setParticipant ( {
231
+ ...participant ,
232
+ dateOfBirth : e . target . value ,
233
+ } )
234
+ }
210
235
required
211
236
style = { { marginTop : 40 } }
212
237
type = "date"
@@ -224,7 +249,13 @@ const ParticipantInfo = observer(() => {
224
249
id = "uuid"
225
250
name = "uuid"
226
251
value = { participant . ppId }
227
- onChange = { e => changeParticipant ( e , "ppId" ) }
252
+ onChange = { e =>
253
+ setParticipant ( {
254
+ ...participant ,
255
+ ppId : e . target . value ,
256
+ lastFourSSN : + e . target . value . substr ( 2 ) ,
257
+ } )
258
+ }
228
259
required
229
260
/>
230
261
</ FormControl >
@@ -246,7 +277,12 @@ const ParticipantInfo = observer(() => {
246
277
onOpen = { handleOpen . race }
247
278
required
248
279
value = { participant . race }
249
- onChange = { e => changeParticipant ( e , "race" ) }
280
+ onChange = { e =>
281
+ setParticipant ( {
282
+ ...participant ,
283
+ race : e . target . value ,
284
+ } )
285
+ }
250
286
inputProps = { {
251
287
name : "race" ,
252
288
id : "demo-controlled-open-select" ,
@@ -282,7 +318,12 @@ const ParticipantInfo = observer(() => {
282
318
onOpen = { handleOpen . gender }
283
319
required
284
320
value = { participant . gender }
285
- onChange = { e => changeParticipant ( e , "gender" ) }
321
+ onChange = { e =>
322
+ setParticipant ( {
323
+ ...participant ,
324
+ gender : e . target . value ,
325
+ } )
326
+ }
286
327
inputProps = { {
287
328
name : "gender" ,
288
329
id : "demo-controlled-open-select" ,
@@ -316,16 +357,21 @@ const ParticipantInfo = observer(() => {
316
357
name = "hasInsurance"
317
358
className = { classes . group }
318
359
value = { participant . hasInsurance }
319
- onChange = { e => changeParticipant ( e , "hasInsurance" ) }
360
+ onChange = { e =>
361
+ setParticipant ( {
362
+ ...participant ,
363
+ hasInsurance : e . target . value ,
364
+ } )
365
+ }
320
366
style = { { display : "inline" } }
321
367
>
322
368
< FormControlLabel
323
- value = "yes"
369
+ value = { true }
324
370
control = { < Radio /> }
325
371
label = "Yes"
326
372
/>
327
373
< FormControlLabel
328
- value = "no"
374
+ value = { false }
329
375
control = { < Radio /> }
330
376
label = "No"
331
377
/>
@@ -343,7 +389,12 @@ const ParticipantInfo = observer(() => {
343
389
onClose = { handleClose . insuranceType }
344
390
onOpen = { handleOpen . insuranceType }
345
391
value = { participant . insuranceType }
346
- onChange = { e => changeParticipant ( e , "insuranceType" ) }
392
+ onChange = { e =>
393
+ setParticipant ( {
394
+ ...participant ,
395
+ insuranceType : e . target . value ,
396
+ } )
397
+ }
347
398
inputProps = { {
348
399
name : "insuranceType" ,
349
400
id : "demo-controlled-open-select" ,
@@ -393,7 +444,12 @@ const ParticipantInfo = observer(() => {
393
444
onOpen = { handleOpen . program }
394
445
required
395
446
value = { participant . program }
396
- onChange = { e => changeParticipant ( e , "program" ) }
447
+ onChange = { e =>
448
+ setParticipant ( {
449
+ ...participant ,
450
+ program : e . target . value ,
451
+ } )
452
+ }
397
453
inputProps = { {
398
454
name : "program" ,
399
455
id : "demo-controlled-open-select" ,
@@ -416,7 +472,12 @@ const ParticipantInfo = observer(() => {
416
472
onOpen = { handleOpen . service }
417
473
required
418
474
value = { participant . service }
419
- onChange = { e => changeParticipant ( e , "service" ) }
475
+ onChange = { e =>
476
+ setParticipant ( {
477
+ ...participant ,
478
+ service : e . target . value ,
479
+ } )
480
+ }
420
481
inputProps = { {
421
482
name : "service" ,
422
483
id : "demo-controlled-open-select" ,
@@ -439,7 +500,12 @@ const ParticipantInfo = observer(() => {
439
500
onClose = { handleClose . priorityLevel }
440
501
onOpen = { handleOpen . priorityLevel }
441
502
value = { participant . priority }
442
- onChange = { e => changeParticipant ( e , "priority" ) }
503
+ onChange = { e =>
504
+ setParticipant ( {
505
+ ...participant ,
506
+ priority : e . target . value ,
507
+ } )
508
+ }
443
509
inputProps = { {
444
510
name : "priorityLevel" ,
445
511
id : "demo-controlled-open-select" ,
@@ -458,7 +524,12 @@ const ParticipantInfo = observer(() => {
458
524
id = "standard-full-width"
459
525
style = { { margin : 8 , marginTop : 40 } }
460
526
placeholder = "Add a note"
461
- onChange = { e => changeParticipant ( e , "note" ) }
527
+ onChange = { e =>
528
+ setParticipant ( {
529
+ ...participant ,
530
+ note : e . target . value ,
531
+ } )
532
+ }
462
533
value = { participant . note }
463
534
fullWidth
464
535
margin = "normal"
0 commit comments