import * as actions from './main';
import * as types from '../constants/actionTypes';

const createReducer = (handlers: {[key: string]: any}) => (state: Object, action: { type: string }) => {
  if(!handlers.hasOwnProperty(action.type)) {
    return state;
  }

  return handlers[action.type](state, action);
};

export default createReducer({
  [types.SWITCH_NAVBAR]: actions.navbarState,
  [types.SWITCH_SIDEBAR]: actions.sidebarState,
});
