Add year selection for report; fetch report for selected year

This commit is contained in:
Bilal Catic
2019-08-09 00:05:17 +02:00
parent 7a3d49dee7
commit ecbacfd92d
5 changed files with 109 additions and 12 deletions

View File

@@ -113,15 +113,24 @@ export const checkProcessing = (dispatch) => {
});
};
export const fetchMemberPracticeSummaryReport = (dispatch) => {
export const fetchMemberPracticeSummaryReport = (dispatch, year) => {
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING});
API.get('integration/report/practiceSummary', {
API.get(`integration/report/practiceSummary/${year}`, {
responseType: 'blob',
})
.then(response => {
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS, payload: response});
})
.catch(error => {
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED, payload: error.response});
let errorMessage = 'Error generating Member Practice Summary Report';
switch (error.response.status) {
case 400:
errorMessage = 'Year cannot be greater than current year and it has to be a number';
break;
case 500:
default:
break;
}
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED, payload: errorMessage});
});
};