"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _table = _interopRequireDefault(require("../../molecule/table"));
var _pagination = _interopRequireDefault(require("../../molecule/pagination"));
var _inputSearch = _interopRequireDefault(require("../../atom/input-search"));
var _loader = _interopRequireDefault(require("../../atom/loader"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const BrandTable = props => {
  const {
    pagination,
    search,
    rows = [],
    columns = [],
    editable,
    isPending,
    emptyValue,
    onRefresh,
    refreshLabel,
    headerTitle = ''
  } = props;
  const pendingView = /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.loading
  }, /*#__PURE__*/_react.default.createElement(_loader.default, null));
  const tableView = rows.length > 0 ? /*#__PURE__*/_react.default.createElement(_table.default, {
    rows: rows,
    columns: columns,
    editable: editable,
    headerTitle: headerTitle
  }) : /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.empty
  }, emptyValue);
  const paginationView = pagination ? /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_pagination.default, pagination)) : null;
  const searchView = search ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.searchWrapper
  }, /*#__PURE__*/_react.default.createElement(_inputSearch.default, search)) : null;
  const refreshView = onRefresh ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.refresh,
    onClick: onRefresh
  }, "\uD83D\uDD04 ", refreshLabel) : null;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.wrapper
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.headerWrapper
  }, refreshView, searchView, paginationView), /*#__PURE__*/_react.default.createElement("div", null, isPending ? pendingView : tableView), /*#__PURE__*/_react.default.createElement("div", null));
};
BrandTable.propTypes = process.env.NODE_ENV !== "production" ? {
  search: _propTypes.default.shape(_inputSearch.default.propTypes),
  pagination: _propTypes.default.shape(_pagination.default.propTypes),
  emptyValue: _propTypes.default.string.isRequired,
  isPending: _propTypes.default.bool,
  editable: _propTypes.default.bool,
  rows: _table.default.propTypes.rows,
  columns: _table.default.propTypes.columns,
  onRefresh: _propTypes.default.func,
  refreshLabel: _propTypes.default.string,
  headerTitle: _propTypes.default.string
} : {};
var _default = exports.default = BrandTable;
//# sourceMappingURL=index.js.map