55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
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;
|