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