Add year selection for report; fetch report for selected year
This commit is contained in:
@@ -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});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user