Liferay.Loader.define("portal-workflow-metrics-web@2.0.42/js/components/process-metrics/workload-by-assignee-card/WorkloadByAssigneeCardBody.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/router/ChildLink.es', '../../AppContext.es', './WorkloadByAssigneeCardTable.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.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 _ChildLink = _interopRequireDefault(require("../../../shared/components/router/ChildLink.es"));

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

    var _WorkloadByAssigneeCardTable = require("./WorkloadByAssigneeCardTable.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 currentTab = _ref.currentTab,
          items = _ref.items,
          processId = _ref.processId,
          processStepKey = _ref.processStepKey,
          totalCount = _ref.totalCount;

      var getEmptyMessage = function getEmptyMessage(tab) {
        switch (tab) {
          case 'onTime':
            return Liferay.Language.get('there-are-no-assigned-items-on-time-at-the-moment');

          case 'overdue':
            return Liferay.Language.get('there-are-no-assigned-items-overdue-at-the-moment');

          default:
            return Liferay.Language.get('there-are-no-items-assigned-to-users-at-the-moment');
        }
      };

      var statesProps = (0, _react.useMemo)(function () {
        return {
          emptyProps: {
            className: 'py-6',
            hideAnimation: true,
            message: getEmptyMessage(currentTab),
            messageClassName: 'small'
          },
          errorProps: {
            actionButton: _react["default"].createElement(_ReloadButton["default"], null),
            className: 'py-6',
            hideAnimation: true,
            message: Liferay.Language.get('there-was-a-problem-retrieving-data-please-try-reloading-the-page'),
            messageClassName: 'small'
          },
          loadingProps: {
            className: 'py-6'
          }
        };
      }, [currentTab]);
      return _react["default"].createElement(_Panel["default"].Body, null, _react["default"].createElement(_ContentView["default"], statesProps, totalCount > 0 && _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(Body.Table, {
        currentTab: currentTab,
        items: items,
        processId: processId,
        processStepKey: processStepKey
      }), _react["default"].createElement(Body.Footer, {
        processId: processId,
        processStepKey: processStepKey,
        totalCount: totalCount
      }))));
    };

    exports.Body = Body;

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

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

      var filters = {};

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

      var viewAllAssigneesUrl = "/workload/assignee/".concat(processId, "/").concat(defaultDelta, "/1/overdueTaskCount:desc");
      return _react["default"].createElement("div", {
        className: "mb-1 text-right"
      }, _react["default"].createElement(_ChildLink["default"], {
        className: "border-0 btn btn-secondary btn-sm",
        query: {
          filters: filters
        },
        to: viewAllAssigneesUrl
      }, _react["default"].createElement("span", {
        className: "mr-2",
        "data-testid": "viewAllAssignees"
      }, "".concat(Liferay.Language.get('view-all-assignees'), " (").concat(totalCount, ")")), _react["default"].createElement(_icon["default"], {
        symbol: "caret-right-l"
      })));
    };

    Body.Footer = Footer;
    Body.Table = _WorkloadByAssigneeCardTable.Table;
    //# sourceMappingURL=WorkloadByAssigneeCardBody.es.js.map
  }
});
//# sourceMappingURL=WorkloadByAssigneeCardBody.es.js.map