"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = index;

var _fdx = require("@whalecloud/fdx");

var _react = _interopRequireDefault(require("react"));

var _ProductItem = _interopRequireDefault(require("../../../../../common/ProductItem"));

var _commonTitle = _interopRequireDefault(require("./common-title"));

require("./index.less");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function index(props) {
  var loading = props.loading,
      data = props.data,
      onClick = props.onClick,
      rightTxt = props.rightTxt,
      title = props.title,
      isWill = props.isWill,
      renderCountDown = props.renderCountDown;
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, data && data.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
    className: "flash-sale-wrap"
  }, /*#__PURE__*/_react["default"].createElement(_commonTitle["default"], {
    title: title,
    isWill: isWill,
    renderCountDown: renderCountDown,
    rightTxt: rightTxt,
    onClick: onClick
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "list"
  }, data.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement(_ProductItem["default"], {
      data: _objectSpread({}, item, {
        salePercent: isWill ? 0 : item.salePercent
      }),
      key: item.id,
      onItemClick: function onItemClick() {
        return onClick("/product/detail/".concat(item.offerId, "?productId=").concat(item.sppProductId));
      }
    });
  }), loading && /*#__PURE__*/_react["default"].createElement("div", {
    className: "loading-wrap"
  }, /*#__PURE__*/_react["default"].createElement(_fdx.Icon, {
    type: "loading",
    style: {
      fontSize: 32,
      color: '#abacb2',
      cursor: 'pointer'
    }
  })))));
}