'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = RelatedRecordButtonBar;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _CreateButton = require('./CreateButton');

var _CreateButton2 = _interopRequireDefault(_CreateButton);

var _RelateButton = require('./RelateButton');

var _RelateButton2 = _interopRequireDefault(_RelateButton);

var _ButtonBar = require('../../../styles/cspace-ui/ButtonBar.css');

var _ButtonBar2 = _interopRequireDefault(_ButtonBar);

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

const propTypes = {
  isCreatable: _propTypes2.default.bool,
  isRelatable: _propTypes2.default.bool,
  onCreateButtonClick: _propTypes2.default.func,
  onRelateButtonClick: _propTypes2.default.func
};

const defaultProps = {
  isRelatable: true
};

function RelatedRecordButtonBar(props) {
  const isCreatable = props.isCreatable,
        isRelatable = props.isRelatable,
        onCreateButtonClick = props.onCreateButtonClick,
        onRelateButtonClick = props.onRelateButtonClick;


  if (!isRelatable) {
    return null;
  }

  const createButton = isCreatable ? _react2.default.createElement(_CreateButton2.default, { onClick: onCreateButtonClick }) : undefined;

  return _react2.default.createElement(
    'div',
    { className: _ButtonBar2.default.common },
    createButton,
    _react2.default.createElement(_RelateButton2.default, {
      onClick: onRelateButtonClick
    })
  );
}

RelatedRecordButtonBar.propTypes = propTypes;
RelatedRecordButtonBar.defaultProps = defaultProps;