"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

var _okrProgressDetail = _interopRequireDefault(require("../../../okr-progress-detail"));

var _title = _interopRequireDefault(require("../title"));

var _tooltipText = _interopRequireDefault(require("../../../tooltip/tooltip-text"));

var _drawerManager = _interopRequireDefault(require("../../../drawer-manager"));

var _getLocale = require("../../../../utils/getLocale");

var _openData = require("../../../../utils/open-data");

require("./index.css");

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

var renderTitle = function renderTitle(index, title, id) {
  var handleTitleClick = function handleTitleClick() {
    _drawerManager["default"].open("krDetail", {
      krId: id
    });
  };

  return /*#__PURE__*/_react["default"].createElement("span", {
    onClick: handleTitleClick
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "kr-progress__order"
  }, "KR", index + 1), /*#__PURE__*/_react["default"].createElement(_tooltipText["default"], {
    text: (0, _openData.parseString)(title),
    maxWidth: 600,
    exClass: "kr-progress__title-text"
  }));
};

var KrProgress = function KrProgress(_ref) {
  var data = _ref.data;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "kr-progress__container"
  }, /*#__PURE__*/_react["default"].createElement(_title["default"], {
    title: (0, _getLocale.getLocale)("OKR_MyO_Prog_Butt_KRprogress")
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "kr-progress__content-wrapper"
  }, data && data.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement(_okrProgressDetail["default"], {
      key: index,
      riskLevel: item.riskLevel,
      title: renderTitle(index, item.title, item.id),
      percent: item.percent,
      oldPercent: item.oldPercent,
      content: item.content,
      time: item.time,
      canEdit: false,
      id: item.id,
      rightTip: item.rightTip
    });
  })));
};

var _default = KrProgress;
exports["default"] = _default;