@feedmepos/order-plugin-gallery 0.0.5 → 0.0.6

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.
@@ -1,5 +1,4 @@
1
1
  const maxItemInCategoryPlugin = ({ sdk, onAfterComputeMenuState, onBeforeSubmitOrder, pluginParams, }) => {
2
- const MAX_FREE_ITEMS = 1;
3
2
  const MIN_ITEMS = 1;
4
3
  const MAX_ITEMS = 2;
5
4
  const categoryLimitConfig = pluginParams?.categoryLimitConfig || {};
@@ -43,14 +42,6 @@ const maxItemInCategoryPlugin = ({ sdk, onAfterComputeMenuState, onBeforeSubmitO
43
42
  return { menuItem, quantity: item.quantity };
44
43
  })
45
44
  .filter((entry) => Boolean(entry));
46
- // const numberOfFreeItems = {
47
- // submitted: submittedItemsInCategory.reduce((sum, entry) => {
48
- // return entry.menuItem.price.amount === 0 ? sum + entry.quantity : sum;
49
- // }, 0),
50
- // inCart: cartItemsInCategory.reduce((sum, entry) => {
51
- // return entry.menuItem.price.amount === 0 ? sum + entry.quantity : sum;
52
- // }, 0),
53
- // };
54
45
  const numberOfTotalItems = {
55
46
  submitted: submittedItemsInCategory.reduce((sum, entry) => sum + entry.quantity, 0),
56
47
  inCart: cartItemsInCategory.reduce((sum, entry) => sum + entry.quantity, 0),
@@ -63,19 +54,10 @@ const maxItemInCategoryPlugin = ({ sdk, onAfterComputeMenuState, onBeforeSubmitO
63
54
  });
64
55
  };
65
56
  // POS already ordered, and customer have not added more target items to cart, we ignore the validation
66
- // if (numberOfTotalItems.submitted > 0 && numberOfTotalItems.inCart === 0) {
67
- // return true;
68
- // }
69
- // const totalFreeItems =
70
- // numberOfFreeItems.submitted + numberOfFreeItems.inCart;
57
+ if (numberOfTotalItems.submitted > 0 && numberOfTotalItems.inCart === 0) {
58
+ return true;
59
+ }
71
60
  const totalItems = numberOfTotalItems.submitted + numberOfTotalItems.inCart;
72
- // if (totalFreeItems > MAX_FREE_ITEMS) {
73
- // const overFreeItems = totalFreeItems - MAX_FREE_ITEMS;
74
- // toast(
75
- // `Remove ${overFreeItems} free ${targetCategory.name} from cart to continue. `
76
- // );
77
- // return false;
78
- // }
79
61
  if (totalItems > MAX_ITEMS) {
80
62
  const extraItems = totalItems - MAX_ITEMS;
81
63
  toast(`Remove ${extraItems} ${targetCategory.name} from cart to continue. `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedmepos/order-plugin-gallery",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"