generate practice summary report; send report to frontend
This commit is contained in:
@@ -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});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user