Files
caremyway-client/src/reducers/pShiftReducer.js
T
2018-04-22 23:04:09 -06:00

53 lines
1.1 KiB
JavaScript

import {
IS_SENDING_PSHIFT_REQUEST,
SET_PSHIFT_REQUEST_ERROR,
SET_PSHIFT_REQUEST_SUCCESS,
CLEAR_PSHIFT_REQUEST_ERROR,
CLEAR_PSHIFT_REQUEST_SUCCESS,
SET_CLEAR_PSHIFT_STATE
} from "../constants/pShift.constants";
const initialState = {
isSendingPShiftRequest: false,
pShiftRequestError: "",
pShiftRequestSuccess: ""
};
function pShiftReducer(state = initialState, action) {
switch (action.type) {
case IS_SENDING_PSHIFT_REQUEST:
return {
...state,
isSendingPShiftRequest: action.data
};
case SET_PSHIFT_REQUEST_ERROR:
return {
...state,
pShiftRequestError: action.data
};
case CLEAR_PSHIFT_REQUEST_ERROR:
return {
...state,
pShiftRequestError: ""
};
case SET_PSHIFT_REQUEST_SUCCESS:
return {
...state,
pShiftRequestSuccess: action.data
};
case CLEAR_PSHIFT_REQUEST_SUCCESS:
return {
...state,
pShiftRequestSuccess: ""
};
case SET_CLEAR_PSHIFT_STATE:
return {
...initialState
};
default:
return { ...state };
}
}
export default pShiftReducer;