"use strict";

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

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

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

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

require("./index.css");

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

function Score(props) {
  var editable = props.editable,
      score = props.score,
      _props$onClick = props.onClick,
      onClick = _props$onClick === void 0 ? function () {} : _props$onClick,
      _props$isEvaluate = props.isEvaluate,
      isEvaluate = _props$isEvaluate === void 0 ? true : _props$isEvaluate;

  var clickHandler = function clickHandler() {
    if (!editable) return;
    onClick && onClick();
  };

  var getIconType = function getIconType(score) {
    var type = "";

    if (!isEvaluate) {
      type = "level-0";
    } else if (score == 1) {
      type = "level-4";
    } else if (score >= 0.9 && score < 1) {
      type = "level-5";
    } else if (score >= 0.8 && score < 0.9) {
      type = "level-3";
    } else if (score >= 0.4 && score < 0.8) {
      type = "level-2";
    } else if (score >= 0 && score < 0.4) {
      type = "level-1";
    }

    return type;
  };

  return /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("okr-drawer-score", {
      "okr-drawer-score--editable": editable
    }),
    onClick: clickHandler
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("okr-drawer-score__icon", "okr-drawer-score__icon--".concat(getIconType(score)))
  }), isEvaluate ? /*#__PURE__*/_react["default"].createElement("span", {
    className: "okr-drawer-score__text"
  }, score == 1 ? "1" : Number(score).toFixed(2) * 1, "\u5206") : /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", null), /*#__PURE__*/_react["default"].createElement("span", null, editable ? (0, _getLocale.getLocale)("Per_Ass_New_Appr_detail_Scor") : "--")));
}

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