'use strict';

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

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactRedux = require('react-redux');

var _reactIntl = require('react-intl');

var _Typography = require('@material-ui/core/Typography');

var _Typography2 = _interopRequireDefault(_Typography);

var _FieldList = require('./FieldList');

var _FieldList2 = _interopRequireDefault(_FieldList);

var _filterable_fields = require('../../selectors/filterable_fields');

var _filterable_fields2 = _interopRequireDefault(_filterable_fields);

var _filter_fields = require('../../selectors/filter_fields');

var _filter_fields2 = _interopRequireDefault(_filter_fields);

var _action_creators = require('../../action_creators');

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

var messages = (0, _reactIntl.defineMessages)({
  description: {
    'id': 'filter.filters.description',
    'defaultMessage': 'Select the fields you would like to use to filter the data:'
  }
});

var FilterConfigurator = function FilterConfigurator(_ref) {
  var filterableFields = _ref.filterableFields,
      visibleFilters = _ref.visibleFilters,
      onUpdateVisibleFilters = _ref.onUpdateVisibleFilters;
  return _react2.default.createElement(
    'div',
    null,
    _react2.default.createElement(
      _Typography2.default,
      null,
      _react2.default.createElement(_reactIntl.FormattedMessage, messages.description)
    ),
    _react2.default.createElement(_FieldList2.default, { fields: filterableFields, visibleFields: visibleFilters, onUpdate: onUpdateVisibleFilters })
  );
};

FilterConfigurator.propTypes = {
  filterableFields: _propTypes2.default.array.isRequired,
  onUpdateVisibleFilters: _propTypes2.default.func.isRequired,
  visibleFilters: _propTypes2.default.array.isRequired
};

function mapStateToProps(state) {
  return {
    filterableFields: (0, _filterable_fields2.default)(state),
    visibleFilters: (0, _filter_fields2.default)(state)
  };
}

function mapDispatchToProps(dispatch) {
  return {
    onUpdateVisibleFilters: function onUpdateVisibleFilters(filters) {
      return dispatch((0, _action_creators.updateVisibleFilters)(filters));
    }
  };
}

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(FilterConfigurator);
//# sourceMappingURL=FilterSettings.js.map