var React = require('react');
var ReactPropTypes = React.PropTypes;
var CartStore = require('../stores/CartStore');
var CartActions = require('../actions/CartActions');

var Quantity = React.createClass({

	propTypes: {
		productInCart: ReactPropTypes.object.isRequired,
	},
    getInitialState: function () {
		return {
			productInCart: this.props.productInCart
		};
	},
    componentWillMount() {
       CartStore.addOnProductWasAddedToCartListner(this.onProductWasAddedToCartListner);
    },
    componentWillUnmount(){
       CartStore.removeOnProductWasAddedToCartListner(this.onProductWasAddedToCartListner);
    },
    onProductWasAddedToCartListner: function (product) {
      this.setState({productInCart:product});  
    },
    decrease: function () {
		CartActions.decrease(this.state.productInCart.id);
	},
    increase: function () {
		CartActions.increase(this.state.productInCart.id);
	},
    render: function()
    {
        <div>
            <button onClick={this.decrease}>-</button>
            <label>({this.staate.productInCart.quantity})</label>
            <button onClick={this.increase}>-</button>
        </div>
    }
});

module.exports = Quantity;
Rerun