import _classCallCheck from "babel-runtime/helpers/classCallCheck";
import _createClass from "babel-runtime/helpers/createClass";
import _possibleConstructorReturn from "babel-runtime/helpers/possibleConstructorReturn";
import _inherits from "babel-runtime/helpers/inherits";
import React, { Fragment } from "react";
import "./index.less";

var DealDayItem = function (_React$Component) {
  _inherits(DealDayItem, _React$Component);

  function DealDayItem() {
    _classCallCheck(this, DealDayItem);

    var _this = _possibleConstructorReturn(this, (DealDayItem.__proto__ || Object.getPrototypeOf(DealDayItem)).apply(this, arguments));

    _this.currencyFormat = function (value, prefixVal) {
      var precision = 2;
      var f = parseFloat(value / 100);
      if (Number.isNaN(f)) {
        f = 0.0;
      }
      var num = f.toFixed(precision).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      return prefixVal ? prefixVal + " " + num : "" + num;
    };
    return _this;
  }

  _createClass(DealDayItem, [{
    key: "render",
    value: function render() {
      var _props$productItem = this.props.productItem,
          imgUrl = _props$productItem.imgUrl,
          productName = _props$productItem.productName,
          specialPriceStr = _props$productItem.specialPriceStr,
          specialPrice = _props$productItem.specialPrice,
          currencySymbol = _props$productItem.currencySymbol;

      return React.createElement(
        Fragment,
        null,
        React.createElement(
          "div",
          { className: "ecom-item-vertical-img ecom-column-flex ant-row-flex-middle ant-row-flex-center", style: { width: "238px", height: "300px" } },
          React.createElement("img", { src: imgUrl, alt: "" }),
          React.createElement(
            "h3",
            { className: "tilte" },
            productName.length > 16 ? productName.substr(0, 16) + "..." : productName
          ),
          React.createElement(
            "div",
            { className: "offerItemPriceBox" },
            React.createElement(
              "div",
              { className: "leftItem" },
              this.currencyFormat(specialPriceStr, currencySymbol)
            ),
            React.createElement(
              "div",
              { className: "rightItem" },
              React.createElement(
                "a",
                { href: "#" },
                this.currencyFormat(specialPrice, currencySymbol)
              )
            )
          )
        )
      );
    }
  }]);

  return DealDayItem;
}(React.Component);

export default DealDayItem;