orderiom-api-package 0.4.10 → 0.4.12

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.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/src/common.js CHANGED
@@ -37,7 +37,7 @@ export function calculateBasketIdParameter(isLogin, restaurantId) {
37
37
  console.error(e);
38
38
  throw new Error('Basket not found');
39
39
  }
40
- const foundBasket = baskets.find(basket => Number(basket.restaurantId) === (Number(restaurantId) || restaurantIdEnv));
40
+ const foundBasket = baskets.findLast(basket => Number(basket.restaurantId) === (Number(restaurantId) || restaurantIdEnv));
41
41
  if(!foundBasket){
42
42
  throw new Error('Basket not found');
43
43
  }
@@ -593,6 +593,22 @@ const actions = {
593
593
  // commit('setorder', res.data.data.order)
594
594
  // commit('setuserOrder', JSON.parse(res.data.data.order.user_details));
595
595
  // commit('setshippigPriceOrder', res.data.data.order.shipping_price);
596
+ const basketData = JSON.parse(localStorage.getItem("basket"));
597
+ if (basketData) {
598
+ const index = basketId
599
+ ? basketData.findIndex(item => Number(item.basketId) === Number(basketId))
600
+ : basketData.findIndex(item => Number(item.restaurantId) === Number(data.restaurantId || restaurantIdEnv))
601
+ if (index > -1) {
602
+ basketData.splice(index, 1);
603
+ localStorage.setItem("basket", JSON.stringify(basketData));
604
+ }
605
+ }
606
+
607
+ commit("product/SetSubtotalPrice", "0.00", {root: true});
608
+ commit("product/SetShoppingCart", [], {root: true});
609
+ commit("product/setBasketInfo", {}, {root: true});
610
+ commit("product/setDeliveryTime", "", {root: true});
611
+ commit("product/SetTotalPrice", "0.00", { root: true });
596
612
 
597
613
  if (
598
614
  (
@@ -618,23 +634,6 @@ const actions = {
618
634
  window.location = res.data.data.paymentLink;
619
635
  }
620
636
 
621
- const basketData = JSON.parse(localStorage.getItem("basket"));
622
- if (basketData) {
623
- const index = basketId
624
- ? basketData.findIndex(item => Number(item.basketId) === Number(basketId))
625
- : basketData.findIndex(item => Number(item.restaurantId) === Number(data.restaurantId || restaurantIdEnv))
626
- if (index > -1) {
627
- basketData.splice(index, 1);
628
- localStorage.setItem("basket", JSON.stringify(basketData));
629
- }
630
- }
631
-
632
- commit("product/SetSubtotalPrice", "0.00", {root: true});
633
- commit("product/SetShoppingCart", [], {root: true});
634
- commit("product/setBasketInfo", {}, {root: true});
635
- commit("product/setDeliveryTime", "", {root: true});
636
- commit("product/SetTotalPrice", "0.00", { root: true });
637
-
638
637
  return {
639
638
  type: "success",
640
639
  msg: "ok",
@@ -390,7 +390,9 @@ const actions = {
390
390
  }
391
391
 
392
392
  const selectedCategory = rootState.orderiomApiPackage.product.selectedCategory
393
- if (selectedCategory) {
393
+ if (rootState.orderiomApiPackage.product.showPinnedProducts) {
394
+ dispatch("getPinnedProducts", restaurantId);
395
+ } else if (selectedCategory) {
394
396
  dispatch("getProducts", {
395
397
  category: selectedCategory,
396
398
  restaurantId: restaurantId,
@@ -403,10 +405,6 @@ const actions = {
403
405
  dispatch('getCategories', (restaurantId || restaurantIdEnv));
404
406
  }
405
407
 
406
- if (rootState.orderiomApiPackage.product.showPinnedProducts) {
407
- dispatch("getPinnedProducts", restaurantId);
408
- }
409
-
410
408
  const result = await dispatch("getBasket", (restaurantId || restaurantIdEnv));
411
409
 
412
410
  return {