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 GoodsTags = function (_React$Component) {
    _inherits(GoodsTags, _React$Component);

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

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

        _this.zyIcon = require('../imgs/store.svg');
        _this.msIcon = require('../imgs/second.svg');
        _this.shipIcon = require('../imgs/free.svg');
        _this.couponIcon = require('../imgs/coupon.svg');
        return _this;
    }

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

            var iconType = {
                '自营': this.zyIcon,
                '免邮': this.shipIcon,
                '秒杀': this.msIcon,
                '优惠券': this.couponIcon
            };
            return React.createElement(
                'div',
                { className: 'goods-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: 'goods-tag', color: tag && tag.color },
                                tag.name
                            )
                        );
                    })
                )
            );
        }
    }]);

    return GoodsTags;
}(React.Component);

export default GoodsTags;