@pisell/private-materials 3.0.201 → 3.0.202

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 (129) 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 +142 -142
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +12 -27
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +18 -33
  11. package/es/components/booking/addons/model.d.ts +1 -1
  12. package/es/components/booking/components/footer/amount.js +5 -4
  13. package/es/components/booking/components/footer/utils.js +49 -29
  14. package/es/components/booking/forms/model.d.ts +1 -1
  15. package/es/components/booking/info/Provider.d.ts +0 -0
  16. package/es/components/booking/info/Provider.js +54 -0
  17. package/es/components/booking/info/clientVariant/vertical/index.js +93 -7
  18. package/es/components/booking/info/main.js +10 -9
  19. package/es/components/booking/info/pet/ChangePetModal/index.js +38 -23
  20. package/es/components/booking/info/service/addService/index.js +70 -99
  21. package/es/components/booking/info/service/addService/utils.d.ts +1 -0
  22. package/es/components/booking/info/service/addService/utils.js +55 -3
  23. package/es/components/booking/info/service/editService/BookingList/index.d.ts +5 -0
  24. package/es/components/booking/info/service/editService/BookingList/index.js +39 -0
  25. package/es/components/booking/info/service/editService/EditTabs/index.d.ts +3 -0
  26. package/es/components/booking/info/service/editService/EditTabs/index.js +35 -0
  27. package/es/components/booking/info/service/editService/index.js +234 -142
  28. package/es/components/booking/info/service/serve.d.ts +10 -0
  29. package/es/components/booking/info/service/serve.js +28 -0
  30. package/es/components/booking/info/service/serviceManager/distributeDiscount.d.ts +11 -0
  31. package/es/components/booking/info/service/serviceManager/distributeDiscount.js +55 -0
  32. package/es/components/booking/info/service/serviceManager/index.d.ts +20 -0
  33. package/es/components/booking/info/service/serviceManager/index.js +277 -0
  34. package/es/components/booking/info/service/serviceManager/utils.d.ts +0 -0
  35. package/es/components/booking/info/service/serviceManager/utils.js +0 -0
  36. package/es/components/booking/info/service2/Group/utils.d.ts +14 -0
  37. package/es/components/booking/info/service2/Group/utils.js +146 -0
  38. package/es/components/booking/info/service2/Lists.js +27 -33
  39. package/es/components/booking/info/service2/index.d.ts +4 -1
  40. package/es/components/booking/info/service2/index.js +5 -6
  41. package/es/components/booking/info/service2/status.js +1 -1
  42. package/es/components/booking/info/service2/utils.d.ts +95 -3
  43. package/es/components/booking/info/service2/utils.js +676 -52
  44. package/es/components/booking/info/utils.d.ts +11 -0
  45. package/es/components/booking/info/utils.js +24 -0
  46. package/es/components/booking/locales.d.ts +6 -0
  47. package/es/components/booking/locales.js +9 -3
  48. package/es/components/booking/model.d.ts +1 -0
  49. package/es/components/booking/notes/index.d.ts +1 -1
  50. package/es/components/booking/notes/model.d.ts +1 -1
  51. package/es/components/booking/payments/index.d.ts +1 -1
  52. package/es/components/booking/payments/model.d.ts +1 -1
  53. package/es/components/booking/utils.js +5 -4
  54. package/es/components/eftpos/hooks.d.ts +4 -4
  55. package/es/components/eftposPay/amount.d.ts +1 -1
  56. package/es/components/eftposPay/component/step/index.d.ts +6 -6
  57. package/es/components/eftposPay/component/step/step.d.ts +4 -4
  58. package/es/components/eftposPay/hooks.d.ts +1 -1
  59. package/es/components/eftposPay/store/index.d.ts +1 -1
  60. package/es/components/eftposPay/tyro/hooks.d.ts +2 -2
  61. package/es/components/eftposPay/windcave/helper.d.ts +1 -1
  62. package/es/components/schedules/index.d.ts +1 -1
  63. package/es/components/schedules/model.d.ts +1 -1
  64. package/es/components/shoppingCart/components/Cart/Product.js +11 -39
  65. package/es/components/shoppingCart/components/Render/index.js +8 -7
  66. package/es/components/shoppingCart/components/SelectHolderModal/index.js +12 -4
  67. package/es/components/shoppingCart/hooks/useClearCart.js +10 -5
  68. package/es/components/shoppingCart/type.d.ts +1 -1
  69. package/es/components/shoppingCart/utils.js +2 -5
  70. package/lib/components/booking/addons/model.d.ts +1 -1
  71. package/lib/components/booking/components/footer/amount.js +4 -3
  72. package/lib/components/booking/components/footer/utils.js +28 -28
  73. package/lib/components/booking/forms/model.d.ts +1 -1
  74. package/lib/components/booking/info/Provider.d.ts +0 -0
  75. package/lib/components/booking/info/Provider.js +0 -0
  76. package/lib/components/booking/info/clientVariant/vertical/index.js +51 -1
  77. package/lib/components/booking/info/main.js +6 -5
  78. package/lib/components/booking/info/pet/ChangePetModal/index.js +33 -23
  79. package/lib/components/booking/info/service/addService/index.js +50 -92
  80. package/lib/components/booking/info/service/addService/utils.d.ts +1 -0
  81. package/lib/components/booking/info/service/addService/utils.js +27 -0
  82. package/lib/components/booking/info/service/editService/BookingList/index.d.ts +5 -0
  83. package/lib/components/booking/info/service/editService/BookingList/index.js +55 -0
  84. package/lib/components/booking/info/service/editService/EditTabs/index.d.ts +3 -0
  85. package/lib/components/booking/info/service/editService/EditTabs/index.js +75 -0
  86. package/lib/components/booking/info/service/editService/index.js +309 -234
  87. package/lib/components/booking/info/service/serve.d.ts +10 -0
  88. package/lib/components/booking/info/service/serve.js +7 -2
  89. package/lib/components/booking/info/service/serviceManager/distributeDiscount.d.ts +11 -0
  90. package/lib/components/booking/info/service/serviceManager/distributeDiscount.js +70 -0
  91. package/lib/components/booking/info/service/serviceManager/index.d.ts +20 -0
  92. package/lib/components/booking/info/service/serviceManager/index.js +207 -0
  93. package/lib/components/booking/info/service/serviceManager/utils.d.ts +0 -0
  94. package/lib/components/booking/info/service/serviceManager/utils.js +0 -0
  95. package/lib/components/booking/info/service2/Group/utils.d.ts +14 -0
  96. package/lib/components/booking/info/service2/Group/utils.js +142 -0
  97. package/lib/components/booking/info/service2/Lists.js +14 -12
  98. package/lib/components/booking/info/service2/index.d.ts +4 -1
  99. package/lib/components/booking/info/service2/index.js +5 -5
  100. package/lib/components/booking/info/service2/status.js +1 -1
  101. package/lib/components/booking/info/service2/utils.d.ts +95 -3
  102. package/lib/components/booking/info/service2/utils.js +401 -48
  103. package/lib/components/booking/info/utils.d.ts +11 -0
  104. package/lib/components/booking/info/utils.js +35 -0
  105. package/lib/components/booking/locales.d.ts +6 -0
  106. package/lib/components/booking/locales.js +9 -3
  107. package/lib/components/booking/model.d.ts +1 -0
  108. package/lib/components/booking/notes/index.d.ts +1 -1
  109. package/lib/components/booking/notes/model.d.ts +1 -1
  110. package/lib/components/booking/payments/index.d.ts +1 -1
  111. package/lib/components/booking/payments/model.d.ts +1 -1
  112. package/lib/components/booking/utils.js +3 -4
  113. package/lib/components/eftpos/hooks.d.ts +4 -4
  114. package/lib/components/eftposPay/amount.d.ts +1 -1
  115. package/lib/components/eftposPay/component/step/index.d.ts +6 -6
  116. package/lib/components/eftposPay/component/step/step.d.ts +4 -4
  117. package/lib/components/eftposPay/hooks.d.ts +1 -1
  118. package/lib/components/eftposPay/store/index.d.ts +1 -1
  119. package/lib/components/eftposPay/tyro/hooks.d.ts +2 -2
  120. package/lib/components/eftposPay/windcave/helper.d.ts +1 -1
  121. package/lib/components/schedules/index.d.ts +1 -1
  122. package/lib/components/schedules/model.d.ts +1 -1
  123. package/lib/components/shoppingCart/components/Cart/Product.js +6 -22
  124. package/lib/components/shoppingCart/components/Render/index.js +6 -10
  125. package/lib/components/shoppingCart/components/SelectHolderModal/index.js +12 -4
  126. package/lib/components/shoppingCart/hooks/useClearCart.js +4 -9
  127. package/lib/components/shoppingCart/type.d.ts +1 -1
  128. package/lib/components/shoppingCart/utils.js +2 -8
  129. package/package.json +3 -3
@@ -68,6 +68,7 @@ var formatProductOption = (option) => {
68
68
  "num": d.num,
69
69
  "option_group_item_id": d.product_option_item_id,
70
70
  "option_group_id": d.option_group_id
71
+ // "add_price": Number(d?.add_price),
71
72
  };
72
73
  });
73
74
  };
@@ -84,6 +85,8 @@ var formatProductBundle = (bundle) => {
84
85
  "num": d.num,
85
86
  "extension_id": d.extension_id,
86
87
  "extension_type": d.extension_type,
88
+ // "price": Number(d?.price),
89
+ // "price_type": d?.price_type,
87
90
  "option": formatProductOption(d.option)
88
91
  };
89
92
  });
@@ -151,6 +154,23 @@ var formatProductPrice = (item) => {
151
154
  }
152
155
  return price;
153
156
  };
157
+ var formatMetaData = (item) => {
158
+ var _a, _b, _c, _d, _e;
159
+ let metadata = {};
160
+ if ((_a = item._extend) == null ? void 0 : _a.capacity) {
161
+ metadata.capacity = item._extend.capacity;
162
+ }
163
+ if (item._extend.groupId) {
164
+ metadata.groupId = item._extend.groupId;
165
+ }
166
+ if ((_b = item._extend) == null ? void 0 : _b.holder_id) {
167
+ metadata.holder_id = (_c = item._extend) == null ? void 0 : _c.holder_id;
168
+ }
169
+ if ((_d = item._extend) == null ? void 0 : _d.multiDayPrices) {
170
+ metadata.multiDayPrices = (_e = item._extend) == null ? void 0 : _e.multiDayPrices;
171
+ }
172
+ return metadata;
173
+ };
154
174
  var formatProducts = (item) => {
155
175
  var _a, _b, _c, _d, _e, _f;
156
176
  const total = Number(item._extend.total);
@@ -172,23 +192,10 @@ var formatProducts = (item) => {
172
192
  "product_bundle": formatProductBundle((_b = (_a = item._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.bundle),
173
193
  "bundle_edit": item._extend.bundle_edit,
174
194
  "product_option_item": formatProductOption((_d = (_c = item._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.option),
175
- "product_variant_id": ((_f = (_e = item._extend) == null ? void 0 : _e.other) == null ? void 0 : _f.product_variant_id) || 0
195
+ "product_variant_id": ((_f = (_e = item._extend) == null ? void 0 : _e.other) == null ? void 0 : _f.product_variant_id) || 0,
196
+ metadata: formatMetaData(item)
176
197
  };
177
198
  };
178
- var formatDayRelationProducts = (data, booking_item) => {
179
- const list = data.service.value;
180
- let relation_products = list == null ? void 0 : list.filter((item) => {
181
- var _a;
182
- const holderId = (_a = item._extend) == null ? void 0 : _a.holder_id;
183
- const bookingHolderId = booking_item._extend.holder_id;
184
- const isAppointment = import_status.appointmentTypes.includes(item.extension_type);
185
- return holderId && holderId === bookingHolderId && !isAppointment;
186
- });
187
- relation_products = relation_products.map((item) => {
188
- return formatProducts(item);
189
- });
190
- return relation_products || [];
191
- };
192
199
  var formatAppointmentProductLists = (data) => {
193
200
  var _a;
194
201
  try {
@@ -206,11 +213,8 @@ var formatAppointmentProductLists = (data) => {
206
213
  }
207
214
  groupMap.get(key).push(item);
208
215
  });
209
- groupMap.forEach((group) => {
210
- group[0].relation_products = formatDayRelationProducts(data, group[0]);
211
- });
212
216
  const result = (_a = Array.from(groupMap.values())) == null ? void 0 : _a.reduce((acc, group) => acc.concat(group), []);
213
- return result || [];
217
+ return list || [];
214
218
  } catch (error) {
215
219
  }
216
220
  };
@@ -225,7 +229,6 @@ var formatBookings = (data, values) => {
225
229
  };
226
230
  const eventOtherParams = data.eventOtherParams;
227
231
  let bookings = [];
228
- console.log(list, "wh_result11");
229
232
  bookings = list.map((item) => {
230
233
  var _a, _b, _c, _d;
231
234
  let start_date = item._extend.startDate.format("YYYY-MM-DD");
@@ -265,9 +268,7 @@ var formatBookings = (data, values) => {
265
268
  "duration": isDay ? 0 : import_utils.flexibleObj.getValue(item._extend.duration),
266
269
  "number": item._extend.capacity ? (0, import_utilsByBooking.getSumCapacity)({ cacheItem: item }) : item._extend.number || 1,
267
270
  "resources": formatResource(item),
268
- "metadata": item._extend.capacity ? {
269
- capacity: item._extend.capacity
270
- } : void 0,
271
+ "metadata": formatMetaData(item),
271
272
  ...eventOtherParams || {},
272
273
  ...dayParams
273
274
  };
@@ -277,15 +278,12 @@ var formatBookings = (data, values) => {
277
278
  var formatRelationProducts = (data) => {
278
279
  var _a;
279
280
  let list = ((_a = data.service) == null ? void 0 : _a.value) || [];
280
- list = list.filter((item) => {
281
- var _a2;
282
- return !((_a2 = item._extend) == null ? void 0 : _a2.holder_id);
283
- });
281
+ list = list.filter((item) => !import_status.appointmentTypes.includes(item.extension_type));
284
282
  let relationProducts = [];
285
283
  relationProducts = list.map((item) => {
286
284
  return formatProducts(item);
287
285
  });
288
- return relationProducts;
286
+ return relationProducts || [];
289
287
  };
290
288
  var formatHolder = (state, values) => {
291
289
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -345,7 +343,9 @@ var formatValues = (state) => {
345
343
  }
346
344
  if (isDay) {
347
345
  values.metadata.is_multiday_appointment = 1;
346
+ values.is_bundle_price_calculated = 1;
348
347
  }
348
+ debugger;
349
349
  return values;
350
350
  };
351
351
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { FormState } from "../model";
3
- export declare const Provider: (ComponentUi: any) => (props: any) => any, Context: import("react").Context<{
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
4
  state: FormState;
5
5
  } & {
6
6
  dispatch: (params: {
File without changes
File without changes
@@ -49,6 +49,7 @@ var import_utils2 = require("../../utils");
49
49
  var import_utils3 = require("../../../utils");
50
50
  var import_utils4 = require("../../service2/utils");
51
51
  var import_ChangePetModal = __toESM(require("../../pet/ChangePetModal"));
52
+ var import_model = require("../../model");
52
53
  var VerticalClient = (0, import_react.forwardRef)((props, ref) => {
53
54
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
54
55
  const { globalState, setGlobalState } = props;
@@ -364,6 +365,55 @@ var VerticalClient = (0, import_react.forwardRef)((props, ref) => {
364
365
  setSearch: (_b2 = modalRef.current) == null ? void 0 : _b2.setSearch
365
366
  };
366
367
  });
368
+ const isOpenDeleteProduct = (0, import_react.useMemo)(() => {
369
+ if (!(0, import_utils4.isDayBooking)(state))
370
+ return false;
371
+ const pets = (0, import_utils4.getPets)(state);
372
+ const appointmentServices = (0, import_utils4.getAppointmentService)(state);
373
+ if ((pets == null ? void 0 : pets.length) && (appointmentServices == null ? void 0 : appointmentServices.length)) {
374
+ return true;
375
+ }
376
+ return false;
377
+ }, [state]);
378
+ const _handleSelectClient = async (e) => {
379
+ var _a2, _b2, _c2, _d2, _e2;
380
+ handleSelectClient(e);
381
+ if ((0, import_utils4.isDayBooking)(state)) {
382
+ let _value = (e == null ? void 0 : e[e.length - 1]) || import_model.walkInData;
383
+ if (_value.loading) {
384
+ return;
385
+ }
386
+ if ((0, import_utils4.isDayBooking)(state) && ((_b2 = (_a2 = state == null ? void 0 : state.service) == null ? void 0 : _a2.value) == null ? void 0 : _b2.length) > 0 && ((_c2 = state.client.value) == null ? void 0 : _c2.id) !== (_value == null ? void 0 : _value.id)) {
387
+ const _state = {
388
+ ...state,
389
+ client: {
390
+ ...state.client,
391
+ value: {
392
+ ..._value,
393
+ name: getNickname(_value)
394
+ }
395
+ }
396
+ };
397
+ if (isOpenDeleteProduct) {
398
+ (_e2 = changePetRef.current) == null ? void 0 : _e2.open({
399
+ setGlobalState,
400
+ service: ((_d2 = state.service) == null ? void 0 : _d2.value) || [],
401
+ state,
402
+ source: "changeClient"
403
+ });
404
+ }
405
+ const services = await (0, import_utils4.updateServicePrice)(_state);
406
+ console.log(services, state, _value, isOpenDeleteProduct, "wh98797686");
407
+ setGlobalState({
408
+ service: {
409
+ ...stateRef.current.service,
410
+ value: services,
411
+ edit: true
412
+ }
413
+ });
414
+ }
415
+ }
416
+ };
367
417
  return /* @__PURE__ */ import_react.default.createElement(
368
418
  "div",
369
419
  {
@@ -441,7 +491,7 @@ var VerticalClient = (0, import_react.forwardRef)((props, ref) => {
441
491
  autoFocus: !((_G = (_F = (_E = context == null ? void 0 : context.appHelper) == null ? void 0 : _E.utils) == null ? void 0 : _F.isTerminal) == null ? void 0 : _G.call(_F)),
442
492
  ref: modalRef,
443
493
  onClose: handleClose,
444
- handleSelectClient,
494
+ handleSelectClient: _handleSelectClient,
445
495
  handleCreateItem,
446
496
  childrenValue: state.pet.value,
447
497
  handleSelectPet,
@@ -99,7 +99,8 @@ var Info = (0, import_model.Provider)((props) => {
99
99
  ...globalState,
100
100
  isTerminal: (_g2 = (_f2 = (_e2 = context == null ? void 0 : context.appHelper) == null ? void 0 : _e2.utils) == null ? void 0 : _f2.isTerminal) == null ? void 0 : _g2.call(_f2),
101
101
  isFranchisee,
102
- timezone: (_m = (_l = (_k = (_j = (_i2 = (_h2 = context == null ? void 0 : context.appHelper) == null ? void 0 : _h2.utils) == null ? void 0 : _i2.store) == null ? void 0 : _j.getState()) == null ? void 0 : _k.global) == null ? void 0 : _l.globalConfig) == null ? void 0 : _m.timezone
102
+ timezone: (_m = (_l = (_k = (_j = (_i2 = (_h2 = context == null ? void 0 : context.appHelper) == null ? void 0 : _h2.utils) == null ? void 0 : _i2.store) == null ? void 0 : _j.getState()) == null ? void 0 : _k.global) == null ? void 0 : _l.globalConfig) == null ? void 0 : _m.timezone,
103
+ isDayBooking: (globalState == null ? void 0 : globalState.renderType) === "dayBooking"
103
104
  }
104
105
  });
105
106
  }, [JSON.stringify(globalState)]);
@@ -141,7 +142,10 @@ var Info = (0, import_model.Provider)((props) => {
141
142
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, !!modal.state.setGlobalState ? /* @__PURE__ */ import_react.default.createElement(
142
143
  import_tabPane.default,
143
144
  {
144
- style,
145
+ style: {
146
+ ...style,
147
+ height: ((_h = (_g = context == null ? void 0 : context.appHelper) == null ? void 0 : _g.utils) == null ? void 0 : _h.isMobile) ? "100%" : "100vh"
148
+ },
145
149
  header,
146
150
  footer: /* @__PURE__ */ import_react.default.createElement(
147
151
  import_footer.default,
@@ -151,9 +155,6 @@ var Info = (0, import_model.Provider)((props) => {
151
155
  source: "info"
152
156
  }
153
157
  ),
154
- style: {
155
- height: ((_h = (_g = context == null ? void 0 : context.appHelper) == null ? void 0 : _g.utils) == null ? void 0 : _h.isMobile) ? "100%" : "100vh"
156
- },
157
158
  bodyClassName: (0, import_classnames.default)("booking-info-warp", {
158
159
  ["create-booking-page-info-wrap"]: isBookingCreatePage,
159
160
  ["create-booking-page-info-wrap-create"]: isBookingCreatePageCreateMode && !(0, import_utils3.isTerminalDayBooking)(modal.state)
@@ -47,31 +47,41 @@ var ChangePetModal = (props, ref) => {
47
47
  }
48
48
  }));
49
49
  const handleProduct = (type) => {
50
- const { ids, service, dispatch, setGlobalState, state } = params;
50
+ const { ids, service, dispatch, setGlobalState, state, source } = params;
51
51
  let _service = [...service || []];
52
- if (type === "ok") {
53
- _service = _service == null ? void 0 : _service.map((item) => {
54
- if (ids == null ? void 0 : ids.includes(item._extend.holder_id)) {
55
- return {
56
- ...item,
57
- _extend: {
58
- ...item._extend || {},
59
- holder_id: 0
60
- }
61
- };
62
- }
63
- return item;
64
- });
65
- _service = _service.filter(
66
- (item) => {
67
- var _a;
68
- return !(((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.holder_id) === 0 && import_status.appointmentTypes.includes(item.extension_type));
69
- }
70
- );
52
+ if (source === "changeClient") {
53
+ if (type === "ok") {
54
+ _service = _service == null ? void 0 : _service.filter(
55
+ (item) => !import_status.appointmentTypes.includes(item.extension_type)
56
+ );
57
+ } else {
58
+ _service = [];
59
+ }
71
60
  } else {
72
- _service = _service.filter(
73
- (item) => !ids.includes(item._extend.holder_id)
74
- );
61
+ if (type === "ok") {
62
+ _service = _service == null ? void 0 : _service.map((item) => {
63
+ if (ids == null ? void 0 : ids.includes(item._extend.holder_id)) {
64
+ return {
65
+ ...item,
66
+ _extend: {
67
+ ...item._extend || {},
68
+ holder_id: 0
69
+ }
70
+ };
71
+ }
72
+ return item;
73
+ });
74
+ _service = _service.filter(
75
+ (item) => {
76
+ var _a;
77
+ return !(((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.holder_id) === 0 && import_status.appointmentTypes.includes(item.extension_type));
78
+ }
79
+ );
80
+ } else {
81
+ _service = _service.filter(
82
+ (item) => !ids.includes(item._extend.holder_id)
83
+ );
84
+ }
75
85
  }
76
86
  if (dispatch) {
77
87
  dispatch({
@@ -44,13 +44,13 @@ var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineCon
44
44
  var import_serve = require("../serve");
45
45
  var import_utils = require("../../utils");
46
46
  var import_dateRange = __toESM(require("../../dateRange"));
47
- var import_utils2 = require("./utils");
48
- var import_utils3 = require("../../../utils");
49
- var import_utils4 = require("../../service2/utils");
47
+ var import_utils2 = require("../../../utils");
48
+ var import_utils3 = require("../../service2/utils");
50
49
  var import_status = require("../../service2/status");
51
- var import_utils5 = require("@pisell/utils");
50
+ var import_utils4 = require("@pisell/utils");
52
51
  var import_ahooks = require("ahooks");
53
52
  var import_debounce = __toESM(require("lodash/debounce"));
53
+ var import_serviceManager = require("../serviceManager");
54
54
  var shopList = [
55
55
  2886,
56
56
  4422,
@@ -68,7 +68,7 @@ var shopList = [
68
68
  6305
69
69
  ];
70
70
  var Info = (props) => {
71
- var _a, _b, _c, _d;
71
+ var _a, _b, _c, _d, _e, _f;
72
72
  const { onEdit, drawerProps, renderMode } = props;
73
73
  const [search, setSearch] = (0, import_react.useState)("");
74
74
  let { state, dispatch } = (0, import_react.useContext)(import_model.Context);
@@ -79,9 +79,15 @@ var Info = (props) => {
79
79
  const context = (0, import_useEngineContext.default)();
80
80
  state = state || (props == null ? void 0 : props.state);
81
81
  dispatch = dispatch || (props == null ? void 0 : props.dispatch);
82
- import_utils3.request.setRequest(context.appHelper.utils.request);
82
+ import_utils2.request.setRequest(context.appHelper.utils.request);
83
+ const { createBookingData, createBooking } = (0, import_serviceManager.useService)({
84
+ renderMode,
85
+ onEdit,
86
+ state,
87
+ dispatch
88
+ });
83
89
  const isDay = (0, import_react.useMemo)(() => {
84
- return (0, import_utils4.isDayBooking)(state);
90
+ return (0, import_utils3.isDayBooking)(state);
85
91
  }, [state.renderType]);
86
92
  const handleResize = () => {
87
93
  var _a2;
@@ -99,6 +105,12 @@ var Info = (props) => {
99
105
  window.removeEventListener("resize", debouncedHandleResize);
100
106
  };
101
107
  }, [debouncedHandleResize]);
108
+ const customerId = (0, import_react.useMemo)(() => {
109
+ var _a2, _b2;
110
+ if (!isDay)
111
+ return void 0;
112
+ return ((_b2 = (_a2 = state.client) == null ? void 0 : _a2.value) == null ? void 0 : _b2.id) || 1;
113
+ }, [(_b = (_a = state.client) == null ? void 0 : _a.value) == null ? void 0 : _b.id, isDay]);
102
114
  const setDefaultService = async (list) => {
103
115
  if (state.renderType !== "eventBooking") {
104
116
  return;
@@ -116,7 +128,8 @@ var Info = (props) => {
116
128
  setLoading(true);
117
129
  let product = list[0];
118
130
  const detail = await (0, import_serve.getProductDetail)(product.id, {
119
- schedule_date: state.date.value.format("YYYY-MM-DD")
131
+ schedule_date: state.date.value.format("YYYY-MM-DD"),
132
+ customer_id: customerId
120
133
  });
121
134
  const isBundleOrCombination = (0, import_utils.getIsBundleOrCombination)(detail.data);
122
135
  setLoading(false);
@@ -125,7 +138,7 @@ var Info = (props) => {
125
138
  let _item = {
126
139
  ...product,
127
140
  product_id: product.id,
128
- _id: (0, import_utils5.getUniqueId)(),
141
+ _id: (0, import_utils4.getUniqueId)(),
129
142
  _extend: {
130
143
  start_date: state.date.value,
131
144
  startDate: state.date.value,
@@ -164,6 +177,7 @@ var Info = (props) => {
164
177
  let dayParams = {};
165
178
  if (isDay) {
166
179
  dayParams.extension_type = ["normal", "product_appointment"];
180
+ dayParams.customer_id = customerId;
167
181
  }
168
182
  let data = await state.apis.getServices({
169
183
  skip: 1,
@@ -186,8 +200,8 @@ var Info = (props) => {
186
200
  setLoading(false);
187
201
  let lists = (data == null ? void 0 : data.list) || [];
188
202
  if (isDay) {
189
- const id = (0, import_utils4.holderId)(state);
190
- lists = (0, import_utils4.getDayProducts)(id, lists, state == null ? void 0 : state.isTerminalDayBookingPage);
203
+ const id = (0, import_utils3.holderId)(state);
204
+ lists = (0, import_utils3.getDayProducts)(id, lists, state == null ? void 0 : state.isTerminalDayBookingPage);
191
205
  }
192
206
  if (!state.service.addModal) {
193
207
  setDefaultService(lists);
@@ -219,7 +233,6 @@ var Info = (props) => {
219
233
  if (isDay) {
220
234
  isEject = type === "detail" || item.bundle_group_count > 0 || item.option_group_count > 0 || item.is_variant > 0;
221
235
  }
222
- let lock = false;
223
236
  state.action({
224
237
  type: "pisell1.handleOpenProductModal",
225
238
  data: {
@@ -231,68 +244,14 @@ var Info = (props) => {
231
244
  variant: isDay ? true : false,
232
245
  package: true
233
246
  },
234
- is_eject: isEject ? 1 : 0
247
+ is_eject: isEject ? 1 : 0,
248
+ customer_id: customerId
235
249
  },
236
- callback: (e) => {
237
- var _a2, _b2, _c2, _d2, _e, _f;
238
- if (lock) {
239
- return;
240
- }
241
- lock = true;
242
- setTimeout(() => {
243
- lock = false;
244
- }, 2e3);
245
- let cacheItem = {
246
- ...item,
247
- product_id: item.id,
248
- _id: (0, import_utils5.getUniqueId)(),
249
- _key: e.key,
250
- _extend: {
251
- start_date: state.date.value,
252
- quantity: 1,
253
- price: item.price,
254
- product_name: item.title,
255
- other: JSON.parse(JSON.stringify(e))
256
- },
257
- new: 1
258
- };
259
- if (isDay) {
260
- cacheItem._extend.holder_id = (0, import_utils4.holderId)(state);
261
- cacheItem._extend.end_date = state.date.end_date;
262
- cacheItem._extend.sub_type = "days";
263
- }
264
- let _total = (0, import_utils3.getProductTotalPrice)(cacheItem);
265
- if ((_b2 = (_a2 = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a2.other) == null ? void 0 : _b2.product_variant_id) {
266
- cacheItem._extend.price = Number((_d2 = (_c2 = cacheItem._extend) == null ? void 0 : _c2.other) == null ? void 0 : _d2.price);
267
- }
268
- cacheItem._extend.total = _total;
269
- cacheItem._extend.origin_total = _total;
270
- const _isEdit = !!state.service.cacheItem;
271
- if (_isEdit) {
272
- cacheItem._id = (_e = state.service.cacheItem) == null ? void 0 : _e._id;
273
- cacheItem.new = 0;
274
- }
275
- if (renderMode === "current") {
276
- cacheItem.currentDefaultTime = state.date.value.format("HH:mm");
277
- }
278
- cacheItem._extend = (0, import_utils2.getProductExtend)({ cacheItem, state });
279
- if (isDay && !(0, import_utils4.isAppointment)(item, state)) {
280
- cacheItem.autoClose = !_isEdit;
281
- } else if (state.renderType === "eventBooking") {
282
- cacheItem.autoClose = false;
283
- } else {
284
- cacheItem.autoClose = !_isEdit && (cacheItem._extend.resource || cacheItem._extend.resource === 0 || (((_f = state.service) == null ? void 0 : _f.resourcesOrigin) || []).length === 1);
285
- }
286
- dispatch({
287
- type: "setService",
288
- payload: {
289
- editModal: true,
290
- cacheItem,
291
- addModal: !cacheItem.autoClose,
292
- changeService: false
293
- }
250
+ callback: async (e) => {
251
+ const data = await createBookingData({
252
+ product: { ...item, _params: e }
294
253
  });
295
- onEdit == null ? void 0 : onEdit(cacheItem);
254
+ createBooking({ booking: data });
296
255
  }
297
256
  });
298
257
  }
@@ -301,7 +260,7 @@ var Info = (props) => {
301
260
  var _a2;
302
261
  let _list = ((_a2 = state.service) == null ? void 0 : _a2.services) || [];
303
262
  if (isDay) {
304
- if (!(0, import_utils4.holderId)(state)) {
263
+ if (!(0, import_utils3.holderId)(state)) {
305
264
  _list = _list.filter(
306
265
  (item) => !import_status.appointmentTypes.includes(item.extension_type)
307
266
  );
@@ -310,29 +269,28 @@ var Info = (props) => {
310
269
  const isIncludes = (str) => {
311
270
  return str.toLowerCase().indexOf(search.toLowerCase()) !== -1;
312
271
  };
313
- return (0, import_utils3.formatProductListByCategory)(
272
+ return (0, import_utils2.formatProductListByCategory)(
314
273
  _list,
315
274
  search ? (item) => isIncludes(item.title) : void 0
316
275
  );
317
- }, [search, (_a = state.service) == null ? void 0 : _a.services, state == null ? void 0 : state.activeCartId]);
318
- console.log("state.service.renderList", renderList);
276
+ }, [search, (_c = state.service) == null ? void 0 : _c.services, state == null ? void 0 : state.activeCartId]);
319
277
  const isService = (0, import_react.useMemo)(() => {
320
278
  var _a2, _b2;
321
279
  return ((_b2 = (_a2 = state.service) == null ? void 0 : _a2.value) == null ? void 0 : _b2.length) > 0;
322
280
  }, [state.service.value]);
323
281
  (0, import_react.useEffect)(() => {
324
- var _a2, _b2, _c2, _d2, _e, _f, _g;
282
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g;
325
283
  if (shopList.includes(
326
- (_e = (_d2 = (_c2 = (_b2 = (_a2 = context.appHelper.utils.store) == null ? void 0 : _a2.getState) == null ? void 0 : _b2.call(_a2)) == null ? void 0 : _c2.global) == null ? void 0 : _d2.globalConfig) == null ? void 0 : _e.id
284
+ (_e2 = (_d2 = (_c2 = (_b2 = (_a2 = context.appHelper.utils.store) == null ? void 0 : _a2.getState) == null ? void 0 : _b2.call(_a2)) == null ? void 0 : _c2.global) == null ? void 0 : _d2.globalConfig) == null ? void 0 : _e2.id
327
285
  ) || state.closeAutoOpenService) {
328
286
  return;
329
287
  }
330
- if (state.modalOpen && !state.bookingId && state.renderType !== "eventBooking" && ((_g = (_f = state.service) == null ? void 0 : _f.value) == null ? void 0 : _g.length) === 0) {
288
+ if (state.modalOpen && !state.bookingId && state.renderType !== "eventBooking" && ((_g = (_f2 = state.service) == null ? void 0 : _f2.value) == null ? void 0 : _g.length) === 0) {
331
289
  setTimeout(() => {
332
290
  handleSelectService();
333
291
  }, 10);
334
292
  }
335
- }, [state.modalOpen, state.bookingId, (_b = state.service) == null ? void 0 : _b.value]);
293
+ }, [state.modalOpen, state.bookingId, (_d = state.service) == null ? void 0 : _d.value]);
336
294
  const showAddButton = (0, import_react.useMemo)(() => {
337
295
  return !state.disabledEdit && !state.channelDisabledEdit;
338
296
  }, [state.disabledEdit, state.channelDisabledEdit]);
@@ -369,8 +327,8 @@ var Info = (props) => {
369
327
  {
370
328
  loading,
371
329
  showSub: false,
372
- title: import_utils5.locales.getText("pisell2.text.add-a-service"),
373
- subTitle: import_utils5.locales.getText("pisell2.text.add-another-service"),
330
+ title: import_utils4.locales.getText("pisell2.text.add-a-service"),
331
+ subTitle: import_utils4.locales.getText("pisell2.text.add-another-service"),
374
332
  onClick: handleSelectService
375
333
  }
376
334
  );
@@ -379,8 +337,8 @@ var Info = (props) => {
379
337
  import_addButton.default,
380
338
  {
381
339
  showSub: isService,
382
- title: import_utils5.locales.getText("pisell2.text.add-a-service"),
383
- subTitle: import_utils5.locales.getText("pisell2.text.add-another-service"),
340
+ title: import_utils4.locales.getText("pisell2.text.add-a-service"),
341
+ subTitle: import_utils4.locales.getText("pisell2.text.add-another-service"),
384
342
  onClick: handleSelectService
385
343
  }
386
344
  ) : /* @__PURE__ */ import_react.default.createElement("div", { style: { height: 20 } });
@@ -396,18 +354,18 @@ var Info = (props) => {
396
354
  }, [renderMode]);
397
355
  const colSpan = (0, import_react.useMemo)(() => {
398
356
  const isTerminal = state.isTerminalDayBookingPage;
399
- const showDate = !!(isDay && (0, import_utils4.holderId)(state));
357
+ const showDate = !!(isDay && (0, import_utils3.holderId)(state));
400
358
  return (0, import_status.inputDateCol)(showDate, isTerminal);
401
- }, [state.isTerminalDayBookingPage, isDay, (0, import_utils4.holderId)(state)]);
359
+ }, [state.isTerminalDayBookingPage, isDay, (0, import_utils3.holderId)(state)]);
402
360
  return (0, import_react.useMemo)(() => {
403
361
  var _a2, _b2;
404
- const header = /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-header", ref: headerRef }, /* @__PURE__ */ import_react.default.createElement(import_antd.Row, { gutter: [16, 16] }, isDay && (0, import_utils4.holderId)(state) ? /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { ...colSpan.date }, /* @__PURE__ */ import_react.default.createElement(import_dateRange.default, { state, dispatch })) : null, /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { ...colSpan.input }, /* @__PURE__ */ import_react.default.createElement(
362
+ const header = /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-header", ref: headerRef }, /* @__PURE__ */ import_react.default.createElement(import_antd.Row, { gutter: [16, 16] }, isDay && (0, import_utils3.holderId)(state) ? /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { ...colSpan.date }, /* @__PURE__ */ import_react.default.createElement(import_dateRange.default, { state, dispatch })) : null, /* @__PURE__ */ import_react.default.createElement(import_antd.Col, { ...colSpan.input }, /* @__PURE__ */ import_react.default.createElement(
405
363
  import_antd.Input,
406
364
  {
407
365
  ref: searchRef,
408
366
  prefix: /* @__PURE__ */ import_react.default.createElement(import_SearchLg.default, null),
409
367
  style: { marginTop: 16, height: 44 },
410
- placeholder: import_utils5.locales.getText("pisell2.text.search"),
368
+ placeholder: import_utils4.locales.getText("pisell2.text.search"),
411
369
  allowClear: true,
412
370
  value: search,
413
371
  onChange: (e) => {
@@ -446,7 +404,7 @@ var Info = (props) => {
446
404
  {
447
405
  titleNoWrap: true,
448
406
  open: state.service.addModal && !state.isBookingCreatePage && !state.isTerminalDayBookingPage,
449
- title: isDay ? import_utils5.locales.getText("pisell2.text.select.items") : import_utils5.locales.getText("pisell2.text.select-service"),
407
+ title: isDay ? import_utils4.locales.getText("pisell2.text.select.items") : import_utils4.locales.getText("pisell2.text.select-service"),
450
408
  rootClassName: "booking-server-wrap",
451
409
  onClose: () => {
452
410
  dispatch({
@@ -463,17 +421,17 @@ var Info = (props) => {
463
421
  content
464
422
  ));
465
423
  }, [
466
- (_d = (_c = state.service) == null ? void 0 : _c.cacheItem) == null ? void 0 : _d.autoClose,
424
+ (_f = (_e = state.service) == null ? void 0 : _e.cacheItem) == null ? void 0 : _f.autoClose,
467
425
  addButton,
468
426
  state.service.addModal,
469
- import_utils5.locales,
427
+ import_utils4.locales,
470
428
  search,
471
429
  renderList,
472
430
  state.amountSymbol,
473
431
  state.renderType,
474
432
  state == null ? void 0 : state.activeCartId,
475
433
  headerHeight,
476
- (0, import_utils4.holderId)(state)
434
+ (0, import_utils3.holderId)(state)
477
435
  ]);
478
436
  };
479
437
  var addService_default = Info;
@@ -68,3 +68,4 @@ export declare const getProductExtend: ({ cacheItem, state }: any) => any;
68
68
  * @Date: 2024-12-09 15:53
69
69
  */
70
70
  export declare const getResourceTitle: ({ state, id }: any) => any;
71
+ export declare const getMultiDay: ({ start_date, end_date, state, cacheItem, }: any) => Promise<any>;
@@ -33,6 +33,7 @@ __export(utils_exports, {
33
33
  formatResources: () => formatResources,
34
34
  getDurationProps: () => getDurationProps,
35
35
  getFlexibleOption: () => getFlexibleOption,
36
+ getMultiDay: () => getMultiDay,
36
37
  getProductExtend: () => getProductExtend,
37
38
  getResourceTitle: () => getResourceTitle,
38
39
  getTimeObj: () => getTimeObj
@@ -44,6 +45,7 @@ var import_dayjs = __toESM(require("dayjs"));
44
45
  var import_utils2 = require("@pisell/utils");
45
46
  var import_AlertTriangle = __toESM(require("@pisell/icon/es/AlertTriangle"));
46
47
  var import_utils3 = require("../../service2/utils");
48
+ var import_utils4 = require("../../utils");
47
49
  var getDurationProps = ({
48
50
  cacheItem,
49
51
  useStartTime,
@@ -223,12 +225,37 @@ var getResourceTitle = ({ state, id }) => {
223
225
  const resource = resources.find((d) => d.id === id);
224
226
  return (resource == null ? void 0 : resource.main_field) || "-";
225
227
  };
228
+ var getMultiDay = async ({
229
+ start_date,
230
+ end_date,
231
+ state,
232
+ cacheItem
233
+ }) => {
234
+ let _cacheItem = cacheItem || state.service.cacheItem;
235
+ if ((0, import_utils3.isDayBookingProduct)(_cacheItem, state)) {
236
+ const { multiDayPrices, price } = await (0, import_utils3.updateAppointmentServicePrice)(
237
+ state,
238
+ {
239
+ start_date,
240
+ end_date,
241
+ product_id: _cacheItem.product_id
242
+ }
243
+ );
244
+ _cacheItem._extend.multiDayPrices = (0, import_utils4.getMultiDayPrices)(multiDayPrices || []);
245
+ if (!(multiDayPrices == null ? void 0 : multiDayPrices.length)) {
246
+ _cacheItem._extend.price = price;
247
+ }
248
+ return _cacheItem;
249
+ }
250
+ return _cacheItem;
251
+ };
226
252
  // Annotate the CommonJS export names for ESM import in node:
227
253
  0 && (module.exports = {
228
254
  checkCacheItemResource,
229
255
  formatResources,
230
256
  getDurationProps,
231
257
  getFlexibleOption,
258
+ getMultiDay,
232
259
  getProductExtend,
233
260
  getResourceTitle,
234
261
  getTimeObj
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const BookingList: ({ items }: {
3
+ items: any[];
4
+ }) => React.JSX.Element;
5
+ export default BookingList;