"use strict";

exports.__esModule = true;
exports.default = void 0;
var _sortBy2 = _interopRequireDefault(require("lodash/fp/sortBy"));
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _cardsGrid = _interopRequireDefault(require("../../organism/cards-grid"));
var _cardsList = _interopRequireDefault(require("../../molecule/dashboard/cards-list"));
var _continueLearning = _interopRequireDefault(require("./continue-learning.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 }; }
const ContinueLearning = (props, context) => {
  const {
    ongoingCourses
  } = props;
  const {
    translate
  } = context;
  const Title = (0, _react.useCallback)(() => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
    className: _continueLearning.default.continueLearningTitle
  }, translate('continue_learning')), /*#__PURE__*/_react.default.createElement("span", {
    className: _continueLearning.default.continueLearningNumber
  }, ongoingCourses.list.length)), [ongoingCourses, translate]);
  if (ongoingCourses.list.length === 0) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement(_cardsList.default, {
    cards: (0, _sortBy2.default)(course => -(0, _getOr2.default)(0, ['progress'], course), ongoingCourses.list),
    title: /*#__PURE__*/_react.default.createElement(Title, null)
    // to override CardList wrapper padding
    ,
    customStyle: {
      padding: '0px'
    }
  });
};
ContinueLearning.contextTypes = {
  skin: _provider.default.childContextTypes.skin,
  translate: _provider.default.childContextTypes.translate
};
ContinueLearning.propTypes = process.env.NODE_ENV !== "production" ? {
  ongoingCourses: _propTypes.default.shape(_cardsGrid.default.propTypes)
} : {};
var _default = exports.default = ContinueLearning;
//# sourceMappingURL=continue-learning.js.map