@feedmepos/order-plugin-gallery 0.0.10-beta.2 → 0.0.10-beta.4

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,3 +1,3 @@
1
- import { PluginFunction } from "@feedmepos/ordering-sdk";
1
+ import type { PluginFunction } from "@feedmepos/ordering-sdk";
2
2
  declare const compulsoryItemsPlugin: PluginFunction;
3
3
  export default compulsoryItemsPlugin;
@@ -1,4 +1,3 @@
1
- import { OrderItemUtil, } from "@feedmepos/ordering-sdk";
2
1
  import { getAutoAddPlans, getNormalizedRules, getRuleQuantitySummary as getRuleQuantitySummaryShared, getViolationMessages, } from "./compulsory-items.shared.js";
3
2
  const getItemTitleMap = (sdk) => {
4
3
  const titleMap = new Map();
@@ -56,7 +55,7 @@ const buildDefaultOrderItem = (sdk, menuItem, quantity) => {
56
55
  remark: "",
57
56
  quantity,
58
57
  };
59
- return OrderItemUtil.buildOrderItem(baseState, menuItem, option.type);
58
+ return sdk.orderItemUtil.buildOrderItem(baseState, menuItem, option.type);
60
59
  };
61
60
  const autoAddCompulsoryItems = async (sdk, rules, slotActiveBills) => {
62
61
  const order = sdk.orderManager.state.value.order;
@@ -93,19 +92,23 @@ const autoAddCompulsoryItems = async (sdk, rules, slotActiveBills) => {
93
92
  await sdk.orderManager.updateItems(itemsToAdd);
94
93
  }
95
94
  };
96
- const compulsoryItemsPlugin = ({ sdk, onOrderSessionReady, onBeforeSubmitOrder, pluginParams, }) => {
95
+ const compulsoryItemsPlugin = (args) => {
96
+ const { sdk, onBeforeSubmitOrder, pluginParams } = args;
97
+ const { onOrderSessionReady } = args;
97
98
  const getRules = () => {
98
99
  const params = (pluginParams || {});
99
100
  return getNormalizedRules(params.itemLimitConfig);
100
101
  };
101
- onOrderSessionReady(async (params) => {
102
- if (params.isPreviewMode)
103
- return;
104
- const rules = getRules();
105
- if (rules.length === 0)
106
- return;
107
- await autoAddCompulsoryItems(sdk, rules, params.slotActiveBills);
108
- });
102
+ if (typeof onOrderSessionReady === "function") {
103
+ onOrderSessionReady(async (params) => {
104
+ if (params.isPreviewMode)
105
+ return;
106
+ const rules = getRules();
107
+ if (rules.length === 0)
108
+ return;
109
+ await autoAddCompulsoryItems(sdk, rules, params.slotActiveBills);
110
+ });
111
+ }
109
112
  onBeforeSubmitOrder(() => {
110
113
  const rules = getRules();
111
114
  if (rules.length === 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedmepos/order-plugin-gallery",
3
- "version": "0.0.10-beta.2",
3
+ "version": "0.0.10-beta.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"