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

@@ -0,0 +1,38 @@
import {
FETCH_INCIDENTS_PENDING,
FETCH_INCIDENTS_SUCCESS,
FETCH_INCIDENTS_FAILED,
} from '../constants';
const initialState = {
pending: false,
result: null,
error: null,
};
export const incidentsReport = (state, action) => {
state = state || initialState;
action = action || {};
switch(action.type){
case FETCH_INCIDENTS_PENDING:
return Object.assign({}, state, {
pending: true,
error: null,
});
case FETCH_INCIDENTS_SUCCESS:
return Object.assign({}, state, {
pending: false,
result: action.payload,
error: null,
});
case FETCH_INCIDENTS_FAILED:
return Object.assign({}, state, {
pending: false,
result: {},
error: action.payload,
});
default:
return state;
}
};

View File

@@ -1,12 +1,14 @@
import { combineReducers } from "redux";
import { combineReducers } from 'redux';
import { doorLockData} from "./doorLockReducers";
import { mappingsData } from "./mappingsReducer";
import { doorLockData} from './doorLockReducers';
import { mappingsData } from './mappingsReducer';
import { addMapping } from './addMappingReducer';
import { incidentsReport } from './incidentsReportReducer';
export const rootReducer = combineReducers({
doorLockData,
mappingsData,
addMapping,
incidentsReport,
});