Last active
March 21, 2018 18:48
-
-
Save purinkle/27f4b2ab08e1ef5f9ff13b77a0c8bb07 to your computer and use it in GitHub Desktop.
Fetching questionnaires
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// appointments/actions.js | |
const doFetchedAppointmentQuestionnaires = (appointmentId, questionnaires) => ({ | |
type: types.APPOINTMENT_QUESTIONNAIRES_FETCHED, | |
payload: { appointmentId, questionnaires }, | |
}); | |
const handleFetchQuestionnaires(appointmentId) = () => async dispatch => { | |
const questionnaires = await PatientApi.getQuestionnaires(appointmentId); | |
dispatch(doFetchedQuestionnaires(appointmentId, questionnaires)); | |
}; | |
// appointments/reducer.js | |
const applyUpdateAppointmentQuestionnaires = (state, action) => { | |
// Update questionnaires… | |
}; | |
const reducer = (state = initialState, action) => { | |
switch(action.type) { | |
case types.APPOINTMENT_QUESTIONNAIRES_FETCHED : { | |
return applyUpdateAppointmentQuestionnaires(state, action); | |
} | |
default: | |
return state; | |
} | |
} | |
// questionnaires/reducer.js | |
const applyAddQuestionnaires = (state, action) => { | |
// Add questionnaires… | |
}; | |
const reducer = (state = initialState, action) => { | |
switch(action.type) { | |
case types.APPOINTMENT_QUESTIONNAIRES_FETCHED : { | |
return applyAddQuestionnaires(state, action); | |
} | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment