Skip to content

Instantly share code, notes, and snippets.

@purinkle
Last active March 21, 2018 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purinkle/27f4b2ab08e1ef5f9ff13b77a0c8bb07 to your computer and use it in GitHub Desktop.
Save purinkle/27f4b2ab08e1ef5f9ff13b77a0c8bb07 to your computer and use it in GitHub Desktop.
Fetching questionnaires
// 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