stuff not ready to be pushed to master
This commit is contained in:
@@ -8,10 +8,12 @@ var ItemInCartCollection = require('../models/itemInCartCollection');
|
||||
var ItemCollection = require('../models/itemCollection');
|
||||
var DeliveryDestination = require('../models/deliveryDestination');
|
||||
var OrderConfirmation = require('../models/orderConfirmation');
|
||||
|
||||
var globals = require('../globals');
|
||||
var Superagent = require('superagent');
|
||||
var _ = require('underscore');
|
||||
|
||||
var states = {}
|
||||
var initialized = false;
|
||||
|
||||
var _itemsInCart = new ItemInCartCollection();
|
||||
var _itemsForDisplay = new ItemCollection();
|
||||
@@ -19,30 +21,53 @@ _itemsForDisplay.setFromCart(true);
|
||||
var _deliveryDestination = new DeliveryDestination();
|
||||
|
||||
|
||||
var loadCart = function() {
|
||||
_itemsInCart.fetch({
|
||||
success: function() {
|
||||
states = {}
|
||||
for (var i = 0; i < _itemsInCart.models.length; i++) {
|
||||
var itemInCart = _itemsInCart.models[i];
|
||||
states[itemInCart.get('item_id')] = itemInCart;
|
||||
}
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
|
||||
_itemsForDisplay.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
})
|
||||
if (!_deliveryDestination.get('id')) {
|
||||
_deliveryDestination.fetch({
|
||||
var loadCart = function() {
|
||||
var get = function() {
|
||||
_itemsInCart.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
states = {}
|
||||
for (var i = 0; i < _itemsInCart.models.length; i++) {
|
||||
var itemInCart = _itemsInCart.models[i];
|
||||
states[itemInCart.get('item_id')] = itemInCart;
|
||||
}
|
||||
//CartActions.dataLoaded();
|
||||
|
||||
_itemsForDisplay.fetch({
|
||||
success: function() {
|
||||
//CartActions.dataLoaded();
|
||||
if (!_deliveryDestination.get('id')) {
|
||||
_deliveryDestination.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
get();
|
||||
//if(initialized) {
|
||||
//get();
|
||||
//} else {
|
||||
//Superagent
|
||||
//.get(globals.ApiUrl + '/cart/init')
|
||||
//.withCredentials()
|
||||
//.end(function(response) {
|
||||
//if(response.ok) {
|
||||
//initialized = true;
|
||||
//get();
|
||||
//}
|
||||
//});
|
||||
//}
|
||||
};
|
||||
|
||||
|
||||
@@ -201,4 +226,4 @@ AppDispatcher.register(function(payload) {
|
||||
|
||||
});
|
||||
|
||||
module.exports = CartStore;
|
||||
module.exports = CartStore;
|
||||
|
||||
Reference in New Issue
Block a user