"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _button = _interopRequireDefault(require("devextreme-react/button"));
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; }
var ComponentSignButton = function ComponentSignButton(_ref) {
  var data = _ref.data,
    _onClick = _ref.onClick,
    mutable = _ref.mutable,
    readOnly = _ref.readOnly,
    handleSubmit = _ref.handleSubmit,
    updatePropsData = _ref.updatePropsData,
    parentId = _ref.parentId;
  var undoRef = /*#__PURE__*/_react["default"].createRef();
  //const [item, setItem] = useState(data);

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "component-sign"
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
    className: "CheckButton",
    key: data.id,
    text: data.attributes.text || data.attributes.displayName,
    style: data.style,
    id: "button".concat(data.id),
    name: "button".concat(data.id),
    disabled: readOnly ? true : mutable ? data.disabled : true,
    icon: data.icon,
    hint: "Click to Approve",
    onClick: function onClick(e) {
      var t = _onClick({
        style: {
          backgroundColor: 'rgba(198, 239, 226, 1)'
        },
        icon: 'check',
        undoVisibility: true,
        sign: data,
        clicked: true,
        parentId: parentId,
        e: e
      });
      // setItem(JSON.parse(JSON.stringify(t)));
      if (updatePropsData) updatePropsData();
      if (handleSubmit) handleSubmit();
    }
  }), /*#__PURE__*/_react["default"].createElement(_button["default"], {
    style: {
      marginLeft: 10
    },
    ref: undoRef,
    id: "undo-".concat(data.id),
    icon: "undo",
    stylingMode: "text",
    visible: data.undoVisibility || false,
    hint: "Click to undo",
    disabled: mutable ? data.undoDisabled : true,
    onClick: function onClick(e) {
      var t = _onClick({
        style: {},
        icon: null,
        undoVisibility: false,
        sign: data,
        clicked: false,
        parentId: parentId,
        e: e
      });
      // setItem(JSON.parse(JSON.stringify(t)));
      if (updatePropsData) updatePropsData();
      if (handleSubmit) handleSubmit();
    }
  }));
};
var _default = ComponentSignButton;
exports["default"] = _default;