generate practice summary report; send report to frontend

This commit is contained in:
Bilal Catic
2019-08-08 01:55:00 +02:00
parent 12523fde5b
commit 3f16ec5949
12 changed files with 13279 additions and 10 deletions

View File

@@ -115,9 +115,11 @@ export const checkProcessing = (dispatch) => {
export const fetchMemberPracticeSummaryReport = (dispatch) => {
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING});
API.get('integration/report/practiceSummary')
API.get('integration/report/practiceSummary', {
responseType: 'blob',
})
.then(response => {
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS, payload: response.data});
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS, payload: response});
})
.catch(error => {
dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED, payload: error.response});

View File

@@ -0,0 +1,45 @@
import {
FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING,
FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS,
FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED,
} from '../constants';
const initialState = {
pending: false,
result: null,
error: null,
};
export const memberPracticeSummaryReport = (state, action) => {
state = state || initialState;
action = action || {};
switch(action.type){
case FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING:
return Object.assign({}, state, {
pending: true,
error: null,
});
case FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS:
const url = window.URL.createObjectURL(new Blob([action.payload.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'Member Practice Summary Report.xlsx');
document.body.appendChild(link);
link.click();
return Object.assign({}, state, {
pending: false,
result: null,
error: null,
});
case FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED:
return Object.assign({}, state, {
pending: false,
result: {},
error: action.payload,
});
default:
return state;
}
};

View File

@@ -8,6 +8,7 @@ import { membersList } from './membersListReducer';
import { memberIncidents} from './memberIncidentsReducer';
import { addFeesStatus } from './addFeesToOrdReducer';
import { checkProcessing } from './checkProcessingReducer';
import { memberPracticeSummaryReport} from './fetchMemberPracticeSummaryReportReducer';
export const rootReducer = combineReducers({
doorLockData,
@@ -18,5 +19,6 @@ export const rootReducer = combineReducers({
memberIncidents,
addFeesStatus,
checkProcessing,
memberPracticeSummaryReport,
});