orderiom-api-package 0.2.55 → 0.2.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/modules/product.js +18 -16
package/package.json
CHANGED
package/src/modules/product.js
CHANGED
|
@@ -257,17 +257,20 @@ const actions = {
|
|
|
257
257
|
commonErrorCallback()
|
|
258
258
|
);
|
|
259
259
|
},
|
|
260
|
-
getBasket({ commit, rootState }
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
basketId
|
|
264
|
-
}
|
|
260
|
+
getBasket({ commit, rootState }) {
|
|
261
|
+
let basketId = undefined;
|
|
262
|
+
try{
|
|
263
|
+
basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken);
|
|
264
|
+
} catch(e) {
|
|
265
|
+
console.error(e);
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
265
268
|
|
|
266
269
|
commit('startFetchingBasket');
|
|
267
270
|
return axios.get('api/basket', {
|
|
268
271
|
params: {
|
|
269
|
-
|
|
270
|
-
restaurantId
|
|
272
|
+
basketId,
|
|
273
|
+
restaurantId
|
|
271
274
|
}
|
|
272
275
|
}).then(res => {
|
|
273
276
|
const basketInfo = res.data.data;
|
|
@@ -287,18 +290,17 @@ const actions = {
|
|
|
287
290
|
commit('setTip', basketInfo.tip);
|
|
288
291
|
commit('setshippingPrice', basketInfo.shipping_price);
|
|
289
292
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
basket.push({
|
|
297
|
-
restaurantId: restaurantId,
|
|
293
|
+
if (parseInt(basketInfo.id) !== parseInt(basketId)) {
|
|
294
|
+
const baskets = JSON.parse(localStorage.getItem('basket'));
|
|
295
|
+
const basketIndex = baskets.findIndex(basket => parseInt(basket.restaurantId) === restaurantId);
|
|
296
|
+
if (basketIndex > -1) baskets.splice(basketIndex, 1);
|
|
297
|
+
baskets.push({
|
|
298
|
+
restaurantId,
|
|
298
299
|
basketId: basketInfo.id,
|
|
299
300
|
});
|
|
300
|
-
localStorage.setItem(
|
|
301
|
+
localStorage.setItem('basket', JSON.stringify(baskets));
|
|
301
302
|
}
|
|
303
|
+
|
|
302
304
|
commit('basketLoadedOnce');
|
|
303
305
|
return true;
|
|
304
306
|
}).catch(error => {
|