import _sortBy from "lodash/fp/sortBy";
import _getOr from "lodash/fp/getOr";
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import Provider from '../../atom/provider';
import CardsGrid from '../../organism/cards-grid';
import CardsList from '../../molecule/dashboard/cards-list';
import style from './continue-learning.css';
const ContinueLearning = (props, context) => {
  const {
    ongoingCourses
  } = props;
  const {
    translate
  } = context;
  const Title = useCallback(() => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
    className: style.continueLearningTitle
  }, translate('continue_learning')), /*#__PURE__*/React.createElement("span", {
    className: style.continueLearningNumber
  }, ongoingCourses.list.length)), [ongoingCourses, translate]);
  if (ongoingCourses.list.length === 0) {
    return null;
  }
  return /*#__PURE__*/React.createElement(CardsList, {
    cards: _sortBy(course => -_getOr(0, ['progress'], course), ongoingCourses.list),
    title: /*#__PURE__*/React.createElement(Title, null)
    // to override CardList wrapper padding
    ,
    customStyle: {
      padding: '0px'
    }
  });
};
ContinueLearning.contextTypes = {
  skin: Provider.childContextTypes.skin,
  translate: Provider.childContextTypes.translate
};
ContinueLearning.propTypes = process.env.NODE_ENV !== "production" ? {
  ongoingCourses: PropTypes.shape(CardsGrid.propTypes)
} : {};
export default ContinueLearning;
//# sourceMappingURL=continue-learning.js.map