orderiom-api-package 0.3.57 → 0.3.59

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.57",
3
+ "version": "0.3.59",
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",
@@ -406,6 +406,86 @@ const actions = {
406
406
  if (basketProduct) basketProduct.changingQuantity = false;
407
407
  });
408
408
  },
409
+ addAttributeItems({ dispatch, rootState }, data) {
410
+ const basketProduct = !data.basketProductId
411
+ ? null
412
+ : rootState.orderiomApiPackage.product.ShoppingCart.find(f => f.basketProductId === data.basketProductId);
413
+
414
+ const basket = JSON.parse(localStorage.getItem("basket"));
415
+ const basketId = !rootState.orderiomApiPackage.auth.privateToken
416
+ ? {
417
+ basketId: basket.find(
418
+ (basket) => basket.restaurantId == data.restaurantId
419
+ ).basketId,
420
+ }
421
+ : {};
422
+
423
+ if (basketProduct) basketProduct.changingQuantity = true;
424
+
425
+ data.quantity = parseInt(data.quantity);
426
+
427
+ $http
428
+ .post("api/basket/add-attribute-items", {
429
+ restaurantId: data.restaurantId,
430
+ ...basketId,
431
+ basketProductId: data.basketProductId,
432
+ attributeItems: data.attributeItems.length
433
+ ? data.attributeItems
434
+ : undefined,
435
+ productAttributeItems: data.productAttributeItems.length
436
+ ? data.productAttributeItems
437
+ : undefined,
438
+ })
439
+ .then(async () => {
440
+ return await dispatch("shoppingCartUpdateCallback", {
441
+ restaurantId: data.restaurantId,
442
+ });
443
+ })
444
+ .catch(commonErrorCallback())
445
+ .finally(() => {
446
+ if (basketProduct) basketProduct.changingQuantity = false;
447
+ });
448
+ },
449
+ removeAttributeItems({ dispatch, rootState }, data) {
450
+ const basketProduct = !data.basketProductId
451
+ ? null
452
+ : rootState.orderiomApiPackage.product.ShoppingCart.find(f => f.basketProductId === data.basketProductId);
453
+
454
+ const basket = JSON.parse(localStorage.getItem("basket"));
455
+ const basketId = !rootState.orderiomApiPackage.auth.privateToken
456
+ ? {
457
+ basketId: basket.find(
458
+ (basket) => basket.restaurantId == data.restaurantId
459
+ ).basketId,
460
+ }
461
+ : {};
462
+
463
+ if (basketProduct) basketProduct.changingQuantity = true;
464
+
465
+ data.quantity = parseInt(data.quantity);
466
+
467
+ $http
468
+ .post("api/basket/remove-attribute-items", {
469
+ restaurantId: data.restaurantId,
470
+ ...basketId,
471
+ basketProductId: data.basketProductId,
472
+ attributeItems: data.attributeItems.length
473
+ ? data.attributeItems
474
+ : undefined,
475
+ productAttributeItems: data.productAttributeItems.length
476
+ ? data.productAttributeItems
477
+ : undefined,
478
+ })
479
+ .then(async () => {
480
+ return await dispatch("shoppingCartUpdateCallback", {
481
+ restaurantId: data.restaurantId,
482
+ });
483
+ })
484
+ .catch(commonErrorCallback())
485
+ .finally(() => {
486
+ if (basketProduct) basketProduct.changingQuantity = false;
487
+ });
488
+ },
409
489
  addAddress({ rootState }, data) {
410
490
  const basket = JSON.parse(localStorage.getItem("basket"));
411
491
  const basketId = !rootState.orderiomApiPackage.auth.privateToken
@@ -267,7 +267,7 @@ const actions = {
267
267
  msg: '',
268
268
  data: res.data
269
269
  };
270
- }).catch(commonErrorCallback)
270
+ }).catch(commonErrorCallback())
271
271
  }
272
272
  }
273
273
  export default {