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 from 'react';
import { Tag, Popover, Row } from '@whalecloud/fdx';

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

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

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

        _this.zyIcon = require('../imgs/logo-zy.svg');
        _this.msIcon = require('../imgs/icon_ms.svg');
        _this.shipIcon = require('../imgs/icon_ship_free.svg');
        _this.couponIcon = require('../imgs/icon_coupon.svg');
        return _this;
    }

    _createClass(CommodityTags, [{
        key: 'render',
        value: function render() {
            var data = this.props.data;

            var iconType = {
                '自营': this.zyIcon,
                '秒杀': this.msIcon,
                '免邮': this.shipIcon,
                '优惠券': this.couponIcon
            };
            return React.createElement(
                'div',
                { className: 'commodity-tags-wrap' },
                React.createElement(
                    Row,
                    { type: 'flex', align: 'middle' },
                    data && data.map(function (tag, index) {
                        return React.createElement(
                            Popover,
                            { key: tag.id + index, content: tag && tag.description, title: '', trigger: 'hover', placement: 'bottom' },
                            tag.url ? React.createElement('img', { className: 'ml6', src: tag.url, alt: tag.name }) : iconType[tag.name] ? React.createElement('img', { className: 'ml6', src: iconType[tag.name], alt: tag.name }) : React.createElement(
                                Tag,
                                { className: 'commodity-tag', color: tag && tag.color },
                                tag.name
                            )
                        );
                    })
                )
            );
        }
    }]);

    return CommodityTags;
}(React.Component);

export default CommodityTags;