You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
7 years ago
|
import {
|
||
|
IS_SENDING_USER_REQUEST,
|
||
|
SET_USER_REQUEST_ERROR,
|
||
|
CLEAR_USER_REQUEST_ERROR,
|
||
|
SET_USER_REQUEST_SUCCESS,
|
||
|
CLEAR_USER_REQUEST_SUCCESS,
|
||
|
SET_SELF_USER
|
||
|
} from "../constants/user.constants";
|
||
|
|
||
|
const initialState = {
|
||
|
isSendingUserRequest: false,
|
||
|
userRequestError: "",
|
||
|
userRequestSuccess: "",
|
||
|
selfUser: {}
|
||
|
};
|
||
|
|
||
|
function userReducer(state = initialState, action) {
|
||
|
switch (action.type) {
|
||
|
case IS_SENDING_USER_REQUEST:
|
||
|
return {
|
||
|
...state,
|
||
|
isSendingUserRequest: action.data
|
||
|
};
|
||
|
case SET_USER_REQUEST_ERROR:
|
||
|
return {
|
||
|
...state,
|
||
|
userRequestError: action.data
|
||
|
};
|
||
|
case CLEAR_USER_REQUEST_ERROR:
|
||
|
return {
|
||
|
...state,
|
||
|
userRequestError: ""
|
||
|
};
|
||
|
case SET_USER_REQUEST_SUCCESS:
|
||
|
return {
|
||
|
...state,
|
||
|
userRequestSuccess: action.data
|
||
|
};
|
||
|
case CLEAR_USER_REQUEST_SUCCESS:
|
||
|
return {
|
||
|
...state,
|
||
|
userRequestSuccess: ""
|
||
|
};
|
||
|
case SET_SELF_USER:
|
||
|
return {
|
||
|
...state,
|
||
|
selfUser: action.data
|
||
|
};
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default userReducer;
|