98 lines
3.1 KiB
JavaScript
98 lines
3.1 KiB
JavaScript
import {
|
|
FETCH_MAPPINGS_PENDING,
|
|
FETCH_MAPPINGS_SUCCESS,
|
|
FETCH_MAPPINGS_FAILED,
|
|
ADD_NEW_MAPPING_PENDING,
|
|
ADD_NEW_MAPPING_SUCCESS,
|
|
ADD_NEW_MAPPING_FAILED,
|
|
FETCH_INCIDENTS_PENDING,
|
|
FETCH_INCIDENTS_SUCCESS,
|
|
FETCH_INCIDENTS_FAILED,
|
|
FETCH_MEMBERS_PENDING,
|
|
FETCH_MEMBERS_SUCCESS,
|
|
FETCH_MEMBERS_FAILED,
|
|
FETCH_MEMBER_INCIDENTS_PENDING,
|
|
FETCH_MEMBER_INCIDENTS_SUCCESS,
|
|
FETCH_MEMBER_INCIDENTS_FAILED,
|
|
ADD_FEES_TO_ORD_PENDING,
|
|
ADD_FEES_TO_ORD_SUCCESS,
|
|
ADD_FEES_TO_ORD_FAILED,
|
|
} from '../constants';
|
|
|
|
import API from '../../utilities/api';
|
|
|
|
export const fetchMappings = (dispatch) => {
|
|
dispatch({type: FETCH_MAPPINGS_PENDING});
|
|
API.get('integration/mappings')
|
|
.then(response => {
|
|
dispatch({type: FETCH_MAPPINGS_SUCCESS, payload: response.data});
|
|
})
|
|
.catch(error => {
|
|
dispatch({type: FETCH_MAPPINGS_FAILED, payload: error.response});
|
|
});
|
|
};
|
|
|
|
export const addNewMapping = (dispatch, mapping) => {
|
|
dispatch({type: ADD_NEW_MAPPING_PENDING});
|
|
API.post('integration/mappings', {
|
|
mapping
|
|
})
|
|
.then(response => {
|
|
dispatch({type: ADD_NEW_MAPPING_SUCCESS, payload: response.data});
|
|
})
|
|
.catch(error => {
|
|
dispatch({type: ADD_NEW_MAPPING_FAILED, payload: error.response});
|
|
});
|
|
};
|
|
|
|
export const fetchIncidents = (dispatch, dateRange) => {
|
|
const { startDate, endDate } = dateRange;
|
|
|
|
dispatch({type: FETCH_INCIDENTS_PENDING});
|
|
API.get(`integration/report/allIncidents/${startDate}/${endDate}`)
|
|
.then(response => {
|
|
dispatch({type: FETCH_INCIDENTS_SUCCESS, payload: response.data});
|
|
})
|
|
.catch(error => {
|
|
dispatch({type: FETCH_INCIDENTS_FAILED, payload: error.response});
|
|
});
|
|
};
|
|
|
|
export const fetchMembersList = (dispatch) => {
|
|
dispatch({type: FETCH_MEMBERS_PENDING});
|
|
API.get('officeRnD/membersList')
|
|
.then(response => {
|
|
dispatch({type: FETCH_MEMBERS_SUCCESS, payload: response.data});
|
|
})
|
|
.catch(error => {
|
|
dispatch({type: FETCH_MEMBERS_FAILED, payload: error.response});
|
|
});
|
|
};
|
|
|
|
export const fetchMemberIncidents = (dispatch, memberId, dateRange) => {
|
|
const { startDate, endDate } = dateRange;
|
|
|
|
dispatch({type: FETCH_MEMBER_INCIDENTS_PENDING});
|
|
API.get(`integration/report/member/${memberId}/${startDate}/${endDate}`)
|
|
.then(response => {
|
|
dispatch({type: FETCH_MEMBER_INCIDENTS_SUCCESS, payload: response.data});
|
|
})
|
|
.catch(error => {
|
|
dispatch({type: FETCH_MEMBER_INCIDENTS_FAILED, payload: error.response});
|
|
});
|
|
};
|
|
|
|
export const addFeesToOrd = (dispatch, dateRange, memberIds) => {
|
|
dispatch({type: ADD_FEES_TO_ORD_PENDING});
|
|
API.post(`integration/addFees`, {
|
|
dateRange,
|
|
memberIds: memberIds || [],
|
|
})
|
|
.then(response => {
|
|
dispatch({type: ADD_FEES_TO_ORD_SUCCESS, payload: response.data});
|
|
})
|
|
.catch(error => {
|
|
dispatch({type: ADD_FEES_TO_ORD_FAILED, payload: error.response});
|
|
});
|
|
};
|