@pisell/private-materials 6.3.139 → 6.3.141

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.
Files changed (153) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +5 -5
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +7 -7
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +6 -6
  11. package/es/components/appointmentBooking/components/Cart/Item/Total.d.ts +1 -0
  12. package/es/components/appointmentBooking/components/Cart/index.d.ts +1 -0
  13. package/es/components/appointmentBooking/components/Deposit/index.d.ts +1 -0
  14. package/es/components/appointmentBooking/components/Footer/index.d.ts +1 -0
  15. package/es/components/appointmentBooking/components/Guest/components/InformationOptionsModal/index.d.ts +1 -0
  16. package/es/components/booking/forms/footer.d.ts +1 -0
  17. package/es/components/booking/forms/sendModal/useSendModal.d.ts +1 -0
  18. package/es/components/booking/hooks/useClearCart.d.ts +1 -0
  19. package/es/components/booking/info/dateRange/index.d.ts +1 -0
  20. package/es/components/booking/notes/NoteBlock/index.d.ts +1 -0
  21. package/es/components/ecocup/components/AddCustomerModal/index.d.ts +1 -0
  22. package/es/components/ecocup/components/CupActionList/index.d.ts +1 -0
  23. package/es/components/ecocup/components/CupActionModal/index.d.ts +1 -0
  24. package/es/components/ecocup/components/CupStatusModal/index.d.ts +1 -0
  25. package/es/components/ecocup/components/CustomerAndCupModal/index.d.ts +1 -0
  26. package/es/components/ecocup/components/MoreDropdown/index.d.ts +1 -0
  27. package/es/components/ecocup/components/SearchBar/index.d.ts +1 -0
  28. package/es/components/ecocup/components/SettingModal/index.d.ts +1 -0
  29. package/es/components/ecocup/cupList/hooks/useColumns.d.ts +1 -0
  30. package/es/components/ecocup/cupList/hooks/useSummary.d.ts +1 -0
  31. package/es/components/ecocup/cupList/index.d.ts +1 -0
  32. package/es/components/eventBooking/components/ErrorTip/index.d.ts +1 -0
  33. package/es/components/eventBooking/components/Provider/Cart/index.d.ts +1 -0
  34. package/es/components/eventBooking/components/Provider/EmptyHolderModal/index.d.ts +1 -0
  35. package/es/components/eventBooking/components/Provider/Event/index.d.ts +1 -0
  36. package/es/components/eventBooking/components/Provider/Footer/index.d.ts +1 -0
  37. package/es/components/eventBooking/components/Provider/InformationOptionsModal/index.d.ts +1 -0
  38. package/es/components/eventBooking/components/Provider/OrderProductModal/index.d.ts +1 -0
  39. package/es/components/eventBooking/components/Provider/RemoveOptionConfirmModal.d.ts +1 -0
  40. package/es/components/eventBooking/components/Provider/Resource/index.d.ts +1 -0
  41. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +1 -0
  42. package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +1 -0
  43. package/es/components/eventBooking/components/bookingDetailModal/components/BookingOptions.d.ts +1 -0
  44. package/es/components/eventBooking/components/scheduleCalendar/components/ScheduleTimeItem/index.d.ts +1 -0
  45. package/es/components/pay/toC/PaymentMethods/StripePay/Stripe/components/SetupForm/index.d.ts +1 -0
  46. package/es/components/pay/toC/WalletPassBlock/components/WalletUseList/index.d.ts +1 -0
  47. package/es/components/pisellSelectCustomerModal/RightPanel/List/index.d.ts +1 -0
  48. package/es/components/scanOrder/components/Cart/index.js +127 -56
  49. package/es/components/scanOrder/components/Cart/index.less +11 -5
  50. package/es/components/scanOrder/components/Check/index.js +85 -80
  51. package/es/components/scanOrder/components/Content/index.js +356 -164
  52. package/es/components/scanOrder/components/Menu/index.d.ts +11 -0
  53. package/es/components/scanOrder/components/Menu/index.js +140 -169
  54. package/es/components/scanOrder/components/Voucher/index.d.ts +8 -0
  55. package/es/components/scanOrder/components/Voucher/index.js +250 -0
  56. package/es/components/scanOrder/context.js +38 -13
  57. package/es/components/scanOrder/hooks.js +4 -1
  58. package/es/components/scanOrder/locales.d.ts +65 -0
  59. package/es/components/scanOrder/locales.js +65 -0
  60. package/es/components/scanOrder/types.d.ts +10 -0
  61. package/es/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
  62. package/es/components/scanOrder/utils/toShoppingCartProducts.js +137 -9
  63. package/es/components/scanOrder/utils/transformProductDetail.js +21 -4
  64. package/es/components/shoppingCart/hooks/useAddService.d.ts +1 -0
  65. package/es/components/shoppingCart/hooks/useClearCart.d.ts +1 -0
  66. package/es/components/venueBooking/components/Addons/index.js +42 -33
  67. package/es/components/venueBooking/components/Cart/index.js +26 -14
  68. package/es/components/workSpaceList/components/Modal/index.d.ts +1 -0
  69. package/es/plus/orderList/components/HandleActions.d.ts +1 -0
  70. package/es/plus/orderList/components/QuickFilter.d.ts +1 -0
  71. package/es/plus/orderList/components/Reset.d.ts +1 -0
  72. package/es/plus/orderList/components/Toolbar.d.ts +1 -0
  73. package/es/plus/pisellReservation/floorMap/useReservationFloorPlan.d.ts +1 -0
  74. package/es/plus/saasAttendance/settings/components/membersField/index.d.ts +1 -0
  75. package/es/plus/saasRegister/components/VertifyEmail.d.ts +1 -0
  76. package/es/plus/selectHolder/components/ErrorTip/index.d.ts +1 -0
  77. package/es/plus/skuOptionsSelection/components/OptionsCard/OptionItemCard.d.ts +1 -0
  78. package/es/plus/skuOptionsSelection/components/OptionsCard/index.d.ts +1 -0
  79. package/es/plus/skuOptionsSelection/components/OptionsModal/index.d.ts +1 -0
  80. package/es/plus/walletPassGallery/components/timelineSection/index.d.ts +1 -0
  81. package/es/pro/pisellPhoneKeyboard/index.d.ts +1 -0
  82. package/lib/components/appointmentBooking/components/Cart/Item/Total.d.ts +1 -0
  83. package/lib/components/appointmentBooking/components/Cart/index.d.ts +1 -0
  84. package/lib/components/appointmentBooking/components/Deposit/index.d.ts +1 -0
  85. package/lib/components/appointmentBooking/components/Footer/index.d.ts +1 -0
  86. package/lib/components/appointmentBooking/components/Guest/components/InformationOptionsModal/index.d.ts +1 -0
  87. package/lib/components/booking/forms/footer.d.ts +1 -0
  88. package/lib/components/booking/forms/sendModal/useSendModal.d.ts +1 -0
  89. package/lib/components/booking/hooks/useClearCart.d.ts +1 -0
  90. package/lib/components/booking/info/dateRange/index.d.ts +1 -0
  91. package/lib/components/booking/notes/NoteBlock/index.d.ts +1 -0
  92. package/lib/components/ecocup/components/AddCustomerModal/index.d.ts +1 -0
  93. package/lib/components/ecocup/components/CupActionList/index.d.ts +1 -0
  94. package/lib/components/ecocup/components/CupActionModal/index.d.ts +1 -0
  95. package/lib/components/ecocup/components/CupStatusModal/index.d.ts +1 -0
  96. package/lib/components/ecocup/components/CustomerAndCupModal/index.d.ts +1 -0
  97. package/lib/components/ecocup/components/MoreDropdown/index.d.ts +1 -0
  98. package/lib/components/ecocup/components/SearchBar/index.d.ts +1 -0
  99. package/lib/components/ecocup/components/SettingModal/index.d.ts +1 -0
  100. package/lib/components/ecocup/cupList/hooks/useColumns.d.ts +1 -0
  101. package/lib/components/ecocup/cupList/hooks/useSummary.d.ts +1 -0
  102. package/lib/components/ecocup/cupList/index.d.ts +1 -0
  103. package/lib/components/eventBooking/components/ErrorTip/index.d.ts +1 -0
  104. package/lib/components/eventBooking/components/Provider/Cart/index.d.ts +1 -0
  105. package/lib/components/eventBooking/components/Provider/EmptyHolderModal/index.d.ts +1 -0
  106. package/lib/components/eventBooking/components/Provider/Event/index.d.ts +1 -0
  107. package/lib/components/eventBooking/components/Provider/Footer/index.d.ts +1 -0
  108. package/lib/components/eventBooking/components/Provider/InformationOptionsModal/index.d.ts +1 -0
  109. package/lib/components/eventBooking/components/Provider/OrderProductModal/index.d.ts +1 -0
  110. package/lib/components/eventBooking/components/Provider/RemoveOptionConfirmModal.d.ts +1 -0
  111. package/lib/components/eventBooking/components/Provider/Resource/index.d.ts +1 -0
  112. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/WeekItem/index.d.ts +1 -0
  113. package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.d.ts +1 -0
  114. package/lib/components/eventBooking/components/bookingDetailModal/components/BookingOptions.d.ts +1 -0
  115. package/lib/components/eventBooking/components/scheduleCalendar/components/ScheduleTimeItem/index.d.ts +1 -0
  116. package/lib/components/pay/toC/PaymentMethods/StripePay/Stripe/components/SetupForm/index.d.ts +1 -0
  117. package/lib/components/pay/toC/WalletPassBlock/components/WalletUseList/index.d.ts +1 -0
  118. package/lib/components/pisellSelectCustomerModal/RightPanel/List/index.d.ts +1 -0
  119. package/lib/components/scanOrder/components/Cart/index.js +79 -24
  120. package/lib/components/scanOrder/components/Cart/index.less +11 -5
  121. package/lib/components/scanOrder/components/Check/index.js +28 -23
  122. package/lib/components/scanOrder/components/Content/index.js +136 -42
  123. package/lib/components/scanOrder/components/Menu/index.d.ts +11 -0
  124. package/lib/components/scanOrder/components/Menu/index.js +23 -36
  125. package/lib/components/scanOrder/components/Voucher/index.d.ts +8 -0
  126. package/lib/components/scanOrder/components/Voucher/index.js +162 -0
  127. package/lib/components/scanOrder/context.js +21 -10
  128. package/lib/components/scanOrder/hooks.js +4 -1
  129. package/lib/components/scanOrder/locales.d.ts +65 -0
  130. package/lib/components/scanOrder/locales.js +65 -0
  131. package/lib/components/scanOrder/types.d.ts +10 -0
  132. package/lib/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
  133. package/lib/components/scanOrder/utils/toShoppingCartProducts.js +88 -6
  134. package/lib/components/scanOrder/utils/transformProductDetail.js +10 -3
  135. package/lib/components/shoppingCart/hooks/useAddService.d.ts +1 -0
  136. package/lib/components/shoppingCart/hooks/useClearCart.d.ts +1 -0
  137. package/lib/components/venueBooking/components/Addons/index.js +15 -8
  138. package/lib/components/venueBooking/components/Cart/index.js +8 -2
  139. package/lib/components/workSpaceList/components/Modal/index.d.ts +1 -0
  140. package/lib/plus/orderList/components/HandleActions.d.ts +1 -0
  141. package/lib/plus/orderList/components/QuickFilter.d.ts +1 -0
  142. package/lib/plus/orderList/components/Reset.d.ts +1 -0
  143. package/lib/plus/orderList/components/Toolbar.d.ts +1 -0
  144. package/lib/plus/pisellReservation/floorMap/useReservationFloorPlan.d.ts +1 -0
  145. package/lib/plus/saasAttendance/settings/components/membersField/index.d.ts +1 -0
  146. package/lib/plus/saasRegister/components/VertifyEmail.d.ts +1 -0
  147. package/lib/plus/selectHolder/components/ErrorTip/index.d.ts +1 -0
  148. package/lib/plus/skuOptionsSelection/components/OptionsCard/OptionItemCard.d.ts +1 -0
  149. package/lib/plus/skuOptionsSelection/components/OptionsCard/index.d.ts +1 -0
  150. package/lib/plus/skuOptionsSelection/components/OptionsModal/index.d.ts +1 -0
  151. package/lib/plus/walletPassGallery/components/timelineSection/index.d.ts +1 -0
  152. package/lib/pro/pisellPhoneKeyboard/index.d.ts +1 -0
  153. package/package.json +1 -1
@@ -91,7 +91,9 @@ function ReadyState() {
91
91
  scanOrderModule,
92
92
  isCacheHydrated,
93
93
  markGate,
94
- isGatePassed
94
+ isGatePassed,
95
+ resumeStep,
96
+ consumeResumeStep
95
97
  } = (0, import_context.useScanOrderContext)();
96
98
  const { isLogin, openLoginModal } = (0, import_hooks.useScanOrderLogin)();
97
99
  const utils = (0, import_hooks.contextUtils)();
@@ -109,14 +111,55 @@ function ReadyState() {
109
111
  content: null
110
112
  });
111
113
  const [pendingFormPayload, setPendingFormPayload] = (0, import_react.useState)(null);
114
+ const [productList, setProductList] = (0, import_react.useState)([]);
115
+ const productListLoadedRef = (0, import_react.useRef)(false);
116
+ const productListPromiseRef = (0, import_react.useRef)(null);
117
+ const ensureProductListLoaded = (0, import_react.useCallback)(async () => {
118
+ if (productListLoadedRef.current) return;
119
+ if (productListPromiseRef.current) {
120
+ await productListPromiseRef.current.catch(() => {
121
+ });
122
+ return;
123
+ }
124
+ const request = (async () => {
125
+ try {
126
+ const res = await runModuleAction("getProductList");
127
+ if (Array.isArray(res)) {
128
+ productListLoadedRef.current = true;
129
+ setProductList(res);
130
+ return;
131
+ }
132
+ import_antd.Modal.confirm({
133
+ title: res == null ? void 0 : res.message,
134
+ okText: String(import_utils.locales.getText("pisell2.event.confirm") || "OK"),
135
+ cancelButtonProps: { style: { display: "none" } },
136
+ maskClosable: false,
137
+ onOk: () => {
138
+ location.replace("/");
139
+ }
140
+ });
141
+ } catch (error) {
142
+ console.warn("[scanOrder] getProductList failed", error);
143
+ } finally {
144
+ productListPromiseRef.current = null;
145
+ }
146
+ })();
147
+ productListPromiseRef.current = request;
148
+ await request;
149
+ }, [runModuleAction]);
112
150
  const requestEntryPaxRef = (0, import_react.useRef)(0);
113
151
  const requestPaxMinRef = (0, import_react.useRef)(1);
114
152
  const requestPaxMaxRef = (0, import_react.useRef)(1);
115
153
  const tableFormRecordRef = (0, import_react.useRef)(null);
154
+ const entryPaxModalWasPresentedRef = (0, import_react.useRef)(false);
116
155
  const getLocalizedName = (nameMap) => {
117
156
  if (!nameMap) return "";
118
157
  const currentLocale = import_utils.locales.getLocale();
119
- return nameMap[currentLocale] || nameMap.original || nameMap.en || "";
158
+ const localized = nameMap[currentLocale];
159
+ if (typeof localized === "string" && localized) return localized;
160
+ const original = nameMap.original;
161
+ if (typeof original === "string" && original) return original;
162
+ return "";
120
163
  };
121
164
  const resolveLocalizedText = (value) => {
122
165
  if (value == null) return "";
@@ -140,6 +183,34 @@ function ReadyState() {
140
183
  };
141
184
  };
142
185
  const app = (_a = utils == null ? void 0 : utils.getApp) == null ? void 0 : _a.call(utils);
186
+ const navigateToHome = () => {
187
+ var _a2, _b2;
188
+ if ((_a2 = app == null ? void 0 : app.history) == null ? void 0 : _a2.replace) {
189
+ app.history.replace("/");
190
+ } else if ((_b2 = app == null ? void 0 : app.history) == null ? void 0 : _b2.push) {
191
+ app.history.push("/");
192
+ } else {
193
+ location.replace("/");
194
+ }
195
+ };
196
+ const requestEntryPaxModal = () => new Promise((resolve) => {
197
+ var _a2;
198
+ if (typeof (utils == null ? void 0 : utils.action) !== "function") {
199
+ resolve(null);
200
+ return;
201
+ }
202
+ utils.action({
203
+ type: "pisell1.handlePaxModal",
204
+ data: {
205
+ tableName: getLocalizedName((_a2 = tableFormRecordRef.current) == null ? void 0 : _a2.name),
206
+ requestPaxMin: requestPaxMinRef.current,
207
+ requestPaxMax: requestPaxMaxRef.current
208
+ },
209
+ callback: (result) => {
210
+ resolve(extractEntryPaxNumber(result));
211
+ }
212
+ });
213
+ });
143
214
  const handleOrderDetail = (order_id) => {
144
215
  var _a2, _b2;
145
216
  const link = `/order/details?id=${order_id}`;
@@ -152,7 +223,6 @@ function ReadyState() {
152
223
  }
153
224
  };
154
225
  const handleBack = () => {
155
- var _a2, _b2;
156
226
  if (currentStep !== "product") {
157
227
  prevStep();
158
228
  return;
@@ -161,13 +231,23 @@ function ReadyState() {
161
231
  handleOrderDetail(entryContext.order_id);
162
232
  return;
163
233
  }
164
- if ((_a2 = app == null ? void 0 : app.history) == null ? void 0 : _a2.replace) {
165
- app.history.replace("/");
166
- } else if ((_b2 = app == null ? void 0 : app.history) == null ? void 0 : _b2.push) {
167
- app.history.push("/");
168
- } else {
169
- location.replace("/");
234
+ if (entryPaxModalWasPresentedRef.current) {
235
+ void (async () => {
236
+ const pax = await requestEntryPaxModal();
237
+ if (pax == null) {
238
+ navigateToHome();
239
+ return;
240
+ }
241
+ try {
242
+ await runModuleAction("setEntryPaxNumber", pax);
243
+ await refreshViewModel();
244
+ } catch (error) {
245
+ console.warn("[scanOrder] setEntryPaxNumber on back pax confirm failed", error);
246
+ }
247
+ })();
248
+ return;
170
249
  }
250
+ navigateToHome();
171
251
  };
172
252
  const enterProductStep = async () => {
173
253
  try {
@@ -176,10 +256,16 @@ function ReadyState() {
176
256
  } catch (error) {
177
257
  console.warn("[scanOrder] applyItemRulePrefill failed", error);
178
258
  } finally {
179
- if (currentStep !== "check") goToStep("product");
259
+ const target = resumeStep === "check" ? "check" : "product";
260
+ if (resumeStep) consumeResumeStep();
261
+ goToStep(target);
180
262
  }
181
263
  };
182
264
  const runEntryPaxGateThenEnterProduct = async () => {
265
+ if (entryMode === "additional_order") {
266
+ await enterProductStep();
267
+ return;
268
+ }
183
269
  if (requestEntryPaxRef.current !== 1) {
184
270
  await enterProductStep();
185
271
  return;
@@ -188,26 +274,10 @@ function ReadyState() {
188
274
  await enterProductStep();
189
275
  return;
190
276
  }
191
- const pax = await new Promise((resolve) => {
192
- var _a2;
193
- if (typeof (utils == null ? void 0 : utils.action) !== "function") {
194
- resolve(null);
195
- return;
196
- }
197
- utils.action({
198
- type: "pisell1.handlePaxModal",
199
- data: {
200
- tableName: getLocalizedName((_a2 = tableFormRecordRef.current) == null ? void 0 : _a2.name),
201
- requestPaxMin: requestPaxMinRef.current,
202
- requestPaxMax: requestPaxMaxRef.current
203
- },
204
- callback: (result) => {
205
- resolve(extractEntryPaxNumber(result));
206
- }
207
- });
208
- });
277
+ entryPaxModalWasPresentedRef.current = true;
278
+ const pax = await requestEntryPaxModal();
209
279
  if (pax == null) {
210
- location.replace("/");
280
+ navigateToHome();
211
281
  return;
212
282
  }
213
283
  try {
@@ -277,6 +347,7 @@ function ReadyState() {
277
347
  };
278
348
  (0, import_react.useEffect)(() => {
279
349
  const checkResourceAvailable = async () => {
350
+ var _a2;
280
351
  const hasOrderId = !!(entryContext == null ? void 0 : entryContext.order_id);
281
352
  const {
282
353
  mode,
@@ -318,19 +389,33 @@ function ReadyState() {
318
389
  }
319
390
  await runEntryPaxGateThenEnterProduct();
320
391
  } else if (isAdditionalOrder) {
321
- if (hasOrderId) {
322
- await enterProductStep();
323
- } else {
324
- handleOrderDetail(order_id);
325
- }
392
+ await enterProductStep();
326
393
  } else if (mode === "submit_disabled") {
327
394
  const tips = resolveLocalizedText(errorTips) || String(import_utils.locales.getText("pisell2.scan.order.submit.disabled.default") || "");
328
395
  setSubmitDisabledTips(tips);
329
396
  await enterProductStep();
397
+ } else if (mode === "resource_busy") {
398
+ if (!isLogin) {
399
+ (_a2 = scanOrderModule == null ? void 0 : scanOrderModule.setUIState) == null ? void 0 : _a2.call(scanOrderModule, "pendingStep", currentStep);
400
+ openLoginModal({
401
+ callback: (status) => {
402
+ var _a3, _b2;
403
+ if (status === "success") {
404
+ (_a3 = scanOrderModule == null ? void 0 : scanOrderModule.deleteUIState) == null ? void 0 : _a3.call(scanOrderModule, "pendingStep");
405
+ handleOrderDetail(order_id);
406
+ return;
407
+ }
408
+ (_b2 = scanOrderModule == null ? void 0 : scanOrderModule.deleteUIState) == null ? void 0 : _b2.call(scanOrderModule, "pendingStep");
409
+ location.replace("/");
410
+ }
411
+ });
412
+ } else {
413
+ handleOrderDetail(order_id);
414
+ }
330
415
  } else {
331
416
  let content = resolveLocalizedText(errorTips);
332
417
  if (!content) {
333
- if (mode === "resource_busy") {
418
+ if (mode === "resource_block") {
334
419
  content = String(
335
420
  import_utils.locales.getText("pisell2.scan.order.resource.status.exception") || ""
336
421
  );
@@ -342,7 +427,7 @@ function ReadyState() {
342
427
  }
343
428
  import_antd.Modal.info({
344
429
  title: import_utils.locales.getText("pisell2.scan.order.step.error"),
345
- content: String(content || "").trim(),
430
+ content: resolveLocalizedText(content).trim(),
346
431
  okText: String(import_utils.locales.getText("pisell2.event.confirm") || "OK"),
347
432
  maskClosable: false,
348
433
  onOk: () => {
@@ -375,7 +460,14 @@ function ReadyState() {
375
460
  }, [currentStep, cartValidation == null ? void 0 : cartValidation.passed]);
376
461
  const stepRegistry = {
377
462
  init: /* @__PURE__ */ import_react.default.createElement(import_Initializing.default, null),
378
- product: /* @__PURE__ */ import_react.default.createElement(import_Menu.default, { onCheckout: () => goToStep("check") }),
463
+ product: /* @__PURE__ */ import_react.default.createElement(
464
+ import_Menu.default,
465
+ {
466
+ onCheckout: () => goToStep("check"),
467
+ productList,
468
+ onEnsureProductList: ensureProductListLoaded
469
+ }
470
+ ),
379
471
  check: /* @__PURE__ */ import_react.default.createElement(import_Check.default, null),
380
472
  error: /* @__PURE__ */ import_react.default.createElement(import_ErrorState.default, { message: import_utils.locales.getText("pisell2.scan.order.store.status.exception") })
381
473
  };
@@ -420,6 +512,7 @@ function ReadyState() {
420
512
  return highlighted;
421
513
  };
422
514
  const gotoCheckOrder = async () => {
515
+ var _a2;
423
516
  if (submitDisabledTips) {
424
517
  import_antd.message.warning(submitDisabledTips, 2);
425
518
  return;
@@ -450,16 +543,17 @@ function ReadyState() {
450
543
  return;
451
544
  }
452
545
  if (!isLogin) {
546
+ (_a2 = scanOrderModule == null ? void 0 : scanOrderModule.setUIState) == null ? void 0 : _a2.call(scanOrderModule, "pendingStep", "check");
453
547
  openLoginModal({
454
548
  callback: (status) => {
455
- if (status === "success") {
456
- goToStep("check");
457
- }
549
+ var _a3;
550
+ (_a3 = scanOrderModule == null ? void 0 : scanOrderModule.deleteUIState) == null ? void 0 : _a3.call(scanOrderModule, "pendingStep");
551
+ if (status === "success") goToStep("check");
458
552
  }
459
553
  });
460
- } else {
461
- goToStep("check");
554
+ return;
462
555
  }
556
+ goToStep("check");
463
557
  };
464
558
  const isMobileView = (0, import_utils.isMobile)();
465
559
  const isShowFooter = (0, import_react.useMemo)(() => {
@@ -1,6 +1,17 @@
1
1
  /// <reference types="react" />
2
2
  interface MenuProps {
3
3
  onCheckout: () => void;
4
+ /**
5
+ * 商品列表(由上层 ReadyState 持有,配合 onEnsureProductList 做幂等拉取与持久化:
6
+ * 切 step 回到 product 时 Menu 会 remount,但 productList 在 ReadyState 不会丢)
7
+ */
8
+ productList: any[];
9
+ /**
10
+ * 幂等触发商品列表拉取。Menu mount 时调用:
11
+ * - 首次:真发请求
12
+ * - 后续(如从 check 返回 product):命中缓存,直接短路,不重复发请求
13
+ */
14
+ onEnsureProductList: () => Promise<void>;
4
15
  }
5
16
  export default function Menu(props: MenuProps): JSX.Element;
6
17
  export {};
@@ -37,12 +37,11 @@ var import_productSelect = __toESM(require("../../../../plus/productSelect"));
37
37
  var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
38
38
  var import_context = require("../../context");
39
39
  var import_utils = require("@pisell/utils");
40
- var import_antd = require("antd");
41
40
  var import_materials = require("@pisell/materials");
42
41
  var import_transformProductDetail = require("../../utils/transformProductDetail");
43
42
  function Menu(props) {
44
43
  var _a;
45
- const { onCheckout } = props;
44
+ const { onCheckout, productList, onEnsureProductList } = props;
46
45
  const context = (0, import_useEngineContext.default)();
47
46
  const { utils } = context.appHelper || {};
48
47
  const {
@@ -51,34 +50,18 @@ function Menu(props) {
51
50
  viewModel
52
51
  } = (0, import_context.useScanOrderContext)();
53
52
  const [dineInConfig, setDineInConfig] = (0, import_react.useState)(null);
54
- const getConfig = async () => {
53
+ const getConfig = (0, import_react.useCallback)(async () => {
55
54
  const otherParams = await runModuleAction("getOtherParams");
56
55
  console.log("otherParams >>>>> ", otherParams);
57
56
  const dineInConfig2 = (otherParams == null ? void 0 : otherParams.dineInConfig) ?? {};
58
57
  setDineInConfig(dineInConfig2);
59
- };
60
- getConfig();
61
- const [productList, setProductList] = (0, import_react.useState)([]);
58
+ }, [runModuleAction]);
62
59
  (0, import_react.useEffect)(() => {
63
- const fetchProductList = async () => {
64
- const res = await runModuleAction("getProductList");
65
- console.log("getProductList >>>>> ", res);
66
- if (Array.isArray(res)) {
67
- setProductList(res);
68
- } else {
69
- import_antd.Modal.confirm({
70
- title: res.message,
71
- okText: String(import_utils.locales.getText("pisell2.event.confirm") || "OK"),
72
- cancelButtonProps: { style: { display: "none" } },
73
- maskClosable: false,
74
- onOk: () => {
75
- location.replace("/");
76
- }
77
- });
78
- }
79
- };
80
- fetchProductList();
60
+ getConfig();
81
61
  }, []);
62
+ (0, import_react.useEffect)(() => {
63
+ void onEnsureProductList();
64
+ }, [onEnsureProductList]);
82
65
  const scrollRef = (0, import_react.useRef)(null);
83
66
  const isMobileView = (0, import_utils.isMobile)();
84
67
  const height = window.innerHeight - 100;
@@ -96,11 +79,12 @@ function Menu(props) {
96
79
  }
97
80
  };
98
81
  const removeOrderProduct = async (params) => {
99
- const { product_id, product_variant_id, sourceData } = params;
82
+ const { product_id, product_variant_id, identity_key, sourceData } = params;
100
83
  try {
101
84
  await runModuleAction("removeProductFromOrder", {
102
85
  product_id,
103
- product_variant_id
86
+ product_variant_id,
87
+ ...identity_key ? { identity_key } : {}
104
88
  });
105
89
  await refreshViewModel();
106
90
  } catch (error) {
@@ -108,16 +92,18 @@ function Menu(props) {
108
92
  error,
109
93
  sourceData,
110
94
  product_id,
111
- product_variant_id
95
+ product_variant_id,
96
+ identity_key
112
97
  });
113
98
  }
114
99
  };
115
100
  const updateOrderProduct = async (params) => {
116
- const { product_id, product_variant_id, updates, sourceData } = params;
101
+ const { product_id, product_variant_id, identity_key, updates, sourceData } = params;
117
102
  try {
118
103
  await runModuleAction("updateProductInOrder", {
119
104
  product_id,
120
105
  product_variant_id,
106
+ ...identity_key ? { identity_key } : {},
121
107
  updates
122
108
  });
123
109
  await refreshViewModel();
@@ -127,6 +113,7 @@ function Menu(props) {
127
113
  sourceData,
128
114
  product_id,
129
115
  product_variant_id,
116
+ identity_key,
130
117
  updates
131
118
  });
132
119
  }
@@ -162,18 +149,20 @@ function Menu(props) {
162
149
  return;
163
150
  }
164
151
  const normalizedQuantity = Number.isNaN(nextQuantity) ? 0 : Math.max(0, Math.floor(nextQuantity));
152
+ const cartItems = Array.isArray(viewModel == null ? void 0 : viewModel.cartItems) ? viewModel.cartItems : [];
153
+ const existedCartItem = cartItems.find((cartItem) => {
154
+ return String((cartItem == null ? void 0 : cartItem.product_id) ?? null) === String((orderProduct == null ? void 0 : orderProduct.product_id) ?? null) && Number((cartItem == null ? void 0 : cartItem.product_variant_id) ?? 0) === productVariantId;
155
+ });
156
+ const existedIdentityKey = typeof (existedCartItem == null ? void 0 : existedCartItem.identity_key) === "string" && existedCartItem.identity_key.length > 0 ? existedCartItem.identity_key : void 0;
165
157
  if (normalizedQuantity <= 0) {
166
158
  await removeOrderProduct({
167
159
  product_id: (orderProduct == null ? void 0 : orderProduct.product_id) ?? null,
168
160
  product_variant_id: productVariantId,
161
+ identity_key: existedIdentityKey,
169
162
  sourceData: quantityData
170
163
  });
171
164
  return;
172
165
  }
173
- const cartItems = Array.isArray(viewModel == null ? void 0 : viewModel.cartItems) ? viewModel.cartItems : [];
174
- const existedCartItem = cartItems.find((cartItem) => {
175
- return String((cartItem == null ? void 0 : cartItem.product_id) ?? null) === String((orderProduct == null ? void 0 : orderProduct.product_id) ?? null) && Number((cartItem == null ? void 0 : cartItem.product_variant_id) ?? 0) === productVariantId;
176
- });
177
166
  if (!existedCartItem) {
178
167
  await addOrderProduct({
179
168
  orderProduct: {
@@ -187,6 +176,7 @@ function Menu(props) {
187
176
  await updateOrderProduct({
188
177
  product_id: (orderProduct == null ? void 0 : orderProduct.product_id) ?? null,
189
178
  product_variant_id: productVariantId,
179
+ identity_key: existedIdentityKey,
190
180
  updates: {
191
181
  num: normalizedQuantity,
192
182
  _origin: orderProduct == null ? void 0 : orderProduct._origin
@@ -198,7 +188,7 @@ function Menu(props) {
198
188
  type: "pisell1.productDetail",
199
189
  data: {
200
190
  detail: { ...sourceItem, open_deposit: 1 },
201
- setting: { can_input: true, item_max_length: 1, is_detail_open: true }
191
+ setting: { can_input: true, item_max_length: 1, is_detail_open: false }
202
192
  },
203
193
  callback: async (data) => {
204
194
  if (data == null ? void 0 : data.isCancel) return;
@@ -248,8 +238,5 @@ function Menu(props) {
248
238
  cartElementId: "#scan-order-v2-cart-btn"
249
239
  }
250
240
  );
251
- if (isMobileView) {
252
- return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-menu pisell-scan-menu-mobile" }, productSelectNode);
253
- }
254
241
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-menu" }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellScrollView, { height, overflow: "y", ref: scrollRef }, productSelectNode));
255
242
  }
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import '../../../booking/components/voucher/index.less';
3
+ import '../../../appointmentBooking/components/Voucher/index.less';
4
+ /**
5
+ * VoucherCard -- 优惠券/Promotion 区块
6
+ * 嵌入购物车底部,提供券列表展示、勾选、扫码兑码、未登录引导等能力
7
+ */
8
+ export default function VoucherCard(): JSX.Element;
@@ -0,0 +1,162 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/scanOrder/components/Voucher/index.tsx
30
+ var Voucher_exports = {};
31
+ __export(Voucher_exports, {
32
+ default: () => VoucherCard
33
+ });
34
+ module.exports = __toCommonJS(Voucher_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_ChevronDown = __toESM(require("@pisell/icon/es/ChevronDown"));
37
+ var import_UserCircle = __toESM(require("@pisell/icon/es/UserCircle"));
38
+ var import_classnames = __toESM(require("classnames"));
39
+ var import_antd = require("antd");
40
+ var import_utils = require("@pisell/utils");
41
+ var import_materials = require("@pisell/materials");
42
+ var import_context = require("../../context");
43
+ var import_hooks = require("../../hooks");
44
+ var import_voucher = require("../../../booking/components/voucher/index.less");
45
+ var import_Voucher = require("../../../appointmentBooking/components/Voucher/index.less");
46
+ function VoucherCard() {
47
+ const {
48
+ discountList,
49
+ runModuleAction,
50
+ refreshViewModel,
51
+ scanOrderModule
52
+ } = (0, import_context.useScanOrderContext)();
53
+ const { isLogin, openLoginModal } = (0, import_hooks.useScanOrderLogin)();
54
+ const [showDetail, setShowDetail] = (0, import_react.useState)(true);
55
+ const [code, setCode] = (0, import_react.useState)("");
56
+ const availableData = (0, import_react.useMemo)(() => {
57
+ return (discountList || []).filter((item) => !!item.isAvailable).map((discount) => ({
58
+ ...discount,
59
+ isDisabled: discount.isDisabled || discount.isDisabledForProductUsed
60
+ }));
61
+ }, [discountList]);
62
+ const syncAfterDiscountChange = (0, import_react.useCallback)(async () => {
63
+ await refreshViewModel();
64
+ }, [refreshViewModel]);
65
+ const onScanCode = (0, import_react.useCallback)(async () => {
66
+ var _a;
67
+ if (!code.trim()) return;
68
+ try {
69
+ const tempOrder = (_a = scanOrderModule == null ? void 0 : scanOrderModule.getTempOrder) == null ? void 0 : _a.call(scanOrderModule);
70
+ const customerId = (tempOrder == null ? void 0 : tempOrder.customer_id) || void 0;
71
+ const result = await runModuleAction("scanCode", code, customerId);
72
+ if (result == null ? void 0 : result.isAvailable) {
73
+ setCode("");
74
+ await syncAfterDiscountChange();
75
+ } else {
76
+ const content = {
77
+ time_limit: import_utils.locales.getText("pisell2.text.goodpass.code-invalid-expired")
78
+ };
79
+ import_antd.message.error({
80
+ content: String(
81
+ (result == null ? void 0 : result.type) === "server" ? import_utils.locales.getText("pisell2.text.goodpass.code-invalid") : content[result == null ? void 0 : result.unavailableReason] || import_utils.locales.getText("pisell2.text.goodpass.code-invalid-cart")
82
+ )
83
+ });
84
+ }
85
+ } catch (error) {
86
+ console.warn("[scanOrder] scanCode failed", error);
87
+ import_antd.message.error({
88
+ content: String(
89
+ import_utils.locales.getText("pisell2.text.goodpass.code-invalid") || "兑换码无效"
90
+ )
91
+ });
92
+ }
93
+ }, [code, scanOrderModule, runModuleAction, syncAfterDiscountChange]);
94
+ const onDiscountChange = (0, import_react.useCallback)(
95
+ async (val) => {
96
+ try {
97
+ await runModuleAction("setDiscountSelected", {
98
+ discountId: val.id,
99
+ isSelected: val.isSelected
100
+ });
101
+ await syncAfterDiscountChange();
102
+ } catch (error) {
103
+ console.warn("[scanOrder] setDiscountSelected failed", error);
104
+ }
105
+ },
106
+ [runModuleAction, syncAfterDiscountChange]
107
+ );
108
+ const mixedSort = (0, import_react.useCallback)((val) => {
109
+ return [...val].sort((a, b) => Number(b == null ? void 0 : b.isSelected) - Number(a == null ? void 0 : a.isSelected));
110
+ }, []);
111
+ const renderLoginCard = () => {
112
+ if (isLogin) return null;
113
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "login-card" }, /* @__PURE__ */ import_react.default.createElement(import_UserCircle.default, { style: { fontSize: 28 } }), /* @__PURE__ */ import_react.default.createElement("div", { className: "text-wrapper", style: { maxWidth: "none" } }, /* @__PURE__ */ import_react.default.createElement(
114
+ import_materials.PisellText,
115
+ {
116
+ className: "login-btn",
117
+ onClick: () => {
118
+ openLoginModal({
119
+ callback: () => {
120
+ }
121
+ });
122
+ }
123
+ },
124
+ import_utils.locales.getText("pisell2.text.goodpass.login")
125
+ ), " ", /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell2.text.goodpass.login-tip"))));
126
+ };
127
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__appointment-booking-voucher-container", style: { marginTop: "10px" } }, /* @__PURE__ */ import_react.default.createElement("div", { className: "voucher-title" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "voucher-title-left" }, import_utils.locales.getText("pisell2.text.goodpass")), /* @__PURE__ */ import_react.default.createElement(
128
+ "span",
129
+ {
130
+ className: "voucher-title-right",
131
+ onClick: () => setShowDetail(!showDetail)
132
+ },
133
+ import_utils.locales.getText("pisell2.text.details"),
134
+ " ",
135
+ /* @__PURE__ */ import_react.default.createElement(
136
+ import_ChevronDown.default,
137
+ {
138
+ className: (0, import_classnames.default)("voucher-right-icon", { show: showDetail })
139
+ }
140
+ )
141
+ )), /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)("voucher-detail", { show: showDetail }) }, availableData.length > 0 ? /* @__PURE__ */ import_react.default.createElement(
142
+ import_materials.PisellGoodPassCard,
143
+ {
144
+ style: { width: "100%" },
145
+ dataSource: availableData,
146
+ mixedSort,
147
+ onChange: onDiscountChange
148
+ }
149
+ ) : null, renderLoginCard(), /* @__PURE__ */ import_react.default.createElement("div", { className: "voucher-code-input-wrapper" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "voucher-code-input" }, /* @__PURE__ */ import_react.default.createElement("div", { style: { whiteSpace: "nowrap" } }, import_utils.locales.getText("pisell2.text.goodpass.code"), ":"), /* @__PURE__ */ import_react.default.createElement(
150
+ import_materials.PisellInput,
151
+ {
152
+ value: code,
153
+ allowClear: true,
154
+ onChange: (e) => {
155
+ var _a;
156
+ return setCode(((_a = e.target) == null ? void 0 : _a.value) || "");
157
+ },
158
+ size: "small",
159
+ placeholder: import_utils.locales.getText("pisell2.text.goodpass.enter-code")
160
+ }
161
+ )), /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { size: "small", onClick: onScanCode, disabled: !code.trim() }, import_utils.locales.getText("pisell2.text.apply")))));
162
+ }