Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- SUCCESS_USERS_RESULT,
- FAILURE_RESULT,
- REQUEST_USERS
- } from "../constants"
- const initialState = {
- users: [],
- isFetching: false,
- isLoaded: false,
- activeUserId: 0,
- checkedCityId: 0
- }
- function userReducer(state = initialState, action) {
- switch(action.type) {
- case SUCCESS_USERS_RESULT:
- return {
- ...state,
- isFetching: false,
- users: action.users,
- isLoaded: true,
- activeUserId: action.activeUserId
- };
- case REQUEST_USERS:
- return {
- ...state,
- isFetching: true,
- checkedCityId: action.checkedCityId
- };
- case FAILURE_RESULT:
- return {
- isFetching: false,
- error: action.error
- };
- default:
- return state
- }
- }
- export default userReducer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement