"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Table = void 0;
var _react = _interopRequireDefault(require("react"));
var _Padder = require("./Padder");
require("../styles/main.css");
// import '../styles/table.css'

var Table = function Table(_ref) {
  var columns = _ref.columns,
    data = _ref.data,
    empty = _ref.empty,
    width = _ref.width,
    height = _ref.height;
  var tableWidth = width ? width : '100%';
  var tableHeight = height ? height : 300;
  return /*#__PURE__*/_react.default.createElement("div", {
    style: {
      minWidth: '100%'
    }
  }, /*#__PURE__*/_react.default.createElement("div", {
    style: {
      borderRadius: 25,
      border: '1px solid #DCDCDC',
      backgroundColor: '#fff'
    }
  }, /*#__PURE__*/_react.default.createElement(_Padder.Padder, {
    top: "1em",
    bottom: "1em",
    left: "2em",
    right: "2em"
  }, /*#__PURE__*/_react.default.createElement("div", {
    style: {
      display: 'flex',
      justifyContent: 'space-between',
      alignItems: 'center'
    }
  }, columns.map(function (column) {
    if (column.hasOwnProperty('index')) {
      if (column.index === true) {
        return /*#__PURE__*/_react.default.createElement("label", {
          style: {
            margin: 0
          }
        }, column.header);
      }
    } else {
      return /*#__PURE__*/_react.default.createElement("p", {
        style: {
          margin: 0
        }
      }, column.header);
    }
  })))), /*#__PURE__*/_react.default.createElement("div", {
    style: {
      overflowY: 'scroll',
      maxHeight: tableHeight
    }
  }, /*#__PURE__*/_react.default.createElement(_Padder.Padder, {
    top: "1em"
  }, data.length > 0 ? data.map(function (row) {
    return /*#__PURE__*/_react.default.createElement("div", {
      style: {
        borderRadius: 35,
        border: '1px solid #DCDCDC',
        marginBottom: "1em",
        backgroundColor: '#fff'
      }
    }, /*#__PURE__*/_react.default.createElement(_Padder.Padder, {
      top: "1.5em",
      bottom: "1.5em",
      left: "2em",
      right: "2em"
    }, /*#__PURE__*/_react.default.createElement("div", {
      style: {
        display: 'flex',
        justifyContent: 'space-between',
        alignItems: 'center'
      }
    }, columns.map(function (column) {
      if (column.hasOwnProperty('index')) {
        if (column.index === true) {
          return /*#__PURE__*/_react.default.createElement("label", {
            style: {
              margin: 0
            }
          }, row[column.accessor]);
        }
      } else {
        if (row[column.accessor].hasOwnProperty('color')) {
          return /*#__PURE__*/_react.default.createElement("p", {
            style: {
              margin: 0,
              color: row[column.accessor].color
            }
          }, row[column.accessor].text);
        } else {
          return /*#__PURE__*/_react.default.createElement("p", {
            style: {
              margin: 0
            }
          }, row[column.accessor]);
        }
      }
    }))));
  }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Padder.Padder, {
    top: "1em"
  }, /*#__PURE__*/_react.default.createElement("p", {
    style: {
      textAlign: "center"
    }
  }, empty || 'No data here yet'))))));
};
exports.Table = Table;