All files / src/reducers horsemanPaginationReducer.js

100% Statements 5/5
100% Branches 4/4
100% Functions 1/1
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30    2x     5x   1x                 2x                 2x        
import * as types from "../constants/ActionTypes";
 
const initialState = {};
 
export default function paginations(state = initialState, action) {
  switch (action.type) {
    case types.SET_PAGE_TOTAL: {
      return {
        ...state,
        [action.handle]: {
          ...state[action.handle],
          totalPages: action.data.totalPages,
        },
      };
    }
    case types.SET_CURRENT_PAGE: {
      return {
        ...state,
        [action.handle]: {
          ...state[action.handle],
          currentPage: action.data.currentPage,
        },
      };
    }
    default: {
      return state;
    }
  }
}