"use strict";

exports.__esModule = true;
exports.default = void 0;
var _map2 = _interopRequireDefault(require("lodash/fp/map"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _cardWithButton = _interopRequireDefault(require("../../molecule/card-with-button"));
var _avatar = _interopRequireDefault(require("../../atom/avatar"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const Battles = (props, context) => {
  const {
    translate
  } = context;
  const {
    battles,
    trads
  } = props;
  return /*#__PURE__*/_react.default.createElement("ul", {
    className: _style.default.cards
  }, (0, _map2.default)(battle => {
    const challengeLabel = translate('is challenging you', {
      username: `<strong>${battle.username}</strong>`,
      courseName: `<p><strong>${battle.courseName}</strong></p>`
    });
    const battleCardProps = {
      primaryButtonLabel: trads.battleCTA,
      lightButtonLabel: trads.reviewCTA,
      tagLabel: battle.tagLabel,
      onLightButtonClick: battle.onLightButtonClick,
      onPrimaryButtonClick: battle.onPrimaryButtonClick,
      backgroundImg: battle.backgroundImg
    };
    return /*#__PURE__*/_react.default.createElement("li", {
      key: battle.id,
      className: _style.default.cardsItem
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.card
    }, /*#__PURE__*/_react.default.createElement(_cardWithButton.default, battleCardProps, /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.injection
    }, /*#__PURE__*/_react.default.createElement(_avatar.default, {
      url: battle.urlAvatar
    })), /*#__PURE__*/_react.default.createElement("div", {
      className: (0, _classnames.default)(_style.default.wrapper, _style.default.innerHTML)
      // eslint-disable-next-line react/no-danger
      ,
      dangerouslySetInnerHTML: {
        __html: challengeLabel
      }
    }))));
  }, battles));
};
Battles.contextTypes = {
  translate: _provider.default.childContextTypes.translate
};
Battles.propTypes = process.env.NODE_ENV !== "production" ? {
  battles: _propTypes.default.arrayOf(_propTypes.default.shape({
    username: _propTypes.default.string,
    courseName: _propTypes.default.string,
    tagLabel: _cardWithButton.default.propTypes.tagLabel,
    onLightButtonClick: _cardWithButton.default.propTypes.onLightButtonClick,
    onPrimaryButtonClick: _cardWithButton.default.propTypes.onPrimaryButtonClick,
    backgroundImg: _cardWithButton.default.propTypes.backgroundImg
  })).isRequired,
  trads: _propTypes.default.shape({
    battleCTA: _propTypes.default.string.isRequired,
    reviewCTA: _propTypes.default.string.isRequired
  }).isRequired
} : {};
var _default = exports.default = Battles;
//# sourceMappingURL=index.js.map