'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _goodsInfo = require('./goods-info');

var _goodsInfo2 = _interopRequireDefault(_goodsInfo);

var _fdx = require('@whalecloud/fdx');

var _ecomIcon = require('../ecom-icon');

var _ecomIcon2 = _interopRequireDefault(_ecomIcon);

require('./index.less');

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

var Cart = _ecomIcon2['default'].Cart,
    DroppedNotice = _ecomIcon2['default'].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) {
    (0, _inherits3['default'])(GoodsCard, _React$Component);

    function GoodsCard(props) {
        (0, _classCallCheck3['default'])(this, GoodsCard);

        var _this = (0, _possibleConstructorReturn3['default'])(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;
    }

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

exports['default'] = GoodsCard;
module.exports = exports['default'];