"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

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

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

var _classify = _interopRequireDefault(require("./classify"));

var _principal = _interopRequireDefault(require("./principal"));

var _visibility = _interopRequireDefault(require("./visibility"));

var _okrType = _interopRequireDefault(require("./okr-type"));

var _dateCycle = _interopRequireDefault(require("./date-cycle"));

require("./other-infos.css");

var _bsGlobal = require("../../../../utils/bs-global");

var _context = require("../../context");

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var OtherInfos = function OtherInfos(_ref) {
  var okrId = _ref.okrId,
      _ref$classifyValue = _ref.classifyValue,
      classifyValue = _ref$classifyValue === void 0 ? 0 : _ref$classifyValue,
      setClassifyValue = _ref.setClassifyValue,
      principalUser = _ref.principalUser,
      setPrincipalUser = _ref.setPrincipalUser,
      _ref$visibility = _ref.visibility,
      visibility = _ref$visibility === void 0 ? 1 : _ref$visibility,
      visiableLimit = _ref.visiableLimit,
      onChangeVisiableLimit = _ref.onChangeVisiableLimit,
      _ref$canEdit = _ref.canEdit,
      canEdit = _ref$canEdit === void 0 ? false : _ref$canEdit;
  var setting = (0, _bsGlobal.getOkrAdvancedSetting)();

  var _useContext = (0, _react.useContext)(_context.GeneralDataContext),
      generalCycle = _useContext.generalCycle,
      setGeneralCycle = _useContext.setGeneralCycle;

  var handleChangeUser = function handleChangeUser(data) {
    setPrincipalUser(_objectSpread({
      name: data.name,
      avatar: data.avatar,
      id: data.userId
    }, data));
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "other-info-wrapper"
  }, /*#__PURE__*/_react["default"].createElement(_dateCycle["default"], {
    okrId: okrId,
    cycle: generalCycle,
    setCycle: setGeneralCycle,
    canEdit: canEdit
  }), /*#__PURE__*/_react["default"].createElement(_principal["default"], {
    canEdit: canEdit,
    user: principalUser,
    onChangeUser: handleChangeUser
  }), /*#__PURE__*/_react["default"].createElement(_visibility["default"], {
    canEdit: canEdit,
    visibility: visibility,
    visiableLimit: visiableLimit,
    onChangeVisiableLimit: onChangeVisiableLimit
  }), setting.KRSetting.OkrTypeSetting && /*#__PURE__*/_react["default"].createElement(_okrType["default"], {
    okrId: okrId,
    canEdit: canEdit
  }), setting.KRSetting.OkrClassify && /*#__PURE__*/_react["default"].createElement(_classify["default"], {
    initValue: classifyValue,
    onChangeClassify: setClassifyValue,
    canEdit: canEdit
  }));
};

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