@@ -92,28 +92,14 @@ const ParticipantInfo = observer(() => {
9292 const programList = toJS ( participantStore . programs )
9393 const serviceList = toJS ( participantStore . services )
9494
95- // useEffect is a hook that gets called after every render/re-render. Empty array second argument prevents it from running again.
9695 useEffect ( ( ) => {
97- ; ( async ( ) => {
98- // kick off api calls for insurance list from Mobx
99- await participantStore . getInsurers ( )
100- // kick off api calls for program list from Mobx
101- await participantStore . getPrograms ( )
102- } ) ( )
103- if (
104- existingParticipant . id &&
105- existingVisit . id &&
106- existingVisit . program &&
107- existingVisit . service
108- ) {
109- // preload chosen services based on visit programs
110- participantStore . setServiceList (
111- programList . find ( program => program . id === existingVisit . program )
112- . services
113- )
114- }
96+ // kick off api calls for insurance list from Mobx
97+ participantStore . getInsurers ( )
98+ // kick off api calls for program list from Mobx
99+ participantStore . getPrograms ( )
115100 // eslint-disable-next-line react-hooks/exhaustive-deps
116101 } , [ ] )
102+
117103 // set store stuff here and update Mobx on submit
118104 const handleSubmit = e => {
119105 e . preventDefault ( )
@@ -137,9 +123,10 @@ const ParticipantInfo = observer(() => {
137123 }
138124 // set service listings based on chosen program
139125 const findAndSaveServiceListings = e => {
140- participantStore . setServiceList (
141- programList . find ( program => program . id === e . target . value ) . services
126+ const serviceListing = programList . find (
127+ program => program . id === e . target . value
142128 )
129+ participantStore . setServiceList ( serviceListing . services )
143130 }
144131
145132 const classes = useStyles ( )
0 commit comments