All files / src/redux/patients patients.js

0% Statements 0/10
100% Branches 0/0
100% Functions 0/0
0% Lines 0/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                                 
import { makeAsyncReducer, makeAsyncActionCreator, composeReducers } from 'redux-toolbelt';
import { makeAsyncSaga } from 'redux-toolbelt-saga';
import { addVisitPatient, getVisitPatient, getLocations, getLocationsCnt } from './service';
 
// Actions
export const actions = {
    getVisit: makeAsyncActionCreator('GET_QUESTIONNARIE'),
    addVisit: makeAsyncActionCreator('CREATE_ADD_VISIT'),
    getLocation: makeAsyncActionCreator('GET_LOCATIONS'),
    getLocationCnt: makeAsyncActionCreator('GET_LOCATIONS')
};
 
// Reducer
export const reducer = composeReducers({
    patient: makeAsyncReducer(actions.getVisit),
    addpatient: makeAsyncReducer(actions.addVisit),
    locations: makeAsyncReducer(actions.getLocation),
    locationCnt: makeAsyncReducer(actions.getLocationCnt)
});
 
// Sagas
const PatientSaga = makeAsyncSaga(actions.getVisit, getVisitPatient, { debug: true });
const addPatientSaga = makeAsyncSaga(actions.addVisit, addVisitPatient, { debug: true });
const getLocationSaga = makeAsyncSaga(actions.getLocation, getLocations, { debug: true });
const getLocationCntSaga = makeAsyncSaga(actions.getLocationCnt, getLocationsCnt, { debug: true });
 
export const sagas = [
    PatientSaga(),
    addPatientSaga(),
    getLocationSaga(),
    getLocationCntSaga()
];