cart state for item in details page finnaly shows (arrggh worst kind of bugs)
This commit is contained in:
@@ -11,31 +11,36 @@ var countStyle = {
|
||||
var AddToCart = React.createClass({
|
||||
|
||||
render: function() {
|
||||
|
||||
return (
|
||||
<div className="row-fluid add-to-cart">
|
||||
<div className="col-xs-offset-1 col-xs-1"><button className="btn btn-success" onClick={this._onIncreaseClick}>+</button></div>
|
||||
<div className="col-xs-2"><button className="btn" style={countStyle} > { this.state.count } </button></div>
|
||||
<div className="col-xs-2"><button className="btn" style={countStyle} > { this.state.item.get('count') } </button></div>
|
||||
<div className="col-xs-1"><button className="btn btn-success" onClick={this._onDecreaseClick}>-</button></div>
|
||||
<div className="col-xs-7"><button className="btn btn-warning">U korpu</button></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
// Add change listeners to stores
|
||||
componentDidMount: function() {
|
||||
CartActions.load();
|
||||
CartStore.addChangeListener(this._onChange);
|
||||
|
||||
CartActions.load();
|
||||
},
|
||||
|
||||
|
||||
getInitialState: function() {
|
||||
return CartStore.getStateFor(this.props.itemId)
|
||||
|
||||
var itemInCart = CartStore.getStateFor(this.props.itemId);
|
||||
return { item: itemInCart }
|
||||
},
|
||||
|
||||
|
||||
_onChange: function () {
|
||||
if (this.isMounted()) {
|
||||
this.setState(CartStore.getStateFor(this.props.itemId));
|
||||
var item = CartStore.getStateFor(this.props.itemId);
|
||||
this.setState({ item: item });
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ var ItemWithDetailsPage = React.createClass({
|
||||
onClickLeft={this.onClickLeft}
|
||||
onClickRight={this.onClickRight}
|
||||
onSelectImage={this.onSelectImage} />
|
||||
<AddToCart itemId={this.state.item.id} />
|
||||
<AddToCart itemId={this.state.item.get('id')} />
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user