'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _keyBy = require('lodash/keyBy');

var _keyBy2 = _interopRequireDefault(_keyBy);

var _immutable = require('immutable');

var _constants = require('../../constants');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var addShareBanks = function addShareBanks(state, sharedBank) {
  return state.mergeDeep((0, _immutable.fromJS)((0, _keyBy2.default)(sharedBank, 'id')));
};

exports.default = function () {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _immutable.fromJS)({});
  var action = arguments[1];

  switch (action.type) {
    case _constants.ADD_SHARED_BANKS:
      return addShareBanks(state, action.payload);
    case _constants.REMOVE_SHARED_BANK:
      return state.remove(action.payload);
    default:
      return state;
  }
};