orderiom-api-package 0.3.8 → 0.3.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orderiom-api-package",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/common.js CHANGED
@@ -38,23 +38,23 @@ export function calculateBasketIdParameter(isLogin, restaurantId) {
38
38
  return foundBasket.basketId;
39
39
  }
40
40
 
41
- export function updateBasket({commit, basketId, res, isOutsideProduct, restaurantId}){
41
+ export function updateBasket({commit, basketId, res, restaurantId}){
42
42
  const basketInfo = res.data.data;
43
- commit(`${isOutsideProduct ? 'product/' : ''}setBasketInfo`, basketInfo);
43
+ commit(`product/setBasketInfo`, basketInfo, { root: true });
44
44
 
45
45
  // TODO: why two separate states use same value?
46
- commit(`${isOutsideProduct ? 'product/' : ''}SetSubtotalPrice`, basketInfo.totalPrice);
47
- commit(`${isOutsideProduct ? 'product/' : ''}SetTotalPrice`, basketInfo.totalPrice);
46
+ commit(`product/SetSubtotalPrice`, basketInfo.totalPrice, { root: true });
47
+ commit(`product/SetTotalPrice`, basketInfo.totalPrice, { root: true });
48
48
 
49
- commit(`${isOutsideProduct ? 'product/' : ''}SetShoppingCart`, basketInfo.products);
50
- commit(`${isOutsideProduct ? 'product/' : ''}setDeliveryTime`, basketInfo.deliveryTime);
51
- commit(`${isOutsideProduct ? 'product/' : ''}setVoucherCode`, basketInfo.voucher_code);
52
- commit(`${isOutsideProduct ? 'product/' : ''}setVoucherValue`, basketInfo.voucherValue);
53
- commit(`${isOutsideProduct ? 'product/' : ''}setTotalWithDiscount`, basketInfo.totalWithDiscount);
54
- commit(`${isOutsideProduct ? 'product/' : ''}setDelivertType`, basketInfo.deliveryType);
55
- commit(`${isOutsideProduct ? 'product/' : ''}setPostalCode`, basketInfo.postalCode);
56
- commit(`${isOutsideProduct ? 'product/' : ''}setTip`, basketInfo.tip);
57
- commit(`${isOutsideProduct ? 'product/' : ''}setshippingPrice`, basketInfo.shipping_price);
49
+ commit(`product/SetShoppingCart`, basketInfo.products, { root: true });
50
+ commit(`product/setDeliveryTime`, basketInfo.deliveryTime, { root: true });
51
+ commit(`product/setVoucherCode`, basketInfo.voucher_code, { root: true });
52
+ commit(`product/setVoucherValue`, basketInfo.voucherValue, { root: true });
53
+ commit(`product/setTotalWithDiscount`, basketInfo.totalWithDiscount, { root: true });
54
+ commit(`product/setDelivertType`, basketInfo.deliveryType, { root: true });
55
+ commit(`product/setPostalCode`, basketInfo.postalCode, { root: true });
56
+ commit(`product/setTip`, basketInfo.tip, { root: true });
57
+ commit(`product/setshippingPrice`, basketInfo.shipping_price, { root: true });
58
58
 
59
59
  if (parseInt(basketInfo.id) !== parseInt(basketId)) {
60
60
  const baskets = JSON.parse(localStorage.getItem('basket'));
@@ -67,6 +67,6 @@ export function updateBasket({commit, basketId, res, isOutsideProduct, restauran
67
67
  localStorage.setItem('basket', JSON.stringify(baskets));
68
68
  }
69
69
 
70
- commit(`${isOutsideProduct ? 'product/' : ''}basketLoadedOnce`);
70
+ commit(`product/basketLoadedOnce`, null, { root: true });
71
71
  return true;
72
72
  }
@@ -716,9 +716,10 @@ const actions = {
716
716
 
717
717
  return axios.post('api/basket/update-extraInfo', {
718
718
  basketId,
719
+ restaurantId: data.restaurantId || restaurantIdEnv,
719
720
  ...data
720
721
  }).then(res =>
721
- updateBasket({commit, basketId, res, isOutsideProduct: true, restaurantId: data.restaurantId})
722
+ updateBasket({commit, basketId, res, restaurantId: data.restaurantId})
722
723
  ).catch(err => {
723
724
  console.error(err);
724
725
  return false;
@@ -275,7 +275,7 @@ const actions = {
275
275
  restaurantId: restaurantIdEnv
276
276
  }
277
277
  }).then(res =>
278
- updateBasket({commit, basketId, res, isOutsideProduct: false, restaurantId: data ? data.restaurantId : undefined})
278
+ updateBasket({commit, basketId, res, restaurantId: data ? data.restaurantId : undefined})
279
279
  ).catch(error => {
280
280
  console.error(error);
281
281
  return false;