orderiom-api-package 0.2.53 → 0.2.55
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/order.js +3 -3
- package/src/modules/product.js +43 -46
package/package.json
CHANGED
package/src/modules/order.js
CHANGED
|
@@ -61,7 +61,7 @@ const actions = {
|
|
|
61
61
|
if(!getBasketSuccess || getProductsResult.type !== 'success'){
|
|
62
62
|
return {
|
|
63
63
|
type: 'error',
|
|
64
|
-
msg: 'There was an error in fetching basket and products'
|
|
64
|
+
msg: 'There was an error in fetching the basket and products'
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
return {
|
|
@@ -159,15 +159,15 @@ const actions = {
|
|
|
159
159
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
160
160
|
basketId: basket.find((basket) => basket.restaurantId == data.restaurantId).basketId
|
|
161
161
|
} : {}
|
|
162
|
-
const attributeItems = data.attributeItems.length ? { attributeItems: data.attributeItems } : {}
|
|
163
162
|
|
|
164
163
|
if(basketProduct) basketProduct.changingQuantity = true;
|
|
165
164
|
axios.post("api/basket/add", {
|
|
166
165
|
...basketId,
|
|
167
166
|
productId: data.productId,
|
|
168
167
|
quantity: 1,
|
|
169
|
-
|
|
168
|
+
attributeItems: data.attributeItems.length ? data.attributeItems : undefined,
|
|
170
169
|
restaurantId: data.restaurantId,
|
|
170
|
+
extraInfo: data.extraInfo
|
|
171
171
|
}).then(async () => {
|
|
172
172
|
return await dispatch('shoppingCartUpdateCallback', { restaurantId: data.restaurantId });
|
|
173
173
|
}).catch(
|
package/src/modules/product.js
CHANGED
|
@@ -53,6 +53,7 @@ const mutations = {
|
|
|
53
53
|
SetShoppingCart(state, products) {
|
|
54
54
|
state.ShoppingCart = products.map(item => ({
|
|
55
55
|
...item,
|
|
56
|
+
extra_info: item.extra_info ? JSON.parse(item.extra_info) : item.extra_info,
|
|
56
57
|
deleting: false,
|
|
57
58
|
changingQuantity: false,
|
|
58
59
|
}));
|
|
@@ -256,60 +257,56 @@ const actions = {
|
|
|
256
257
|
commonErrorCallback()
|
|
257
258
|
);
|
|
258
259
|
},
|
|
259
|
-
getBasket({ commit, rootState },
|
|
260
|
+
getBasket({ commit, rootState }, customRestaurantId = undefined) {
|
|
260
261
|
const basket = JSON.parse(localStorage.getItem("basket"));
|
|
261
262
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
262
263
|
basketId: basket.find((basket) => basket.restaurantId == restaurantId).basketId
|
|
263
264
|
} : {}
|
|
264
265
|
|
|
265
266
|
commit('startFetchingBasket');
|
|
266
|
-
return axios
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const voucherValue = res.data.data.voucherValue;
|
|
275
|
-
const voucher_code = res.data.data.voucher_code;
|
|
276
|
-
const totalWithDiscount = res.data.data.totalWithDiscount;
|
|
277
|
-
const delivertYype = res.data.data.deliveryType;
|
|
278
|
-
const postalCode = res.data.data.postalCode;
|
|
279
|
-
const tip = res.data.data.tip;
|
|
280
|
-
const shipping_price = res.data.data.shipping_price;
|
|
281
|
-
commit('setBasketInfo', basketInfo)
|
|
282
|
-
commit("SetSubtotalPrice", SubtotalPrice);
|
|
283
|
-
commit("SetTotalPrice", totalPrice);
|
|
284
|
-
commit("SetShoppingCart", ShoppingCart);
|
|
285
|
-
commit("setDeliveryTime", deliveryTime);
|
|
286
|
-
commit('setVoucherCode', voucher_code);
|
|
287
|
-
commit('setVoucherValue', voucherValue);
|
|
288
|
-
commit('setTotalWithDiscount', totalWithDiscount);
|
|
289
|
-
commit('setDelivertType', delivertYype);
|
|
290
|
-
commit('setPostalCode', postalCode);
|
|
291
|
-
commit('setTip', tip);
|
|
292
|
-
commit('setshippingPrice', shipping_price);
|
|
293
|
-
if (id != basketId) {
|
|
294
|
-
const index = basket.indexOf(basket.find((basket) => basket.restaurantId == restaurantId));
|
|
295
|
-
if (index > -1) {
|
|
296
|
-
basket.splice(index, 1);
|
|
297
|
-
}
|
|
298
|
-
basket.push({
|
|
299
|
-
restaurantId: restaurantId,
|
|
300
|
-
basketId: id,
|
|
301
|
-
});
|
|
302
|
-
localStorage.setItem("basket", JSON.stringify(basket));
|
|
267
|
+
return axios.get('api/basket', {
|
|
268
|
+
params: {
|
|
269
|
+
...basketId,
|
|
270
|
+
restaurantId: customRestaurantId || restaurantId
|
|
271
|
+
}
|
|
272
|
+
}).then(res => {
|
|
273
|
+
const basketInfo = res.data.data;
|
|
274
|
+
commit('setBasketInfo', basketInfo);
|
|
303
275
|
|
|
276
|
+
// TODO: why two separate states use same value?
|
|
277
|
+
commit('SetSubtotalPrice', basketInfo.totalPrice);
|
|
278
|
+
commit('SetTotalPrice', basketInfo.totalPrice);
|
|
279
|
+
|
|
280
|
+
commit('SetShoppingCart', basketInfo.products);
|
|
281
|
+
commit('setDeliveryTime', basketInfo.deliveryTime);
|
|
282
|
+
commit('setVoucherCode', basketInfo.voucher_code);
|
|
283
|
+
commit('setVoucherValue', basketInfo.voucherValue);
|
|
284
|
+
commit('setTotalWithDiscount', basketInfo.totalWithDiscount);
|
|
285
|
+
commit('setDelivertType', basketInfo.deliveryType);
|
|
286
|
+
commit('setPostalCode', basketInfo.postalCode);
|
|
287
|
+
commit('setTip', basketInfo.tip);
|
|
288
|
+
commit('setshippingPrice', basketInfo.shipping_price);
|
|
289
|
+
|
|
290
|
+
//TODO: This condition is always true.
|
|
291
|
+
if (basketInfo.id != basketId) {
|
|
292
|
+
const index = basket.indexOf(basket.find((basket) => basket.restaurantId == restaurantId));
|
|
293
|
+
if (index > -1) {
|
|
294
|
+
basket.splice(index, 1);
|
|
304
295
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
296
|
+
basket.push({
|
|
297
|
+
restaurantId: restaurantId,
|
|
298
|
+
basketId: basketInfo.id,
|
|
299
|
+
});
|
|
300
|
+
localStorage.setItem("basket", JSON.stringify(basket));
|
|
301
|
+
}
|
|
302
|
+
commit('basketLoadedOnce');
|
|
303
|
+
return true;
|
|
304
|
+
}).catch(error => {
|
|
305
|
+
console.error(error);
|
|
306
|
+
return false;
|
|
307
|
+
}).finally(() => {
|
|
308
|
+
commit('finishFetchingBasket')
|
|
309
|
+
});
|
|
313
310
|
},
|
|
314
311
|
getAttributeItems({ commit }, data) {
|
|
315
312
|
return axios.get('api/restaurant/category-attributes-items', {
|