fixes for inconsistent cart state
This commit is contained in:
@@ -32,7 +32,6 @@ var CartPage = React.createClass({
|
||||
<td>
|
||||
<img style={{maxWidth: '90px', maxHeight: '90px'}} src={firstImage.url} alt="product image"/>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<p> {i.get('brand').name}</p>
|
||||
<p>
|
||||
@@ -42,12 +41,9 @@ var CartPage = React.createClass({
|
||||
<td>{ Globals.FormatCurrency(price) }</td>
|
||||
<td>
|
||||
<input style={{textAlign: 'center'}} className="form-control qty-box" type='text' value={count}></input>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{ Globals.FormatCurrency(count * price) }
|
||||
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<button onClick={self._onTakeItemOut.bind(self, i.get('id'))}>Ukloni iz korpe</button>
|
||||
|
||||
@@ -18,6 +18,7 @@ var states = {}
|
||||
var _itemsInCart = new ItemInCartCollection();
|
||||
var _itemsForDisplay = new ItemCollection();
|
||||
_itemsForDisplay.setFromCart(true);
|
||||
|
||||
var _deliveryDestination = new DeliveryDestination();
|
||||
var _deliveryDestinationErrors = {};
|
||||
var _deliveryCosts = new Place({
|
||||
@@ -26,10 +27,8 @@ var _deliveryCosts = new Place({
|
||||
|
||||
var _cartDataLoadCalled = false;
|
||||
|
||||
|
||||
var loadCart = function() {
|
||||
|
||||
states = {};
|
||||
_itemsInCart.fetch({
|
||||
success: function() {
|
||||
states = {}
|
||||
@@ -37,26 +36,22 @@ var loadCart = function() {
|
||||
var itemInCart = _itemsInCart.models[i];
|
||||
states[itemInCart.get('item_id')] = itemInCart;
|
||||
}
|
||||
CartActions.dataLoaded();
|
||||
_itemsForDisplay.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_itemsForDisplay.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
|
||||
_deliveryDestination.fetch({
|
||||
success: function() {
|
||||
validateDeliveryDestinationForm();
|
||||
fetchPlace();
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
|
||||
//_deliveryDestination.fetch({
|
||||
//success: function() {
|
||||
//validateDeliveryDestinationForm();
|
||||
//fetchPlace();
|
||||
//CartActions.dataLoaded();
|
||||
//}
|
||||
//});
|
||||
_cartDataLoadCalled = true;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -265,7 +260,6 @@ AppDispatcher.register(function(payload) {
|
||||
var text;
|
||||
|
||||
switch (action.actionType) {
|
||||
|
||||
case CartConstants.LOAD_CART_CONTENTS:
|
||||
loadCart();
|
||||
break;
|
||||
|
||||
@@ -34,7 +34,9 @@ var getItemIdFromUrl = function() {
|
||||
var itemIdRegex = /artikal\/(\d+)\//g;
|
||||
var match = itemIdRegex.exec(url);
|
||||
|
||||
return match[1];
|
||||
if (match) {
|
||||
return match[1];
|
||||
}
|
||||
};
|
||||
|
||||
var fetchItemWithDetails = function() {
|
||||
@@ -191,4 +193,4 @@ AppDispatcher.register(function(payload) {
|
||||
|
||||
});
|
||||
|
||||
module.exports = ItemStore;
|
||||
module.exports = ItemStore;
|
||||
|
||||
Reference in New Issue
Block a user