File tree Expand file tree Collapse file tree 4 files changed +25
-13
lines changed Expand file tree Collapse file tree 4 files changed +25
-13
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
createVisits ,
16
16
patchVisit ,
17
17
} from "./visitEndpoints"
18
+ import { getInsurers } from "./insurersEndpoints"
18
19
19
20
const create = ( ) => {
20
21
const api = apisauce . create ( {
@@ -44,6 +45,7 @@ const create = () => {
44
45
updateVisits : updateVisits ( api ) ,
45
46
createVisits : createVisits ( api ) ,
46
47
patchVisit : patchVisit ( api ) ,
48
+ getInsurers : getInsurers ( api ) ,
47
49
}
48
50
}
49
51
Original file line number Diff line number Diff line change
1
+ export const getInsurers = api => async ( ) => await api . get ( "insurers/" )
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ const ParticipantInfo = observer(() => {
99
99
let participantIndex = data . findIndex (
100
100
val => val . pp_id === currentParticipant . pp_id
101
101
)
102
+ participantStore . getInsurers ( )
102
103
// useEffect is a hook that gets called after every render/re-render. Empty array second argument prevents it from running again.
103
104
useEffect ( ( ) => {
104
105
if ( participantIndex > - 1 ) {
@@ -122,7 +123,7 @@ const ParticipantInfo = observer(() => {
122
123
note : data [ participantIndex ] . note ,
123
124
} )
124
125
}
125
- } , [ ] )
126
+ } , [ data , participantIndex ] )
126
127
127
128
const createStartDate = ( ) => {
128
129
return format ( new Date ( ) , "yyyy-MM-dd" )
@@ -400,18 +401,9 @@ const ParticipantInfo = observer(() => {
400
401
id : "demo-controlled-open-select" ,
401
402
} }
402
403
>
403
- < MenuItem value = "" >
404
- < em > None</ em >
405
- </ MenuItem >
406
- < MenuItem value = { "Insurance Plan 1" } >
407
- Insurance Plan 1
408
- </ MenuItem >
409
- < MenuItem value = { "Insurance Plan 2" } >
410
- Insurance Plan 2
411
- </ MenuItem >
412
- < MenuItem value = { "Insurance Plan 3" } >
413
- Insurance Plan 3
414
- </ MenuItem >
404
+ { participantStore . insurers . map ( ( insurer , index ) => (
405
+ < MenuItem key = { index } > { insurer . name } </ MenuItem >
406
+ ) ) }
415
407
</ Select >
416
408
</ FormControl >
417
409
</ Grid >
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ export class ParticipantStore {
10
10
// Store Params
11
11
participants = [ ]
12
12
participant = { }
13
+ programs = { }
14
+ insurers = { }
13
15
params = { }
14
16
15
17
// Setters
@@ -28,6 +30,9 @@ export class ParticipantStore {
28
30
setParticipant = data => {
29
31
this . participant = data
30
32
}
33
+ setInsurers = data => {
34
+ this . insurers = data
35
+ }
31
36
32
37
// Getters
33
38
getParticipantsList = ( ) => {
@@ -39,6 +44,9 @@ export class ParticipantStore {
39
44
getParticipant = ( ) => {
40
45
return toJS ( this . participant )
41
46
}
47
+ getInsuranceList = ( ) => {
48
+ return toJS ( this . insurers )
49
+ }
42
50
43
51
// API Calls
44
52
getParticipants = flow ( function * ( ) {
@@ -60,6 +68,15 @@ export class ParticipantStore {
60
68
}
61
69
} )
62
70
71
+ getInsurers = flow ( function * ( ) {
72
+ const { ok, data } = yield api . getInsurers ( )
73
+ if ( ok ) {
74
+ this . setInsurers ( data )
75
+ } else {
76
+ // TODO: Handle errors
77
+ }
78
+ } )
79
+
63
80
updateParticipant = flow ( function * ( ) {
64
81
const { ok, data } = yield api . updateParticipant (
65
82
toJS ( this . participant . id ) ,
You can’t perform that action at this time.
0 commit comments