fetch and display door lock incidents on frontend

This commit is contained in:
Bilal Catic
2019-06-17 12:45:23 +02:00
parent f9bd84c9c5
commit 781943026a
7 changed files with 199 additions and 6 deletions

View File

@@ -5,7 +5,10 @@ import {
ADD_NEW_MAPPING_PENDING,
ADD_NEW_MAPPING_SUCCESS,
ADD_NEW_MAPPING_FAILED,
} from "../constants";
FETCH_INCIDENTS_PENDING,
FETCH_INCIDENTS_SUCCESS,
FETCH_INCIDENTS_FAILED,
} from '../constants';
import API from '../../utilities/api';
@@ -32,3 +35,14 @@ export const addNewMapping = (dispatch, mapping) => {
dispatch({type: ADD_NEW_MAPPING_FAILED, payload: error.response});
});
};
export const fetchIncidents = (dispatch) => {
dispatch({type: FETCH_INCIDENTS_PENDING});
API.get('integration/report/allIncidents')
.then(response => {
dispatch({type: FETCH_INCIDENTS_SUCCESS, payload: response.data});
})
.catch(error => {
dispatch({type: FETCH_INCIDENTS_FAILED, payload: error.response});
});
};