orderiom-api-package 0.3.7 → 0.3.9

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.7",
3
+ "version": "0.3.9",
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
@@ -40,21 +40,22 @@ export function calculateBasketIdParameter(isLogin, restaurantId) {
40
40
 
41
41
  export function updateBasket({commit, basketId, res, isOutsideProduct, restaurantId}){
42
42
  const basketInfo = res.data.data;
43
- commit(`${isOutsideProduct ? 'product/' : ''}setBasketInfo`, basketInfo);
43
+ const scope = isOutsideProduct ? 'product/' : '';
44
+ commit(`${scope}setBasketInfo`, basketInfo);
44
45
 
45
46
  // TODO: why two separate states use same value?
46
- commit(`${isOutsideProduct ? 'product/' : ''}SetSubtotalPrice`, basketInfo.totalPrice);
47
- commit(`${isOutsideProduct ? 'product/' : ''}SetTotalPrice`, basketInfo.totalPrice);
47
+ commit(`${scope}SetSubtotalPrice`, basketInfo.totalPrice);
48
+ commit(`${scope}SetTotalPrice`, basketInfo.totalPrice);
48
49
 
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);
50
+ commit(`${scope}SetShoppingCart`, basketInfo.products);
51
+ commit(`${scope}setDeliveryTime`, basketInfo.deliveryTime);
52
+ commit(`${scope}setVoucherCode`, basketInfo.voucher_code);
53
+ commit(`${scope}setVoucherValue`, basketInfo.voucherValue);
54
+ commit(`${scope}setTotalWithDiscount`, basketInfo.totalWithDiscount);
55
+ commit(`${scope}setDelivertType`, basketInfo.deliveryType);
56
+ commit(`${scope}setPostalCode`, basketInfo.postalCode);
57
+ commit(`${scope}setTip`, basketInfo.tip);
58
+ commit(`${scope}setshippingPrice`, basketInfo.shipping_price);
58
59
 
59
60
  if (parseInt(basketInfo.id) !== parseInt(basketId)) {
60
61
  const baskets = JSON.parse(localStorage.getItem('basket'));
@@ -716,6 +716,7 @@ 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
722
  updateBasket({commit, basketId, res, isOutsideProduct: true, restaurantId: data.restaurantId})
@@ -258,6 +258,8 @@ const actions = {
258
258
  );
259
259
  },
260
260
  getBasket({ commit, rootState }, data) {
261
+ if(typeof data === 'string' || typeof data === 'number') data = {restaurantId: data};
262
+
261
263
  let basketId = undefined;
262
264
  try{
263
265
  basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken, data ? data.restaurantId : undefined);