'use strict';

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

var _redux = require('redux');

var _immutable = require('immutable');

var _reactRedux = require('../../../common/react-redux');

var _banks = require('../../api/banks');

var _sharedBanks = require('../../../common/actions/sharedBanks');

var _presenter = require('./presenter');

var _presenter2 = _interopRequireDefault(_presenter);

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

function mapStateToProps(state, ownProps) {
  var sharedBanks = state.get('sharedBanks', (0, _immutable.Map)()).filter(function (sharedBank) {
    return sharedBank.get('bankId') === ownProps.bank.id;
  }).toList();

  return {
    sharedBanks: sharedBanks
  };
}

var mapDispatchToProps = {
  shareBank: _banks.shareBank,
  getSharedBanks: _banks.getSharedBanks,
  updateSharedBankPermission: _banks.updateSharedBankPermission,
  getBank: _banks.getBank,
  removeSharedBank: _sharedBanks.removeSharedBank
};

exports.default = (0, _redux.compose)((0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps))(_presenter2.default);