"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _col = require("antd/es/col");

var _col2 = _interopRequireDefault(_col);

var _row = require("antd/es/row");

var _row2 = _interopRequireDefault(_row);

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

require("antd/es/col/style/css");

require("antd/es/row/style/css");

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _reactIntlUniversal = require("react-intl-universal");

var _reactIntlUniversal2 = _interopRequireDefault(_reactIntlUniversal);

require("./AvatarHoverCard.less");

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var AvatarHoverCard = function (_Component) {
  _inherits(AvatarHoverCard, _Component);

  function AvatarHoverCard(props) {
    _classCallCheck(this, AvatarHoverCard);

    var _this = _possibleConstructorReturn(this, (AvatarHoverCard.__proto__ || Object.getPrototypeOf(AvatarHoverCard)).call(this, props));

    _this.state = {
      showModal: false
    };
    return _this;
  }

  _createClass(AvatarHoverCard, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var isLogin = this.props.currentUser.user_id > 0;
      this.props.getUserInfo({
        id: this.props.user_id,
        noCheckFollowed: !isLogin
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var _props = this.props,
          image = _props.image,
          user_id = _props.user_id,
          currentUser = _props.currentUser,
          userAvaHoverData = _props.userAvaHoverData;

      var followed = userAvaHoverData[user_id] && userAvaHoverData[user_id].isFollowed;

      return _react2.default.createElement(
        "div",
        { className: "AvatarHoverCard", onClick: function onClick(e) {
            return e.stopPropagation();
          } },
        _react2.default.createElement(
          "div",
          { onClick: function onClick() {
              return _this2.props.userAvaClick(user_id);
            } },
          _react2.default.createElement(
            _row2.default,
            { type: "flex", className: "rowUser" },
            _react2.default.createElement("div", {
              className: "avatar",
              style: {
                backgroundImage: "url(" + image + ")"
              }
            }),
            _react2.default.createElement(
              "div",
              { className: "nickname" },
              userAvaHoverData[user_id] && userAvaHoverData[user_id].nickname
            )
          )
        ),
        _react2.default.createElement("div", { className: "divider" }),
        _react2.default.createElement(
          _row2.default,
          { type: "flex", className: "rowNum" },
          _react2.default.createElement(
            _col2.default,
            { className: "colFans" },
            _react2.default.createElement(
              "div",
              { className: "count" },
              userAvaHoverData[user_id] && userAvaHoverData[user_id].fans
            ),
            _react2.default.createElement(
              "div",
              { className: "text" },
              _reactIntlUniversal2.default.get("bilingually.fan", {
                ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].fans > 1 ? "s" : ""
              })
            )
          ),
          _react2.default.createElement(_col2.default, { className: "hdivider" }),
          _react2.default.createElement(
            _col2.default,
            { className: "colFollow" },
            _react2.default.createElement(
              "div",
              { className: "count" },
              userAvaHoverData[user_id] && userAvaHoverData[user_id].followers
            ),
            _react2.default.createElement(
              "div",
              { className: "text" },
              _reactIntlUniversal2.default.get("bilingually.follow", {
                ext: userAvaHoverData[user_id] && userAvaHoverData[user_id].followers > 1 ? "s" : ""
              })
            )
          )
        ),
        currentUser.user_id > 0 && currentUser.user_id !== user_id && _react2.default.createElement(
          _row2.default,
          { type: "flex", className: "rowBtn" },
          followed ? _react2.default.createElement(
            "div",
            {
              className: "unFollowBtn",
              onClick: function onClick(e) {
                e.stopPropagation();
                _this2.props.unFocus({
                  id: user_id
                }).then(function () {
                  _this2.props.getUserInfo({
                    id: user_id
                  });
                });
              }
            },
            _reactIntlUniversal2.default.get("bilingually.cancel_follow")
          ) : _react2.default.createElement(
            "div",
            {
              className: "followBtn",
              onClick: function onClick(e) {
                e.stopPropagation();
                _this2.props.focus({ id: user_id }).then(function () {
                  _this2.props.getUserInfo({
                    id: user_id
                  });
                });
              }
            },
            _reactIntlUniversal2.default.get("bilingually.follow", { ext: "" })
          )
        )
      );
    }
  }]);

  return AvatarHoverCard;
}(_react.Component);

exports.default = AvatarHoverCard;
//# sourceMappingURL=AvatarHoverCard.js.map