import { makeAsyncReducer, makeAsyncActionCreator, composeReducers } from 'redux-toolbelt';
import { makeAsyncSaga } from 'redux-toolbelt-saga';
import {
questionnarie,
getQuestionnaireInstances,
getFormInstances,
getSectionDefinations,
getFormDefinitionWithDataAndSection,
getPatientProfileInfo,
setSelectedQuestionnaireIdToStore
} from './service';
// Actions
export const actions = {
questionnarieData: makeAsyncActionCreator('GET_QUESTIONNARIELIST'),
questionnarieInstances: makeAsyncActionCreator('GET_QUESTIONNARIE_INSTANCES'),
formInstances: makeAsyncActionCreator('GET_FORM_INSTANCES'),
sectionDefinationInstances: makeAsyncActionCreator('GET_SECTION_DEFINATIONS'),
formDefinitionWithDataAndSection: makeAsyncActionCreator('GET_FORM_DEFINATION_WITH_DATA_AND_SECTION'),
patientProfileInfo: makeAsyncActionCreator('GET_VISIT'),
setSelectedQuestionnaire: makeAsyncActionCreator('SET_SELECTEDQUESTIONNAIRE')
};
// Reducer
export const reducer = composeReducers({
questionnarieList: makeAsyncReducer(actions.questionnarieData),
questionnarieInstanceList: makeAsyncReducer(actions.questionnarieInstances),
formInstanceList: makeAsyncReducer(actions.formInstances),
sectionDefinationInstanceList: makeAsyncReducer(actions.sectionDefinationInstances),
formDefinitionWithDataAndSectionList: makeAsyncReducer(actions.formDefinitionWithDataAndSection),
patientProfileInfolist: makeAsyncReducer(actions.patientProfileInfo),
SelectedQuestionnaire: makeAsyncReducer(actions.setSelectedQuestionnaire)
});
// Sagas
const questionnarieSaga = makeAsyncSaga(actions.questionnarieData, questionnarie, { debug: true });
const questionnarieInstancesSaga = makeAsyncSaga(actions.questionnarieInstances, getQuestionnaireInstances, { debug: true });
const formInstancesSaga = makeAsyncSaga(actions.formInstances, getFormInstances, { debug: true });
const sectionDefinationInstancesSaga = makeAsyncSaga(actions.sectionDefinationInstances, getSectionDefinations, { debug: true });
const formDefinitionWithDataAndSectionSaga = makeAsyncSaga(actions.formDefinitionWithDataAndSection, getFormDefinitionWithDataAndSection, { debug: true });
const patientProfileInfoSaga = makeAsyncSaga(actions.patientProfileInfo, getPatientProfileInfo, { debug: true });
const setSelectedQuestionnaireSaga = makeAsyncSaga(actions.setSelectedQuestionnaire,setSelectedQuestionnaireIdToStore, {debug: true});
export const sagas = [
questionnarieSaga(),
questionnarieInstancesSaga(),
formInstancesSaga(),
sectionDefinationInstancesSaga(),
formDefinitionWithDataAndSectionSaga(),
patientProfileInfoSaga(),
setSelectedQuestionnaireSaga()
]; |