"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.FiltersModal = void 0;

var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));

var _react = _interopRequireDefault(require("react"));

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _lib = require("@sentecacommerce-theme/lib");

var _Common = require("../../../Common");

var _Aggregates = require("../Aggregates");

var _Components = require("./Components");

var _Components2 = require("../Aggregates/Components");

var _templateObject;

var FiltersModal = function FiltersModal(_ref) {
  var data = _ref.data,
      onClose = _ref.onClose,
      isLoading = _ref.isLoading,
      isFetching = _ref.isFetching,
      totalResults = _ref.totalResults,
      filtersCount = _ref.filtersCount,
      clearFilters = _ref.clearFilters;
  var labels = (0, _lib.useLocalLabels)();

  var _useListingConfig = (0, _lib.useListingConfig)(),
      defaultSortKey = _useListingConfig.defaultSortKey,
      sortOptions = _useListingConfig.sortOptions;

  return /*#__PURE__*/_react["default"].createElement(_Common.AnimatedModal, {
    isRoot: true,
    title: "Filters",
    onClose: onClose,
    isContentDisabled: isFetching,
    bottom: filtersCount ? function (_ref2) {
      var closeModal = _ref2.closeModal;
      return /*#__PURE__*/_react["default"].createElement(_Components2.ButtonsContainer, {
        noClear: true
      }, /*#__PURE__*/_react["default"].createElement(_Common.Button, {
        onClick: closeModal,
        fullWidth: true
      }, /*#__PURE__*/_react["default"].createElement("span", null, labels.showResults.replace(':results:', (totalResults == null ? void 0 : totalResults.toString()) || '0'))));
    } : undefined
  }, /*#__PURE__*/_react["default"].createElement(_Components.MobileSort, {
    sortOptions: sortOptions,
    defaultSortKey: defaultSortKey
  }), !data || isLoading ? /*#__PURE__*/_react["default"].createElement(LoaderContainer, null, /*#__PURE__*/_react["default"].createElement(_Common.Loader, null)) : /*#__PURE__*/_react["default"].createElement(_Aggregates.Aggregates, {
    data: data
  }));
};

exports.FiltersModal = FiltersModal;

var LoaderContainer = _styledComponents["default"].div.attrs({
  className: 'd-flex align-items-center justify-content-center'
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  width: 100%;\n  height: 100%;\n"])));
//# sourceMappingURL=index.js.map