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 GoodsInfo from './goods-info';
import { Icon } from '@whalecloud/fdx';
import EcomIcon from '../ecom-icon';
import './index.less';
var Cart = EcomIcon.Cart,
    DroppedNotice = EcomIcon.DroppedNotice;

var CLICK_TYPE;
(function (CLICK_TYPE) {
    CLICK_TYPE["STORE"] = "STORE";
    CLICK_TYPE["DETAIL"] = "DETAIL";
    CLICK_TYPE["CART"] = "CART";
    CLICK_TYPE["NOTICE"] = "NOTICE";
    CLICK_TYPE["TOP"] = "TOP";
    CLICK_TYPE["SIMILAR"] = "SIMILAR";
    CLICK_TYPE["UNFOLLOW"] = "UNFOLLOW";
    CLICK_TYPE["SELECT"] = "SELECT";
})(CLICK_TYPE || (CLICK_TYPE = {}));

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

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

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

        _this.unFollowIcon = require('./imgs/unfollow.svg');
        _this.handleUnFollow = function (data) {
            _this.props.onClick(CLICK_TYPE.UNFOLLOW, data);
            _this.setState({ showConfirmModel: false });
        };
        _this.handleSelectSelf = function () {
            _this.props.onClick(CLICK_TYPE.SELECT, _this.props.data, _this.props.data.selected);
        };
        _this.state = {
            showConfirmModel: false
        };
        return _this;
    }

    _createClass(GoodsCard, [{
        key: 'render',
        value: function render() {
            var _this2 = this;

            var _props = this.props,
                data = _props.data,
                _onClick = _props.onClick;
            var showConfirmModel = this.state.showConfirmModel;

            return React.createElement(
                'div',
                { className: 'goods-card-wrap ' + (showConfirmModel ? 'unfollowing' : '') + ' ' + (data.operating ? 'operating' : '') + ' ' + (data.selected ? 'selected' : '') },
                React.createElement(
                    'div',
                    { className: 'select-wrap', onClick: function onClick() {
                            return _this2.handleSelectSelf();
                        } },
                    React.createElement(
                        'span',
                        { className: 'icon' },
                        React.createElement(Icon, { type: 'check', style: { fontSize: '20px' } })
                    )
                ),
                React.createElement(
                    'div',
                    { className: 'unfollow-wrap' },
                    React.createElement('img', { src: this.unFollowIcon }),
                    React.createElement(
                        'p',
                        null,
                        'Are you sure to delete',
                        React.createElement('br', null),
                        'this item?'
                    ),
                    React.createElement(
                        'button',
                        { type: 'button', className: 'btn-confirm', onClick: function onClick() {
                                return _this2.handleUnFollow(data);
                            } },
                        'Yes'
                    ),
                    React.createElement(
                        'button',
                        { type: 'button', className: 'btn-cancel', onClick: function onClick() {
                                return _this2.setState({ showConfirmModel: false });
                            } },
                        'No'
                    )
                ),
                React.createElement('img', { className: 'product-img', src: data.imgUrl, alt: '', onClick: function onClick() {
                        return _onClick && _onClick(CLICK_TYPE.DETAIL, data);
                    } }),
                React.createElement(
                    'ul',
                    { className: 'ope-wrap' },
                    React.createElement(
                        'li',
                        { onClick: function onClick() {
                                return _onClick && _onClick(CLICK_TYPE.TOP, data);
                            } },
                        React.createElement('span', { className: data.topping ? 'icon-not-top' : 'icon-pin-top' }),
                        data.topping ? 'Unpin to Top' : 'Pin to Top'
                    ),
                    React.createElement(
                        'li',
                        { onClick: function onClick() {
                                return _onClick && _onClick(CLICK_TYPE.SIMILAR, data);
                            } },
                        React.createElement('span', { className: 'icon-find-similar' }),
                        'Find Similar'
                    ),
                    React.createElement(
                        'li',
                        { onClick: function onClick() {
                                return _this2.setState({ showConfirmModel: true });
                            } },
                        React.createElement('span', { className: 'icon-unfollow' }),
                        'Unfollow'
                    )
                ),
                React.createElement(GoodsInfo, { data: data, onStoreClick: function onStoreClick() {
                        return _onClick && _onClick(CLICK_TYPE.STORE, data);
                    }, onDetailClick: function onDetailClick() {
                        return _onClick && _onClick(CLICK_TYPE.DETAIL, data);
                    } }),
                React.createElement(
                    'div',
                    { className: 'btns' },
                    React.createElement(
                        'button',
                        { type: 'button', onClick: function onClick() {
                                return _onClick && _onClick(CLICK_TYPE.CART, data);
                            }, className: 'btn-cart' },
                        React.createElement(Cart, null),
                        'Add to Cart'
                    ),
                    React.createElement(
                        'button',
                        { type: 'button', onClick: function onClick() {
                                return _onClick && _onClick(CLICK_TYPE.NOTICE, data);
                            }, className: 'btn-notice' },
                        React.createElement(DroppedNotice, null),
                        'Dropped Notice'
                    )
                )
            );
        }
    }]);

    return GoodsCard;
}(React.Component);

export default GoodsCard;