Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/process-metrics/performance-by-assignee-card/PerformanceByAssigneeCardBody.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/icon', 'frontend-js-react-web$react', '../../../shared/components/Panel.es', '../../../shared/components/content-view/ContentView.es', '../../../shared/components/list/ReloadButton.es', '../../../shared/components/promises-resolver/PromisesResolver.es', '../../../shared/components/router/ChildLink.es', '../../AppContext.es', './PerformanceByAssigneeCardTable.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.Footer = exports.Body = void 0;

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _Panel = _interopRequireDefault(require("../../../shared/components/Panel.es"));

    var _ContentView = _interopRequireDefault(require("../../../shared/components/content-view/ContentView.es"));

    var _ReloadButton = _interopRequireDefault(require("../../../shared/components/list/ReloadButton.es"));

    var _PromisesResolver = _interopRequireDefault(require("../../../shared/components/promises-resolver/PromisesResolver.es"));

    var _ChildLink = _interopRequireDefault(require("../../../shared/components/router/ChildLink.es"));

    var _AppContext = require("../../AppContext.es");

    var _PerformanceByAssigneeCardTable = require("./PerformanceByAssigneeCardTable.es");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

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

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * The contents of this file are subject to the terms of the Liferay Enterprise
     * Subscription License ("License"). You may not use this file except in
     * compliance with the License. You can obtain a copy of the License by
     * contacting Liferay, Inc. See the License for the specific language governing
     * permissions and limitations under the License, including but not limited to
     * distribution rights of the Software.
     */
    var Body = function Body(_ref) {
      var filtered = _ref.filtered,
          items = _ref.items,
          totalCount = _ref.totalCount;
      var statesProps = (0, _react.useMemo)(function () {
        return {
          emptyProps: {
            className: 'mt-5 py-8',
            filtered: filtered,
            hideAnimation: true,
            messageClassName: 'small'
          },
          errorProps: {
            actionButton: /*#__PURE__*/_react.default.createElement(_ReloadButton.default, null),
            className: 'mt-4 py-8',
            hideAnimation: true,
            message: Liferay.Language.get('there-was-a-problem-retrieving-data-please-try-reloading-the-page'),
            messageClassName: 'small'
          },
          loadingProps: {
            className: 'mt-4 py-8'
          }
        };
      }, [filtered]);
      return (/*#__PURE__*/_react.default.createElement(_Panel.default.Body, null, /*#__PURE__*/_react.default.createElement(_ContentView.default, statesProps, totalCount > 0 && /*#__PURE__*/_react.default.createElement(Body.Table, {
          items: items
        })))
      );
    };

    exports.Body = Body;

    var Footer = function Footer(_ref2) {
      var processId = _ref2.processId,
          processStep = _ref2.processStep,
          timeRange = _ref2.timeRange,
          totalCount = _ref2.totalCount;

      var _useContext = (0, _react.useContext)(_AppContext.AppContext),
          defaultDelta = _useContext.defaultDelta;

      var filters = {};
      var dateEnd = timeRange.dateEnd,
          dateStart = timeRange.dateStart,
          key = timeRange.key;

      if (dateEnd && dateStart && key) {
        filters.dateEnd = dateEnd;
        filters.dateStart = dateStart;
        filters.timeRange = [key];
      }

      if (processStep && processStep !== 'allSteps') {
        filters.taskNames = [processStep];
      }

      var viewAllAssigneesUrl = "/performance/assignee/".concat(processId, "/").concat(defaultDelta, "/1/durationTaskAvg:desc/");
      return (/*#__PURE__*/_react.default.createElement(_PromisesResolver.default.Resolved, null, totalCount > 0 ? /*#__PURE__*/_react.default.createElement(_Panel.default.Footer, {
          elementClasses: "fixed-bottom"
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "mb-1 text-right"
        }, /*#__PURE__*/_react.default.createElement(_ChildLink.default, {
          className: "border-0 btn btn-secondary btn-sm",
          query: {
            filters: filters
          },
          to: viewAllAssigneesUrl
        }, /*#__PURE__*/_react.default.createElement("span", {
          className: "mr-2"
        }, "".concat(Liferay.Language.get('view-all-assignees'), " (").concat(totalCount, ")")), /*#__PURE__*/_react.default.createElement(_icon.default, {
          symbol: "caret-right-l"
        })))) : null)
      );
    };

    exports.Footer = Footer;
    Body.Table = _PerformanceByAssigneeCardTable.Table;
    //# sourceMappingURL=PerformanceByAssigneeCardBody.es.js.map
  }
});
//# sourceMappingURL=PerformanceByAssigneeCardBody.es.js.map