2019-06-10 05:58:09 +02:00
|
|
|
import {
|
|
|
|
|
FETCH_MAPPINGS_PENDING,
|
|
|
|
|
FETCH_MAPPINGS_SUCCESS,
|
|
|
|
|
FETCH_MAPPINGS_FAILED,
|
|
|
|
|
ADD_NEW_MAPPING_PENDING,
|
|
|
|
|
ADD_NEW_MAPPING_SUCCESS,
|
|
|
|
|
ADD_NEW_MAPPING_FAILED,
|
2019-06-17 12:45:23 +02:00
|
|
|
FETCH_INCIDENTS_PENDING,
|
|
|
|
|
FETCH_INCIDENTS_SUCCESS,
|
|
|
|
|
FETCH_INCIDENTS_FAILED,
|
|
|
|
|
} from '../constants';
|
2019-06-10 05:58:09 +02:00
|
|
|
|
|
|
|
|
import API from '../../utilities/api';
|
|
|
|
|
|
|
|
|
|
export const fetchMappings = (dispatch) => {
|
|
|
|
|
dispatch({type: FETCH_MAPPINGS_PENDING});
|
2019-06-14 08:05:24 +02:00
|
|
|
API.get('integration/mappings')
|
2019-06-10 05:58:09 +02:00
|
|
|
.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});
|
2019-06-14 08:05:24 +02:00
|
|
|
API.post('integration/mappings', {
|
2019-06-10 05:58:09 +02:00
|
|
|
mapping
|
|
|
|
|
})
|
|
|
|
|
.then(response => {
|
|
|
|
|
dispatch({type: ADD_NEW_MAPPING_SUCCESS, payload: response.data});
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
dispatch({type: ADD_NEW_MAPPING_FAILED, payload: error.response});
|
|
|
|
|
});
|
|
|
|
|
};
|
2019-06-17 12:45:23 +02:00
|
|
|
|
2019-06-17 20:10:57 +02:00
|
|
|
export const fetchIncidents = (dispatch, dateRange) => {
|
2019-06-18 10:14:11 +02:00
|
|
|
const { startDate, endDate } = dateRange;
|
|
|
|
|
|
2019-06-17 12:45:23 +02:00
|
|
|
dispatch({type: FETCH_INCIDENTS_PENDING});
|
2019-06-18 10:14:11 +02:00
|
|
|
API.get(`integration/report/allIncidents/${startDate}/${endDate}`)
|
2019-06-17 12:45:23 +02:00
|
|
|
.then(response => {
|
|
|
|
|
dispatch({type: FETCH_INCIDENTS_SUCCESS, payload: response.data});
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
dispatch({type: FETCH_INCIDENTS_FAILED, payload: error.response});
|
|
|
|
|
});
|
|
|
|
|
};
|