"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

exports.__esModule = true;
exports.CompanyDetails = void 0;

var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _lib = require("@sentecacommerce-theme/lib");

var _Components = require("./Components");

var _NavigationSkeleton = require("../NavigationSkeleton");

var _Common = require("../../../Common");

var _templateObject, _templateObject2;

var CompanyDetails = function CompanyDetails() {
  var _companiesApi$useGet = _lib.companiesApi.useGet(),
      data = _companiesApi$useGet.data,
      isFetching = _companiesApi$useGet.isFetching;

  var _useState = (0, _react.useState)(false),
      showModal = _useState[0],
      setShowModal = _useState[1];

  var labels = (0, _lib.useLocalLabels)();
  var isEmpty = (data == null ? void 0 : data.length) === 0;
  return /*#__PURE__*/_react["default"].createElement(_NavigationSkeleton.NavigationSkeleton, {
    url: "company-details",
    header: "Company Details"
  }, isFetching ? /*#__PURE__*/_react["default"].createElement(_Common.Spinner, null) : /*#__PURE__*/_react["default"].createElement(Container, null, showModal && /*#__PURE__*/_react["default"].createElement(_Components.AddCompanyModal, {
    handleClose: function handleClose() {
      return setShowModal(false);
    }
  }), isEmpty && /*#__PURE__*/_react["default"].createElement("p", null, labels.noCompanyDetails), data == null ? void 0 : data.map(function (element, index) {
    return /*#__PURE__*/_react["default"].createElement(_Common.CompanyPreview, {
      data: element,
      key: "Company__" + (element._id || index)
    });
  }), /*#__PURE__*/_react["default"].createElement(ActionsContainer, null, /*#__PURE__*/_react["default"].createElement(_Common.Button, {
    onClick: function onClick() {
      return setShowModal(true);
    },
    variant: "primary"
  }, labels.addNew))));
};

exports.CompanyDetails = CompanyDetails;

var Container = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  display: flex;\n  flex-direction: column;\n"])));

var ActionsContainer = _styledComponents["default"].div.attrs({
  className: 'pt-4'
})(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteralLoose2["default"])(["\n  margin-left: auto;\n\n  @media (max-width: 768px) {\n    button {\n      width: 100%;\n      display: block;\n      padding: 1.1rem 2rem 1rem;\n      font-size: 16px;\n    }\n    margin-left: 0;\n  }\n"])));
//# sourceMappingURL=index.js.map