import _map from "lodash/fp/map";
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); }
import React, { useState, useCallback, useMemo } from 'react';
import PropTypes from 'prop-types';
import MoocHeader from '../../organism/mooc-header';
import Cta from '../../atom/cta';
import Loader from '../../atom/loader';
import CardsList from '../../molecule/dashboard/cards-list';
import Provider from '../../atom/provider';
import style from './style.css';
const TeamsDashboard = ({
  logo,
  platformLinks,
  sections,
  isLoading
}) => {
  const [isShadowed, setShadowed] = useState(false);
  const onMenuOpen = useCallback(() => setShadowed(true), []);
  const onMenuClose = useCallback(() => setShadowed(false), []);
  const buildSection = useCallback((section, index) => {
    return /*#__PURE__*/React.createElement(CardsList, _extends({}, section, {
      key: section.title + index
    }));
  }, []);
  const sectionsList = useMemo(() => _map.convert({
    cap: false
  })(buildSection, sections), [buildSection, sections]);
  return isLoading ? /*#__PURE__*/React.createElement("div", {
    className: style.loader,
    "data-name": "teams-dashboard-loader"
  }, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement("div", {
    "data-name": "teams-dashboard",
    className: isShadowed ? style.shadowedTeamsDashboard : style.teamsDashboard
  }, /*#__PURE__*/React.createElement(MoocHeader, {
    "data-name": "teams-dashboard-header",
    logo: logo,
    links: platformLinks,
    onMenuOpen: onMenuOpen,
    onMenuClose: onMenuClose
  }), /*#__PURE__*/React.createElement("div", {
    "data-name": "sections-wrapper",
    className: isShadowed ? style.sectionsWrapper : null
  }, sectionsList));
};
TeamsDashboard.propTypes = process.env.NODE_ENV !== "production" ? {
  logo: MoocHeader.propTypes.logo,
  platformLinks: PropTypes.arrayOf(PropTypes.shape(Cta.propTypes)),
  sections: PropTypes.arrayOf(PropTypes.shape(CardsList.propTypes)),
  isLoading: PropTypes.bool
} : {};
TeamsDashboard.contextTypes = {
  translate: Provider.childContextTypes.translate,
  skin: Provider.childContextTypes.skin
};
export default TeamsDashboard;
//# sourceMappingURL=index.js.map