add mapping; prevent upload before mapping office / resource
This commit is contained in:
38
client/src/store/reducers/addMappingReducer.js
Normal file
38
client/src/store/reducers/addMappingReducer.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
ADD_NEW_MAPPING_PENDING,
|
||||
ADD_NEW_MAPPING_SUCCESS,
|
||||
ADD_NEW_MAPPING_FAILED,
|
||||
} from "../constants";
|
||||
|
||||
const initialState = {
|
||||
pending: false,
|
||||
result: null,
|
||||
error: null,
|
||||
};
|
||||
|
||||
export const addMapping = (state, action) => {
|
||||
state = state || initialState;
|
||||
action = action || {};
|
||||
|
||||
switch(action.type){
|
||||
case ADD_NEW_MAPPING_PENDING:
|
||||
return Object.assign({}, state, {
|
||||
pending: true,
|
||||
error: null,
|
||||
});
|
||||
case ADD_NEW_MAPPING_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
pending: false,
|
||||
result: action.payload,
|
||||
error: null,
|
||||
});
|
||||
case ADD_NEW_MAPPING_FAILED:
|
||||
return Object.assign({}, state, {
|
||||
pending: false,
|
||||
result: {},
|
||||
error: action.payload,
|
||||
});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
@@ -1,8 +1,12 @@
|
||||
import { combineReducers } from "redux";
|
||||
|
||||
import { doorLockData} from "./doorLockReducers";
|
||||
import { mappingsData } from "./mappingsReducer";
|
||||
import { addMapping } from './addMappingReducer';
|
||||
|
||||
export const rootReducer = combineReducers({
|
||||
doorLockData
|
||||
doorLockData,
|
||||
mappingsData,
|
||||
addMapping,
|
||||
});
|
||||
|
||||
|
||||
38
client/src/store/reducers/mappingsReducer.js
Normal file
38
client/src/store/reducers/mappingsReducer.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
FETCH_MAPPINGS_PENDING,
|
||||
FETCH_MAPPINGS_SUCCESS,
|
||||
FETCH_MAPPINGS_FAILED,
|
||||
} from "../constants";
|
||||
|
||||
const initialState = {
|
||||
pending: false,
|
||||
result: null,
|
||||
error: null,
|
||||
};
|
||||
|
||||
export const mappingsData = (state, action) => {
|
||||
state = state || initialState;
|
||||
action = action || {};
|
||||
|
||||
switch(action.type){
|
||||
case FETCH_MAPPINGS_PENDING:
|
||||
return Object.assign({}, state, {
|
||||
pending: true,
|
||||
error: null,
|
||||
});
|
||||
case FETCH_MAPPINGS_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
pending: false,
|
||||
result: action.payload,
|
||||
error: null,
|
||||
});
|
||||
case FETCH_MAPPINGS_FAILED:
|
||||
return Object.assign({}, state, {
|
||||
pending: false,
|
||||
result: {},
|
||||
error: action.payload,
|
||||
});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user