"use strict";

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

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

var _classnames = _interopRequireDefault(require("classnames"));

var _scrollbar = _interopRequireDefault(require("../../../../scrollbar"));

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

var _utils = require("./utils");

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

require("./index.css");

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

var prefix = "titaui-dynamic-summary-table-row-okr";

var TableRowOKR = function TableRowOKR(_ref) {
  var text = _ref.text,
      id = _ref.id,
      _ref$isO = _ref.isO,
      isO = _ref$isO === void 0 ? true : _ref$isO,
      _ref$isFirstLevel = _ref.isFirstLevel,
      isFirstLevel = _ref$isFirstLevel === void 0 ? true : _ref$isFirstLevel,
      _ref$order = _ref.order,
      order = _ref$order === void 0 ? 1 : _ref$order,
      data = _ref.data;

  var handleClickTitle = function handleClickTitle() {
    if (isO) {
      _drawerManager["default"].open("okrDetail", {
        okrId: id
      });
    } else {
      _drawerManager["default"].open("krDetail", {
        krId: id
      });
    }
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: prefix
  }, /*#__PURE__*/_react["default"].createElement(_scrollbar["default"], {
    style: {
      maxHeight: 164
    }
  }, isFirstLevel && /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "__common"),
    onClick: handleClickTitle
  }, /*#__PURE__*/_react["default"].createElement("i", {
    className: "tu-icon-H5-".concat(isO ? "O" : "KR", "-s ").concat(prefix, "__common-icon")
  }), /*#__PURE__*/_react["default"].createElement("p", null, /*#__PURE__*/_react["default"].createElement("span", null, (0, _openData.parseString)(text)), isO && (0, _utils.formatPeriod)({
    annualNum: data.AnnualNum,
    yqmNum: data.YqmNum,
    cycleType: data.CycleType,
    startDate: data.StartDate,
    endDate: data.EndDate
  }) !== '' && /*#__PURE__*/_react["default"].createElement("span", {
    className: "".concat(prefix, "__common-time")
  }, (0, _utils.formatPeriod)({
    annualNum: data.AnnualNum,
    yqmNum: data.YqmNum,
    cycleType: data.CycleType,
    startDate: data.StartDate,
    endDate: data.EndDate
  })))), !isFirstLevel && /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(prefix, "__kr")),
    onClick: handleClickTitle
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("".concat(prefix, "__kr-order"))
  }, "KR", order), /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("".concat(prefix, "__kr-text"))
  }, (0, _openData.parseString)(text)))));
};

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