@pisell/private-materials 6.12.405 → 6.12.406

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 (61) 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/meta.js +1 -1
  5. package/build/lowcode/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +2 -2
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +2 -2
  9. package/es/components/appointmentBooking/components/Cart/ContinueButton/index.js +13 -6
  10. package/es/components/appointmentBooking/components/Cart/ContinueButton/index.less +6 -0
  11. package/es/components/appointmentBooking/components/Date/index.js +103 -35
  12. package/es/components/appointmentBooking/components/Services/index.js +123 -58
  13. package/es/components/appointmentBooking/context.js +72 -10
  14. package/es/components/appointmentBooking/hooks.js +227 -172
  15. package/es/components/appointmentBooking/index.js +3 -2
  16. package/es/components/appointmentBooking/locales.js +10 -0
  17. package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +0 -1
  18. package/es/components/bigSale/components/ProductList/index.js +0 -1
  19. package/es/components/bigSale/components/TimeBar/index.js +0 -1
  20. package/es/components/bigSale/dialog.js +0 -1
  21. package/es/components/bigSale/hooks/useBigSaleContext.js +0 -1
  22. package/es/components/bigSale/hooks/useBigSaleProductListConfig.js +1 -0
  23. package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +0 -1
  24. package/es/components/bigSale/index.js +0 -1
  25. package/es/components/bigSale/templates/Kiosk/index.js +0 -1
  26. package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +0 -1
  27. package/es/components/ticketBooking/components/ProductDisplayAdapter/index.js +3 -0
  28. package/es/components/ticketBooking/components/addServiceVariant/addService.js +1 -0
  29. package/es/components/venueBookingSales/catalogPresentation.js +1 -0
  30. package/es/components/venueBookingSales/checkout/useVenueBookingCheckout.js +0 -1
  31. package/es/index.js +0 -2
  32. package/es/plus/multiCurrencySettlement/index.js +1 -1
  33. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  34. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  35. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  36. package/es/plus/saleDetail/Base.js +0 -1
  37. package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +0 -1
  38. package/es/plus/saleDetail/components/DetailActions/PrintAction.js +0 -1
  39. package/es/plus/saleDetail/components/DetailActions/index.js +0 -1
  40. package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +0 -1
  41. package/es/plus/saleDetail/index.js +0 -1
  42. package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +0 -1
  43. package/es/plus/saleDetail/tmpl/B/index.js +0 -1
  44. package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
  45. package/es/plus/salesSdk/utils/bookingDate.js +1 -1
  46. package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
  47. package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
  48. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  49. package/es/pro/Login2.0/index.d.ts +2 -2
  50. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  51. package/lib/components/appointmentBooking/components/Cart/ContinueButton/index.js +13 -6
  52. package/lib/components/appointmentBooking/components/Cart/ContinueButton/index.less +6 -0
  53. package/lib/components/appointmentBooking/components/Date/index.js +102 -34
  54. package/lib/components/appointmentBooking/components/Services/index.js +122 -57
  55. package/lib/components/appointmentBooking/context.js +71 -9
  56. package/lib/components/appointmentBooking/hooks.js +227 -172
  57. package/lib/components/appointmentBooking/index.js +2 -1
  58. package/lib/components/appointmentBooking/locales.js +10 -0
  59. package/package.json +4 -4
  60. package/es/plus/pisellReservation/index.js +0 -17
  61. package/es/plus/salesSdk/index.js +0 -54
@@ -1,6 +1,8 @@
1
1
  import useEngineContext, { usePisellOS } from "../../hooks/useEngineContext.js";
2
2
  import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
3
3
  import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
4
+ import useInitLocalesOnce from "../../hooks/useInitLocalesOnce.js";
5
+ import locales_default from "./locales.js";
4
6
  import { Toast, checkAndGoNext, checkAndMarkCartRenderError, currentAppointmentBoard, currentRenderLists, formatHolder, getCustomer, getFormInsertBeforeKey, processResourceList } from "./utils.js";
5
7
  import { scrollToFirstErrorCard } from "./components/Resource/utils.js";
6
8
  import { useAppointmentBookingContext } from "./context.js";
@@ -26,9 +28,11 @@ const contextUtils = () => {
26
28
  * @Date: 2025-04-15 11:11
27
29
  */
28
30
  const useAppointmentBookingStep = () => {
29
- var _appointmentBooking$s;
31
+ var _engineContext$engine, _appointmentBooking$s;
32
+ const engineContext = useEngineContext();
33
+ useInitLocalesOnce(locales_default, (engineContext === null || engineContext === void 0 || (_engineContext$engine = engineContext.engine) === null || _engineContext$engine === void 0 || (_engineContext$engine = _engineContext$engine.props) === null || _engineContext$engine === void 0 ? void 0 : _engineContext$engine.locale) || "en");
30
34
  const pisellOS = usePisellOS();
31
- const { appointmentBooking, setCurrentStep, carts, openPolicy, setLoading, setCurrentSelectedResources, currentStepParams, setIsErrorHolder } = useAppointmentBookingContext();
35
+ const { appointmentBooking, setCurrentStep, carts, openPolicy, setLoading, setCurrentSelectedResources, currentStepParams, setIsErrorHolder, runBookingPreparation, bookingPreparationRef, stepTransitionRef, setAvailabilityError } = useAppointmentBookingContext();
32
36
  const { isRetailTemplate } = useAppointmentBookingSetting();
33
37
  const stepList = (appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$s = appointmentBooking.store) === null || _appointmentBooking$s === void 0 || (_appointmentBooking$s = _appointmentBooking$s.step) === null || _appointmentBooking$s === void 0 || (_appointmentBooking$s = _appointmentBooking$s.store) === null || _appointmentBooking$s === void 0 ? void 0 : _appointmentBooking$s.stepList) || [];
34
38
  const { isLogin, openLoginModal } = useAppointmentBookingLogin();
@@ -79,165 +83,216 @@ const useAppointmentBookingStep = () => {
79
83
  isSkip: (step === null || step === void 0 ? void 0 : step.isSkip) || false
80
84
  });
81
85
  };
82
- const nextStep = () => {
83
- var _nextStep$key;
84
- let stepList = appointmentBooking.getStepList() || [];
85
- const currentKey = currentStepParams === null || currentStepParams === void 0 ? void 0 : currentStepParams.key;
86
- const currentSelectedResources = appointmentBooking.getOtherData("current_selected_resources");
87
- if (!isRetailTemplate && currentKey === "select-service") {
88
- var _appointmentBooking$o, _stepList$find;
89
- const { bookingProcess } = (appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$o = appointmentBooking.otherParams) === null || _appointmentBooking$o === void 0 ? void 0 : _appointmentBooking$o.productModuleParams) || {};
90
- const isDateSelectedFirst = bookingProcess === "date_first";
91
- const hasResourceStep = stepList === null || stepList === void 0 ? void 0 : stepList.find((item) => (item === null || item === void 0 ? void 0 : item.key) === "select-resource");
92
- const hasSelectGuestStep = stepList === null || stepList === void 0 || (_stepList$find = stepList.find((item) => (item === null || item === void 0 ? void 0 : item.key) === "select-guest")) === null || _stepList$find === void 0 ? void 0 : _stepList$find.key;
93
- if (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartAllNormalProducts()) {
94
- removeStep("select-resource");
95
- removeStep("select-time");
96
- removeStep("fill-form");
97
- if (!isDateSelectedFirst) removeStep("select-date");
98
- } else if (!hasResourceStep) {
99
- let targetKey = hasSelectGuestStep ? hasSelectGuestStep : "select-service";
100
- if (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartHasDurationProduct()) {
101
- if (!isDateSelectedFirst) {
86
+ const advanceStep = function() {
87
+ var _ref4 = _asyncToGenerator(function* (isCurrent) {
88
+ var _appointmentBooking$g, _nextStep$key;
89
+ const goNext = () => {
90
+ if (isCurrent()) appointmentBooking.next();
91
+ };
92
+ let stepList = appointmentBooking.getStepList() || [];
93
+ const currentKey = (_appointmentBooking$g = appointmentBooking.getCurrentStep()) === null || _appointmentBooking$g === void 0 || (_appointmentBooking$g = _appointmentBooking$g.step) === null || _appointmentBooking$g === void 0 ? void 0 : _appointmentBooking$g.key;
94
+ const currentSelectedResources = appointmentBooking.getOtherData("current_selected_resources");
95
+ if (!isRetailTemplate && currentKey === "select-service") {
96
+ var _appointmentBooking$o, _stepList$find;
97
+ const { bookingProcess } = (appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$o = appointmentBooking.otherParams) === null || _appointmentBooking$o === void 0 ? void 0 : _appointmentBooking$o.productModuleParams) || {};
98
+ const isDateSelectedFirst = bookingProcess === "date_first";
99
+ const hasResourceStep = stepList === null || stepList === void 0 ? void 0 : stepList.find((item) => (item === null || item === void 0 ? void 0 : item.key) === "select-resource");
100
+ const hasSelectGuestStep = stepList === null || stepList === void 0 || (_stepList$find = stepList.find((item) => (item === null || item === void 0 ? void 0 : item.key) === "select-guest")) === null || _stepList$find === void 0 ? void 0 : _stepList$find.key;
101
+ if (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartAllNormalProducts()) {
102
+ removeStep("select-resource");
103
+ removeStep("select-time");
104
+ removeStep("fill-form");
105
+ if (!isDateSelectedFirst) removeStep("select-date");
106
+ } else if (!hasResourceStep) {
107
+ let targetKey = hasSelectGuestStep ? hasSelectGuestStep : "select-service";
108
+ if (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartHasDurationProduct()) {
109
+ if (!isDateSelectedFirst) {
110
+ appointmentBooking.addStep({
111
+ key: "select-date",
112
+ description: locales.getText("pisell2.appointment.select.date")
113
+ }, targetKey);
114
+ targetKey = "select-date";
115
+ }
102
116
  appointmentBooking.addStep({
103
- key: "select-date",
104
- description: locales.getText("pisell2.appointment.select.date")
117
+ key: "select-resource",
118
+ description: locales.getText("pisell2.appointment.select.resource")
105
119
  }, targetKey);
106
- targetKey = "select-date";
107
- }
108
- appointmentBooking.addStep({
120
+ targetKey = "select-resource";
121
+ appointmentBooking.addStep({
122
+ key: "select-time",
123
+ description: locales.getText("pisell2.appointment.select.time")
124
+ }, targetKey);
125
+ } else appointmentBooking.addStep({
109
126
  key: "select-resource",
110
127
  description: locales.getText("pisell2.appointment.select.resource")
111
128
  }, targetKey);
112
- targetKey = "select-resource";
113
- appointmentBooking.addStep({
114
- key: "select-time",
115
- description: locales.getText("pisell2.appointment.select.time")
116
- }, targetKey);
117
- } else appointmentBooking.addStep({
118
- key: "select-resource",
119
- description: locales.getText("pisell2.appointment.select.resource")
120
- }, targetKey);
121
- }
122
- stepList = (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.getStepList()) || [];
123
- }
124
- let nextStep = stepList[(currentStepParams === null || currentStepParams === void 0 ? void 0 : currentStepParams.index) + 1];
125
- if (!isRetailTemplate && (nextStep === null || nextStep === void 0 ? void 0 : nextStep.key) === "select-resource") {
126
- if (!appointmentBooking.checkResourceListForDate()) return Toast(locales.getText("pisell2.appointment.unuse.date"));
127
- const capacityResult = appointmentBooking.checkMaxDurationCapacity();
128
- if (!capacityResult.success) {
129
- const getMessage = locales.getText("pisell2.appointment.unuse.capacity");
130
- return Toast(typeof getMessage === "function" ? getMessage(capacityResult.minAvailableCount) : getMessage);
129
+ }
130
+ stepList = (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.getStepList()) || [];
131
131
  }
132
- }
133
- if (!isRetailTemplate && (currentKey === null || currentKey === void 0 ? void 0 : currentKey.startsWith("select-resource"))) {
134
- var _currentSelectedResou;
135
- const { hasError, updatedCartList } = checkAndMarkCartRenderError(currentSelectedResources, appointmentBooking, utils);
136
- if (hasError) {
137
- setCurrentSelectedResources(updatedCartList);
138
- scrollToFirstErrorCard();
139
- return;
132
+ const stepIndex = stepList.findIndex((step) => step.key === currentKey);
133
+ let nextStep = stepList[stepIndex + 1];
134
+ if (!isRetailTemplate && (nextStep === null || nextStep === void 0 ? void 0 : nextStep.key) === "select-resource") {
135
+ yield appointmentBooking.prepareResourcesForCurrentSelection();
136
+ if (!isCurrent()) return;
137
+ if (!appointmentBooking.checkResourceListForDate()) return Toast(locales.getText("pisell2.appointment.unuse.date"));
138
+ const capacityResult = appointmentBooking.checkMaxDurationCapacity();
139
+ if (!capacityResult.success) {
140
+ const getMessage = locales.getText("pisell2.appointment.unuse.capacity");
141
+ return Toast(typeof getMessage === "function" ? getMessage(capacityResult.minAvailableCount) : getMessage);
142
+ }
140
143
  }
141
- let preKey = "";
142
- currentSelectedResources === null || currentSelectedResources === void 0 || currentSelectedResources.forEach((cart) => {
143
- var _selectedResource$ren, _selectedResource$ren2;
144
- const selectedResource = cart === null || cart === void 0 ? void 0 : cart.currentSelectedResource;
145
- const resourceItem = (selectedResource === null || selectedResource === void 0 ? void 0 : selectedResource.resourceItem) || {};
146
- const formId = selectedResource === null || selectedResource === void 0 || (_selectedResource$ren = selectedResource.renderItem) === null || _selectedResource$ren === void 0 ? void 0 : _selectedResource$ren.resource_form_id;
147
- const policyId = selectedResource === null || selectedResource === void 0 || (_selectedResource$ren2 = selectedResource.renderItem) === null || _selectedResource$ren2 === void 0 ? void 0 : _selectedResource$ren2.policy_id;
148
- const formKey = `fill-form_@${resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.form_id}-${resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.code}-${cart === null || cart === void 0 ? void 0 : cart._id}-${formId}-${policyId}`;
149
- if (formId) {
150
- const description = locales.getText("pisell2.appointment.fill-form");
151
- const beforeKey = getFormInsertBeforeKey(currentKey, stepList);
152
- appointmentBooking.addStep({
153
- key: formKey,
154
- description
155
- }, preKey || beforeKey);
156
- preKey = formKey;
157
- } else appointmentBooking.removeStep(formKey);
158
- });
159
- stepList = appointmentBooking.getStepList();
160
- const selectedResource = currentSelectedResources === null || currentSelectedResources === void 0 || (_currentSelectedResou = currentSelectedResources[0]) === null || _currentSelectedResou === void 0 ? void 0 : _currentSelectedResou.currentSelectedResource;
161
- if (selectedResource) {
162
- var _selectedResource$res;
163
- const originRenderLists = (selectedResource === null || selectedResource === void 0 || (_selectedResource$res = selectedResource.resourceItem) === null || _selectedResource$res === void 0 ? void 0 : _selectedResource$res.originRenderLists) || [];
164
- const currentResourceIndex = originRenderLists === null || originRenderLists === void 0 ? void 0 : originRenderLists.findIndex((item) => {
165
- var _selectedResource$ren3;
166
- return item.id === (selectedResource === null || selectedResource === void 0 || (_selectedResource$ren3 = selectedResource.renderItem) === null || _selectedResource$ren3 === void 0 ? void 0 : _selectedResource$ren3.form_id);
144
+ if (!isRetailTemplate && (currentKey === null || currentKey === void 0 ? void 0 : currentKey.startsWith("select-resource"))) {
145
+ var _currentSelectedResou;
146
+ const { hasError, updatedCartList } = checkAndMarkCartRenderError(currentSelectedResources, appointmentBooking, utils);
147
+ if (hasError) {
148
+ setCurrentSelectedResources(updatedCartList);
149
+ scrollToFirstErrorCard();
150
+ return;
151
+ }
152
+ let preKey = "";
153
+ currentSelectedResources === null || currentSelectedResources === void 0 || currentSelectedResources.forEach((cart) => {
154
+ var _selectedResource$ren, _selectedResource$ren2;
155
+ const selectedResource = cart === null || cart === void 0 ? void 0 : cart.currentSelectedResource;
156
+ const resourceItem = (selectedResource === null || selectedResource === void 0 ? void 0 : selectedResource.resourceItem) || {};
157
+ const formId = selectedResource === null || selectedResource === void 0 || (_selectedResource$ren = selectedResource.renderItem) === null || _selectedResource$ren === void 0 ? void 0 : _selectedResource$ren.resource_form_id;
158
+ const policyId = selectedResource === null || selectedResource === void 0 || (_selectedResource$ren2 = selectedResource.renderItem) === null || _selectedResource$ren2 === void 0 ? void 0 : _selectedResource$ren2.policy_id;
159
+ const formKey = `fill-form_@${resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.form_id}-${resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.code}-${cart === null || cart === void 0 ? void 0 : cart._id}-${formId}-${policyId}`;
160
+ if (formId) {
161
+ const description = locales.getText("pisell2.appointment.fill-form");
162
+ const beforeKey = getFormInsertBeforeKey(currentKey, stepList);
163
+ appointmentBooking.addStep({
164
+ key: formKey,
165
+ description
166
+ }, preKey || beforeKey);
167
+ preKey = formKey;
168
+ } else appointmentBooking.removeStep(formKey);
167
169
  });
168
- const nextResource = originRenderLists === null || originRenderLists === void 0 ? void 0 : originRenderLists[currentResourceIndex + 1];
169
- const resourceKey = `select-resource_@${nextResource === null || nextResource === void 0 ? void 0 : nextResource.form_id}-${nextResource === null || nextResource === void 0 ? void 0 : nextResource.code}`;
170
- if (nextResource) {
171
- var _stepList;
172
- const beforeKey = (_stepList = stepList[stepList.length - 2]) === null || _stepList === void 0 ? void 0 : _stepList.key;
173
- appointmentBooking.addStep({
174
- key: resourceKey,
175
- description: ""
176
- }, beforeKey);
177
- } else appointmentBooking.removeStep(resourceKey);
170
+ stepList = appointmentBooking.getStepList();
171
+ const selectedResource = currentSelectedResources === null || currentSelectedResources === void 0 || (_currentSelectedResou = currentSelectedResources[0]) === null || _currentSelectedResou === void 0 ? void 0 : _currentSelectedResou.currentSelectedResource;
172
+ if (selectedResource) {
173
+ var _selectedResource$res;
174
+ const originRenderLists = (selectedResource === null || selectedResource === void 0 || (_selectedResource$res = selectedResource.resourceItem) === null || _selectedResource$res === void 0 ? void 0 : _selectedResource$res.originRenderLists) || [];
175
+ const currentResourceIndex = originRenderLists === null || originRenderLists === void 0 ? void 0 : originRenderLists.findIndex((item) => {
176
+ var _selectedResource$ren3;
177
+ return item.id === (selectedResource === null || selectedResource === void 0 || (_selectedResource$ren3 = selectedResource.renderItem) === null || _selectedResource$ren3 === void 0 ? void 0 : _selectedResource$ren3.form_id);
178
+ });
179
+ const nextResource = originRenderLists === null || originRenderLists === void 0 ? void 0 : originRenderLists[currentResourceIndex + 1];
180
+ const resourceKey = `select-resource_@${nextResource === null || nextResource === void 0 ? void 0 : nextResource.form_id}-${nextResource === null || nextResource === void 0 ? void 0 : nextResource.code}`;
181
+ if (nextResource) {
182
+ var _stepList;
183
+ const beforeKey = (_stepList = stepList[stepList.length - 2]) === null || _stepList === void 0 ? void 0 : _stepList.key;
184
+ appointmentBooking.addStep({
185
+ key: resourceKey,
186
+ description: ""
187
+ }, beforeKey);
188
+ } else appointmentBooking.removeStep(resourceKey);
189
+ }
178
190
  }
179
- }
180
- stepList = appointmentBooking.getStepList();
181
- nextStep = stepList[(currentStepParams === null || currentStepParams === void 0 ? void 0 : currentStepParams.index) + 1];
182
- if ((nextStep === null || nextStep === void 0 || (_nextStep$key = nextStep.key) === null || _nextStep$key === void 0 ? void 0 : _nextStep$key.startsWith("select-resource_")) || (nextStep === null || nextStep === void 0 ? void 0 : nextStep.key) === "confirm-information") {
183
- var _currentSelectedResou2;
184
- const selectedResource = (currentSelectedResources === null || currentSelectedResources === void 0 || (_currentSelectedResou2 = currentSelectedResources[0]) === null || _currentSelectedResou2 === void 0 ? void 0 : _currentSelectedResou2.currentSelectedResource) || {};
185
- const renderItem = (selectedResource === null || selectedResource === void 0 ? void 0 : selectedResource.renderItem) || {};
186
- const checkHolder = function() {
187
- var _ref2 = _asyncToGenerator(function* (isLoginTrigger = false) {
188
- setLoading(false);
189
- if (isRetailTemplate || (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartAllNormalProducts())) return appointmentBooking.next();
190
- let cartLists = carts || [];
191
- if (!(carts === null || carts === void 0 ? void 0 : carts.length)) cartLists = (yield appointmentBooking.getCart()) || [];
192
- else cartLists = carts || [];
193
- const { hasError, isEnableSkuHolderRule } = checkAndGoNext(isFormSubject, checkAccount, cartLists.filter((n) => !(appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isTargetCartIdNormalProduct(n._id))));
194
- setIsErrorHolder(hasError);
195
- if (hasError) {
196
- scrollToFirstErrorCard(".pisell-lowcode-product-card-select-holder-error");
197
- return;
198
- }
199
- if (isLoginTrigger && isEnableSkuHolderRule) return;
200
- if (!!(renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id)) openPolicy({ id: renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id }, () => {
201
- return appointmentBooking.next();
191
+ stepList = appointmentBooking.getStepList();
192
+ nextStep = stepList[stepList.findIndex((step) => step.key === currentKey) + 1];
193
+ if ((nextStep === null || nextStep === void 0 || (_nextStep$key = nextStep.key) === null || _nextStep$key === void 0 ? void 0 : _nextStep$key.startsWith("select-resource_")) || (nextStep === null || nextStep === void 0 ? void 0 : nextStep.key) === "confirm-information") {
194
+ var _currentSelectedResou2;
195
+ const selectedResource = (currentSelectedResources === null || currentSelectedResources === void 0 || (_currentSelectedResou2 = currentSelectedResources[0]) === null || _currentSelectedResou2 === void 0 ? void 0 : _currentSelectedResou2.currentSelectedResource) || {};
196
+ const renderItem = (selectedResource === null || selectedResource === void 0 ? void 0 : selectedResource.renderItem) || {};
197
+ const checkHolder = function() {
198
+ var _ref2 = _asyncToGenerator(function* (isLoginTrigger = false) {
199
+ if (!isCurrent()) return;
200
+ setLoading(false);
201
+ if (isRetailTemplate || (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartAllNormalProducts())) return goNext();
202
+ let cartLists = carts || [];
203
+ if (!(carts === null || carts === void 0 ? void 0 : carts.length)) {
204
+ const newCarts = yield appointmentBooking.getCart();
205
+ if (!isCurrent()) return;
206
+ cartLists = newCarts || [];
207
+ } else cartLists = carts || [];
208
+ const { hasError, isEnableSkuHolderRule } = checkAndGoNext(isFormSubject, checkAccount, cartLists.filter((n) => !(appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isTargetCartIdNormalProduct(n._id))));
209
+ setIsErrorHolder(hasError);
210
+ if (hasError) {
211
+ scrollToFirstErrorCard(".pisell-lowcode-product-card-select-holder-error");
212
+ return;
213
+ }
214
+ if (isLoginTrigger && isEnableSkuHolderRule) return;
215
+ if (!!(renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id)) openPolicy({ id: renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id }, () => {
216
+ return goNext();
217
+ });
218
+ else return goNext();
202
219
  });
203
- else return appointmentBooking.next();
204
- });
205
- return function checkHolder() {
206
- return _ref2.apply(this, arguments);
207
- };
208
- }();
209
- const checkLogin = function() {
210
- var _ref3 = _asyncToGenerator(function* () {
211
- if (!isLogin()) {
212
- const { pubsub } = utils;
213
- pubsub.once("pisell1.login.success", (res) => {
214
- if (res === "success") {
215
- if (isFormSubject && !isRetailTemplate && !(appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartAllNormalProducts())) {
216
- var _appointmentBooking$r;
217
- const customer = getCustomer(utils);
218
- appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$r = appointmentBooking.refreshAllHolderFormRecords) === null || _appointmentBooking$r === void 0 || _appointmentBooking$r.call(appointmentBooking, { customer_id: customer === null || customer === void 0 ? void 0 : customer.id });
220
+ return function checkHolder() {
221
+ return _ref2.apply(this, arguments);
222
+ };
223
+ }();
224
+ const checkLogin = function() {
225
+ var _ref3 = _asyncToGenerator(function* () {
226
+ if (!isLogin()) {
227
+ const { pubsub } = utils;
228
+ pubsub.once("pisell1.login.success", (res) => {
229
+ if (!isCurrent()) return;
230
+ if (res === "success") {
231
+ if (isFormSubject && !isRetailTemplate && !(appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.isCartAllNormalProducts())) {
232
+ var _appointmentBooking$r;
233
+ const customer = getCustomer(utils);
234
+ appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$r = appointmentBooking.refreshAllHolderFormRecords) === null || _appointmentBooking$r === void 0 || _appointmentBooking$r.call(appointmentBooking, { customer_id: customer === null || customer === void 0 ? void 0 : customer.id });
235
+ }
236
+ checkHolder(true);
219
237
  }
220
- checkHolder(true);
221
- }
222
- if (res === "close") setLoading(false);
223
- });
224
- return openLoginModal({ callback: (status) => {} });
225
- } else return checkHolder();
226
- });
227
- return function checkLogin() {
228
- return _ref3.apply(this, arguments);
229
- };
230
- }();
231
- if ((nextStep === null || nextStep === void 0 ? void 0 : nextStep.key) !== "confirm-information") {
232
- if (!(renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id)) return appointmentBooking.next();
233
- return openPolicy({ id: renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id }, () => {
234
- const cartItem = carts === null || carts === void 0 ? void 0 : carts[0];
235
- appointmentBooking.updateCart(_objectSpread2({ _id: cartItem === null || cartItem === void 0 ? void 0 : cartItem._id }, cartItem));
236
- appointmentBooking.next();
237
- });
238
- } else return checkLogin();
239
- }
240
- appointmentBooking.next();
238
+ if (res === "close") setLoading(false);
239
+ });
240
+ return openLoginModal({ callback: (status) => {} });
241
+ } else return checkHolder();
242
+ });
243
+ return function checkLogin() {
244
+ return _ref3.apply(this, arguments);
245
+ };
246
+ }();
247
+ if ((nextStep === null || nextStep === void 0 ? void 0 : nextStep.key) !== "confirm-information") {
248
+ if (!(renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id)) return goNext();
249
+ return openPolicy({ id: renderItem === null || renderItem === void 0 ? void 0 : renderItem.policy_id }, () => {
250
+ if (!isCurrent()) return;
251
+ const cartItem = carts === null || carts === void 0 ? void 0 : carts[0];
252
+ appointmentBooking.updateCart(_objectSpread2({ _id: cartItem === null || cartItem === void 0 ? void 0 : cartItem._id }, cartItem));
253
+ goNext();
254
+ });
255
+ } else return checkLogin();
256
+ }
257
+ goNext();
258
+ });
259
+ return function advanceStep(_x2) {
260
+ return _ref4.apply(this, arguments);
261
+ };
262
+ }();
263
+ const nextStep = () => {
264
+ var _appointmentBooking$g2;
265
+ const transition = stepTransitionRef.current;
266
+ const sourceKey = (_appointmentBooking$g2 = appointmentBooking.getCurrentStep()) === null || _appointmentBooking$g2 === void 0 || (_appointmentBooking$g2 = _appointmentBooking$g2.step) === null || _appointmentBooking$g2 === void 0 ? void 0 : _appointmentBooking$g2.key;
267
+ const selectionKey = appointmentBooking.getBookingSelectionKey();
268
+ if (transition.pending && transition.module === appointmentBooking && transition.sourceKey === sourceKey && transition.selectionKey === selectionKey) return transition.pending;
269
+ const generation = ++transition.generation;
270
+ transition.sourceKey = sourceKey;
271
+ transition.selectionKey = selectionKey;
272
+ transition.module = appointmentBooking;
273
+ const isCurrent = () => {
274
+ var _appointmentBooking$g3;
275
+ return transition.generation === generation && transition.module === appointmentBooking && ((_appointmentBooking$g3 = appointmentBooking.getCurrentStep()) === null || _appointmentBooking$g3 === void 0 || (_appointmentBooking$g3 = _appointmentBooking$g3.step) === null || _appointmentBooking$g3 === void 0 ? void 0 : _appointmentBooking$g3.key) === sourceKey && appointmentBooking.getBookingSelectionKey() === selectionKey;
276
+ };
277
+ setAvailabilityError(false);
278
+ setLoading(true);
279
+ const pending = _asyncToGenerator(function* () {
280
+ try {
281
+ yield runBookingPreparation();
282
+ if (!isCurrent()) return;
283
+ yield advanceStep(isCurrent);
284
+ } catch (error) {
285
+ if (isCurrent() && (error === null || error === void 0 ? void 0 : error.name) !== "AbortError") setAvailabilityError(true);
286
+ } finally {
287
+ if (transition.generation === generation) {
288
+ var _bookingPreparationRe;
289
+ transition.pending = null;
290
+ if (!((_bookingPreparationRe = bookingPreparationRef.current) === null || _bookingPreparationRe === void 0 ? void 0 : _bookingPreparationRe.pending)) setLoading(false);
291
+ }
292
+ }
293
+ })();
294
+ transition.pending = pending;
295
+ return pending;
241
296
  };
242
297
  return {
243
298
  getStepIndex,
@@ -260,7 +315,7 @@ const useAppointmentBookingProduct = () => {
260
315
  const { productModuleParams } = (appointmentBooking === null || appointmentBooking === void 0 ? void 0 : appointmentBooking.otherParams) || {};
261
316
  const { bookingProcess } = productModuleParams || {};
262
317
  const getProducts = function() {
263
- var _ref4 = _asyncToGenerator(function* () {
318
+ var _ref5 = _asyncToGenerator(function* () {
264
319
  if (bookingProcess === "date_first") {
265
320
  var _dates$;
266
321
  const dates = yield appointmentBooking.getDateRange();
@@ -272,16 +327,16 @@ const useAppointmentBookingProduct = () => {
272
327
  return yield appointmentBooking.loadProducts(productModuleParams);
273
328
  });
274
329
  return function getProducts() {
275
- return _ref4.apply(this, arguments);
330
+ return _ref5.apply(this, arguments);
276
331
  };
277
332
  }();
278
333
  return {
279
334
  checkProductType: function() {
280
- var _ref5 = _asyncToGenerator(function* (productId) {
335
+ var _ref6 = _asyncToGenerator(function* (productId) {
281
336
  return yield appointmentBooking.getProductTypeById(productId);
282
337
  });
283
- return function checkProductType(_x2) {
284
- return _ref5.apply(this, arguments);
338
+ return function checkProductType(_x3) {
339
+ return _ref6.apply(this, arguments);
285
340
  };
286
341
  }(),
287
342
  getProducts
@@ -301,7 +356,7 @@ const useAppointmentBookingCart = () => {
301
356
  const { appointmentBooking, setCarts, setSummary, setIsAgreeDepositPolicy } = useAppointmentBookingContext();
302
357
  const { bookingSubject } = (appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$o2 = appointmentBooking.otherParams) === null || _appointmentBooking$o2 === void 0 ? void 0 : _appointmentBooking$o2.productModuleParams) || {};
303
358
  const getCartAndSummary = function() {
304
- var _ref6 = _asyncToGenerator(function* () {
359
+ var _ref7 = _asyncToGenerator(function* () {
305
360
  var _utils$storage;
306
361
  const locale = (utils === null || utils === void 0 || (_utils$storage = utils.storage) === null || _utils$storage === void 0 ? void 0 : _utils$storage.get("umi_locale")) || "en-US";
307
362
  const symbol = (utils === null || utils === void 0 ? void 0 : utils.getSymbolic()) || "$";
@@ -326,7 +381,7 @@ const useAppointmentBookingCart = () => {
326
381
  if (!carts.length) setIsAgreeDepositPolicy(false);
327
382
  });
328
383
  return function getCartAndSummary() {
329
- return _ref6.apply(this, arguments);
384
+ return _ref7.apply(this, arguments);
330
385
  };
331
386
  }();
332
387
  useEffect(() => {
@@ -380,26 +435,26 @@ const useAppointmentBookingAccount = () => {
380
435
  const { bookingSubject } = (appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$o3 = appointmentBooking.otherParams) === null || _appointmentBooking$o3 === void 0 ? void 0 : _appointmentBooking$o3.productModuleParams) || {};
381
436
  const form_id = bookingSubject === null || bookingSubject === void 0 ? void 0 : bookingSubject.form_id;
382
437
  const getAccountLists = function() {
383
- var _ref7 = _asyncToGenerator(function* () {
438
+ var _ref8 = _asyncToGenerator(function* () {
384
439
  setAccountLists((yield appointmentBooking.getAccounts()) || []);
385
440
  });
386
441
  return function getAccountLists() {
387
- return _ref7.apply(this, arguments);
442
+ return _ref8.apply(this, arguments);
388
443
  };
389
444
  }();
390
445
  useEffect(() => {
391
446
  getAccountLists();
392
447
  pisellOS.effects.on("appointmentBooking_accountList:changed", function() {
393
- var _ref8 = _asyncToGenerator(function* (res) {
448
+ var _ref9 = _asyncToGenerator(function* (res) {
394
449
  if (res.path === "accounts") getAccountLists();
395
450
  });
396
- return function(_x3) {
397
- return _ref8.apply(this, arguments);
451
+ return function(_x4) {
452
+ return _ref9.apply(this, arguments);
398
453
  };
399
454
  }());
400
455
  }, []);
401
456
  const getHolders = function() {
402
- var _ref9 = _asyncToGenerator(function* () {
457
+ var _ref10 = _asyncToGenerator(function* () {
403
458
  var _utils$getStore$getSt, _appointmentBooking$r2;
404
459
  const shop_id = (_utils$getStore$getSt = utils.getStore().getState()) === null || _utils$getStore$getSt === void 0 || (_utils$getStore$getSt = _utils$getStore$getSt.global) === null || _utils$getStore$getSt === void 0 || (_utils$getStore$getSt = _utils$getStore$getSt.shop) === null || _utils$getStore$getSt === void 0 ? void 0 : _utils$getStore$getSt.id;
405
460
  const customer = getCustomer(utils);
@@ -425,19 +480,19 @@ const useAppointmentBookingAccount = () => {
425
480
  })) || [];
426
481
  });
427
482
  return function getHolders() {
428
- return _ref9.apply(this, arguments);
483
+ return _ref10.apply(this, arguments);
429
484
  };
430
485
  }();
431
486
  const addAccount = function() {
432
- var _ref10 = _asyncToGenerator(function* (val, type) {
487
+ var _ref11 = _asyncToGenerator(function* (val, type) {
433
488
  const customer = getCustomer(utils);
434
489
  return yield appointmentBooking.addAccount(val, {
435
490
  type,
436
491
  customerId: customer === null || customer === void 0 ? void 0 : customer.id
437
492
  });
438
493
  });
439
- return function addAccount(_x4, _x5) {
440
- return _ref10.apply(this, arguments);
494
+ return function addAccount(_x5, _x6) {
495
+ return _ref11.apply(this, arguments);
441
496
  };
442
497
  }();
443
498
  const checkAccount = (type) => {
@@ -471,7 +526,7 @@ const useAppointmentBookingResource = () => {
471
526
  };
472
527
  return {
473
528
  getResourceTimeSlot: function() {
474
- var _ref11 = _asyncToGenerator(function* (index) {
529
+ var _ref12 = _asyncToGenerator(function* (index) {
475
530
  var _appointmentBooking$o4, _basic$service_time;
476
531
  const { resourceCodes } = getResourceList();
477
532
  let split = 10;
@@ -481,8 +536,8 @@ const useAppointmentBookingResource = () => {
481
536
  const code = resourceCodes === null || resourceCodes === void 0 ? void 0 : resourceCodes[index || 0];
482
537
  setTimes((yield appointmentBooking.getTimeSlotByAllResources(code, split)) || []);
483
538
  });
484
- return function getResourceTimeSlot(_x6) {
485
- return _ref11.apply(this, arguments);
539
+ return function getResourceTimeSlot(_x7) {
540
+ return _ref12.apply(this, arguments);
486
541
  };
487
542
  }(),
488
543
  getResourceList
@@ -502,7 +557,7 @@ const useIsSkipResourceStep = () => {
502
557
  const appointmentBooking = useAppointmentBooking();
503
558
  const { nextStep } = useAppointmentBookingStep();
504
559
  return { checkSkipResourceStep: function() {
505
- var _ref12 = _asyncToGenerator(function* () {
560
+ var _ref13 = _asyncToGenerator(function* () {
506
561
  try {
507
562
  const { resources } = getResourceList();
508
563
  const accountLists = yield appointmentBooking.getAccounts();
@@ -527,7 +582,7 @@ const useIsSkipResourceStep = () => {
527
582
  }
528
583
  });
529
584
  return function checkSkipResourceStep() {
530
- return _ref12.apply(this, arguments);
585
+ return _ref13.apply(this, arguments);
531
586
  };
532
587
  }() };
533
588
  };
@@ -1,17 +1,18 @@
1
1
  import useEngineContext from "../../hooks/useEngineContext.js";
2
+ import useInitLocalesOnce from "../../hooks/useInitLocalesOnce.js";
2
3
  import locales_default from "./locales.js";
3
4
  import { formatCurrentUser } from "./utils.js";
4
5
  import { contextUtils, useAppointmentBooking } from "./hooks.js";
5
6
  import { AppointmentBookingProvider } from "./context.js";
6
7
  import Layout from "./components/Content/index.js";
7
8
  import React, { useEffect, useMemo } from "react";
8
- import { isIpad, isMobile, locales } from "@pisell/utils";
9
+ import { isIpad, isMobile } from "@pisell/utils";
9
10
  import "./index.less";
10
11
  //#region src/components/appointmentBooking/index.tsx
11
12
  const AppointmentBooking = () => {
12
13
  var _context$engine;
13
14
  const context = useEngineContext();
14
- locales.init(locales_default, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
15
+ useInitLocalesOnce(locales_default, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
15
16
  const utils = contextUtils();
16
17
  const appointmentBooking = useAppointmentBooking();
17
18
  const isMobileLayout = useMemo(() => isMobile() && !isIpad(), []);
@@ -1,6 +1,8 @@
1
1
  //#region src/components/appointmentBooking/locales.ts
2
2
  var locales_default = {
3
3
  en: {
4
+ "pisell2.appointment.availability.load.failed": "Unable to load availability. Please try again.",
5
+ "pisell2.appointment.retry": "Retry",
4
6
  "pisell2.event.calendar.limit.unavailable": "Unavailable",
5
7
  "pisell2.event.calendar.limit.sold.out": "Sold out",
6
8
  "pisell2.event.calendar.limit.call.to.book": "Call to book",
@@ -127,6 +129,8 @@ var locales_default = {
127
129
  "pisell2.text.goodpass.limit.max_per_month": "Used this month"
128
130
  },
129
131
  "zh-CN": {
132
+ "pisell2.appointment.availability.load.failed": "暂时无法获取可预约时间,请重试。",
133
+ "pisell2.appointment.retry": "重试",
130
134
  "pisell2.event.calendar.limit.unavailable": "不可预约",
131
135
  "pisell2.event.calendar.limit.sold.out": "已售罄",
132
136
  "pisell2.event.calendar.limit.call.to.book": "请致电预定",
@@ -253,6 +257,8 @@ var locales_default = {
253
257
  "pisell2.text.goodpass.limit.max_per_month": "本月已用"
254
258
  },
255
259
  "zh-HK": {
260
+ "pisell2.appointment.availability.load.failed": "暫時無法取得可預約時間,請重試。",
261
+ "pisell2.appointment.retry": "重試",
256
262
  "pisell2.event.calendar.limit.unavailable": "不可預約",
257
263
  "pisell2.event.calendar.limit.sold.out": "已售罄",
258
264
  "pisell2.event.calendar.limit.call.to.book": "請致電預訂",
@@ -379,6 +385,8 @@ var locales_default = {
379
385
  "pisell2.text.goodpass.limit.max_per_month": "本月已用"
380
386
  },
381
387
  ja: {
388
+ "pisell2.appointment.availability.load.failed": "予約可能な日時を読み込めませんでした。もう一度お試しください。",
389
+ "pisell2.appointment.retry": "再試行",
382
390
  "pisell2.event.calendar.limit.unavailable": "利用不可",
383
391
  "pisell2.event.calendar.limit.sold.out": "売り切れ",
384
392
  "pisell2.event.calendar.limit.call.to.book": "電話で予約",
@@ -504,6 +512,8 @@ var locales_default = {
504
512
  "pisell2.text.goodpass.limit.max_per_month": "今月利用済み"
505
513
  },
506
514
  pt: {
515
+ "pisell2.appointment.availability.load.failed": "Não foi possível carregar a disponibilidade. Tente novamente.",
516
+ "pisell2.appointment.retry": "Tentar novamente",
507
517
  "pisell2.event.calendar.limit.unavailable": "Indisponível",
508
518
  "pisell2.event.calendar.limit.sold.out": "Esgotado",
509
519
  "pisell2.event.calendar.limit.call.to.book": "Ligar para reservar",
@@ -1,6 +1,5 @@
1
1
  import useEngineContext from "../../../../hooks/useEngineContext.js";
2
2
  import { subscribeBookingDateChange } from "../../../../plus/salesSdk/utils/bookingDate.js";
3
- import "../../../../plus/salesSdk/index.js";
4
3
  import dayjs from "dayjs";
5
4
  import { useCallback, useEffect, useState } from "react";
6
5
  //#region src/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.ts
@@ -20,7 +20,6 @@ import { showAddToCartToast } from "../../../../plus/salesSdk/components/showAdd
20
20
  import { mergeBookingsForDisplay } from "../../../../plus/salesSdk/utils/mergeBookingsForDisplay.js";
21
21
  import useSalesSdkGlobalScanHandler from "../../../../plus/salesSdk/hooks/useSalesSdkGlobalScanHandler.js";
22
22
  import { useSalesSdkGlobalScanActivity } from "../../../../plus/salesSdk/context/SalesSdkGlobalScanActivityContext.js";
23
- import "../../../../plus/salesSdk/index.js";
24
23
  import { buildBigSaleProductListPreferencesKey, readBigSaleProductListPreferences, readStoredBigSaleProductListPreferences, removeBigSaleProductListPreferences, resolveBigSaleAutoProductListPreferences, writeBigSaleProductListPreferences } from "../../utils/productListPreferences.js";
25
24
  import { resolveBigSaleProductDisplayConfig, useBigSaleProductListConfig } from "../../hooks/useBigSaleProductListConfig.js";
26
25
  import { showSalesGuardErrorToast } from "../../../../plus/salesSdk/utils/salesGuard.js";