"use strict";

exports.__esModule = true;
exports.default = void 0;
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _moocHeader = _interopRequireDefault(require("../../organism/mooc-header"));
var _cta = _interopRequireDefault(require("../../atom/cta"));
var _loader = _interopRequireDefault(require("../../atom/loader"));
var _cardsList = _interopRequireDefault(require("../../molecule/dashboard/cards-list"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _style = _interopRequireDefault(require("./style.css"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const TeamsDashboard = ({
  logo,
  platformLinks,
  sections,
  isLoading
}) => {
  const [isShadowed, setShadowed] = (0, _react.useState)(false);
  const onMenuOpen = (0, _react.useCallback)(() => setShadowed(true), []);
  const onMenuClose = (0, _react.useCallback)(() => setShadowed(false), []);
  const buildSection = (0, _react.useCallback)((section, index) => {
    return /*#__PURE__*/_react.default.createElement(_cardsList.default, _extends({}, section, {
      key: section.title + index
    }));
  }, []);
  const sectionsList = (0, _react.useMemo)(() => _map2.default.convert({
    cap: false
  })(buildSection, sections), [buildSection, sections]);
  return isLoading ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.loader,
    "data-name": "teams-dashboard-loader"
  }, /*#__PURE__*/_react.default.createElement(_loader.default, null)) : /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "teams-dashboard",
    className: isShadowed ? _style.default.shadowedTeamsDashboard : _style.default.teamsDashboard
  }, /*#__PURE__*/_react.default.createElement(_moocHeader.default, {
    "data-name": "teams-dashboard-header",
    logo: logo,
    links: platformLinks,
    onMenuOpen: onMenuOpen,
    onMenuClose: onMenuClose
  }), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "sections-wrapper",
    className: isShadowed ? _style.default.sectionsWrapper : null
  }, sectionsList));
};
TeamsDashboard.propTypes = process.env.NODE_ENV !== "production" ? {
  logo: _moocHeader.default.propTypes.logo,
  platformLinks: _propTypes.default.arrayOf(_propTypes.default.shape(_cta.default.propTypes)),
  sections: _propTypes.default.arrayOf(_propTypes.default.shape(_cardsList.default.propTypes)),
  isLoading: _propTypes.default.bool
} : {};
TeamsDashboard.contextTypes = {
  translate: _provider.default.childContextTypes.translate,
  skin: _provider.default.childContextTypes.skin
};
var _default = exports.default = TeamsDashboard;
//# sourceMappingURL=index.js.map