Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {FETCH_USERS, FETCH_USERS_SUCCESS, FETCH_USERS_FAILURE, RESET} from '../actions/userActions.js';
- const INITIAL_STATE = {
- userList: {
- users: [],
- user: {},
- showUserFormModal: false,
- error: null,
- loading: false
- }
- };
- export default function reducer(state = INITIAL_STATE, action) {
- switch (action.type) {
- case FETCH_USERS: {
- return {
- ...state, userList: {users: [], error: null, loading: true}
- };
- }
- case FETCH_USERS_SUCCESS: {
- return {
- ...state, userList: {users: action.payload, error: null, loading: false}
- };
- }
- case FETCH_USERS_FAILURE: {
- return {
- ...state, userList: {users: [], error: action.payload, loading: false}
- };
- }
- case RESET: {
- return {
- ...state, userList: {users: [], error: action.payload, loading: action.payload}
- };
- }
- default: {
- return state;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment