@pisell/private-materials 6.6.70 → 6.6.73

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 (27) 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 +1 -1
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +1 -1
  9. package/es/components/booking/components/footer/index.js +71 -59
  10. package/es/components/booking/components/footer/utils.js +2 -1
  11. package/es/components/booking/info/hooks/useAddHolder.js +1 -0
  12. package/es/components/booking/info/main.js +2 -1
  13. package/es/components/booking/info2/index.js +2 -1
  14. package/es/components/booking/utils/holderAssignmentConfirmModal.d.ts +7 -0
  15. package/es/components/booking/utils/holderAssignmentConfirmModal.js +403 -0
  16. package/es/components/eftposPay/hooks.d.ts +1 -1
  17. package/es/components/eftposPay/store/index.d.ts +2 -2
  18. package/lib/components/booking/components/footer/index.js +26 -20
  19. package/lib/components/booking/components/footer/utils.js +1 -1
  20. package/lib/components/booking/info/hooks/useAddHolder.js +1 -0
  21. package/lib/components/booking/info/main.js +2 -1
  22. package/lib/components/booking/info2/index.js +2 -1
  23. package/lib/components/booking/utils/holderAssignmentConfirmModal.d.ts +7 -0
  24. package/lib/components/booking/utils/holderAssignmentConfirmModal.js +374 -0
  25. package/lib/components/eftposPay/hooks.d.ts +1 -1
  26. package/lib/components/eftposPay/store/index.d.ts +2 -2
  27. package/package.json +1 -1
@@ -0,0 +1,374 @@
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/booking/utils/holderAssignmentConfirmModal.tsx
30
+ var holderAssignmentConfirmModal_exports = {};
31
+ __export(holderAssignmentConfirmModal_exports, {
32
+ HolderAssignmentConfirmModal: () => HolderAssignmentConfirmModal,
33
+ showHolderAssignmentConfirmModal: () => showHolderAssignmentConfirmModal
34
+ });
35
+ module.exports = __toCommonJS(holderAssignmentConfirmModal_exports);
36
+ var import_react = __toESM(require("react"));
37
+ var import_antd = require("antd");
38
+ var import_ahooks = require("ahooks");
39
+ var import_utils = require("@pisell/utils");
40
+ var import_materials = require("@pisell/materials");
41
+ var import_Lists = __toESM(require("../info/service/Lists"));
42
+ var import_model = require("../info/model");
43
+ var import_utils2 = require("../info/service2/utils");
44
+ var import_selectHolderModal = require("./selectHolderModal");
45
+ var import_utils3 = require("../../ticketBooking/utils");
46
+ var import_confirmHolderModal = require("./confirmHolderModal.less");
47
+ var activeHolderAssignmentConfirm = null;
48
+ var holderAssignmentConfirmSubscribers = /* @__PURE__ */ new Set();
49
+ function notifyHolderAssignmentConfirmHost(request) {
50
+ let handledCount = 0;
51
+ holderAssignmentConfirmSubscribers.forEach((subscriber) => {
52
+ if (subscriber(request)) {
53
+ handledCount += 1;
54
+ }
55
+ });
56
+ return handledCount;
57
+ }
58
+ function settleHolderAssignmentConfirmRequest(request, shouldContinue) {
59
+ if (request.settled) {
60
+ return;
61
+ }
62
+ request.settled = true;
63
+ if (activeHolderAssignmentConfirm === request) {
64
+ activeHolderAssignmentConfirm = null;
65
+ }
66
+ request.resolve(shouldContinue);
67
+ notifyHolderAssignmentConfirmHost(null);
68
+ }
69
+ function calculateUnassignedHolderCount(state) {
70
+ var _a;
71
+ const unassignedProducts = (((_a = state == null ? void 0 : state.service) == null ? void 0 : _a.value) || []).filter(
72
+ (item) => {
73
+ var _a2, _b, _c;
74
+ return (!((_a2 = item._extend) == null ? void 0 : _a2.holder_id) || ((_c = (_b = item._extend) == null ? void 0 : _b.holder_id) == null ? void 0 : _c.length) === 0) && !(0, import_utils2.isNormalProductByDurationSchedule)(item);
75
+ }
76
+ );
77
+ const arr = [];
78
+ unassignedProducts.forEach((item) => {
79
+ var _a2;
80
+ if ((_a2 = item == null ? void 0 : item._extend) == null ? void 0 : _a2.groupId) {
81
+ if (!arr.some((sub) => {
82
+ var _a3, _b;
83
+ return ((_a3 = sub == null ? void 0 : sub._extend) == null ? void 0 : _a3.groupId) === ((_b = item == null ? void 0 : item._extend) == null ? void 0 : _b.groupId);
84
+ })) {
85
+ arr.push(item);
86
+ }
87
+ } else {
88
+ arr.push(item);
89
+ }
90
+ });
91
+ return arr.reduce((sum, item) => {
92
+ var _a2;
93
+ return sum + (((_a2 = item._extend) == null ? void 0 : _a2.quantity) || 1);
94
+ }, 0);
95
+ }
96
+ function hasHolderId(item) {
97
+ var _a;
98
+ const holderId = (_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.holder_id;
99
+ return Array.isArray(holderId) ? holderId.length > 0 : Boolean(holderId);
100
+ }
101
+ function updateProductHolder(state, currentItem, holderIds) {
102
+ var _a, _b, _c, _d, _e, _f, _g;
103
+ const list = [...((_a = state == null ? void 0 : state.service) == null ? void 0 : _a.value) || []];
104
+ const cacheItem = {
105
+ ...currentItem,
106
+ _extend: {
107
+ ...(currentItem == null ? void 0 : currentItem._extend) || {},
108
+ holder_id: holderIds
109
+ }
110
+ };
111
+ if ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.groupId) {
112
+ const groupId = cacheItem._extend.groupId;
113
+ list.forEach((item, index) => {
114
+ var _a2;
115
+ if (((_a2 = item == null ? void 0 : item._extend) == null ? void 0 : _a2.groupId) === groupId) {
116
+ list[index] = {
117
+ ...item,
118
+ _extend: {
119
+ ...item._extend || {},
120
+ holder_id: holderIds
121
+ }
122
+ };
123
+ }
124
+ });
125
+ } else {
126
+ const index = list.findIndex((item) => item._id === cacheItem._id);
127
+ if (index !== -1) {
128
+ list[index] = cacheItem;
129
+ }
130
+ }
131
+ if (((_d = (_c = cacheItem._extend) == null ? void 0 : _c.holder_id) == null ? void 0 : _d.length) > 1 || ((_e = cacheItem._extend) == null ? void 0 : _e.quantity) > 1 && ((_g = (_f = cacheItem._extend) == null ? void 0 : _f.holder_id) == null ? void 0 : _g.length) >= 1) {
132
+ let remainingHolderIds = cacheItem._extend.holder_id;
133
+ cacheItem._extend.holder_id = [remainingHolderIds[0]];
134
+ remainingHolderIds = remainingHolderIds.slice(1);
135
+ cacheItem._holderKey = (0, import_utils3.genHolderKey)(cacheItem);
136
+ remainingHolderIds.forEach((holderId) => {
137
+ const newItem = {
138
+ ...cacheItem,
139
+ _id: (0, import_utils.getUniqueId)(),
140
+ _extend: {
141
+ ...cacheItem._extend,
142
+ holder_id: [holderId],
143
+ quantity: 1
144
+ }
145
+ };
146
+ newItem._holderKey = (0, import_utils3.genHolderKey)(newItem);
147
+ list.unshift(newItem);
148
+ cacheItem._extend.quantity -= 1;
149
+ });
150
+ if (cacheItem._extend.quantity > 1) {
151
+ const newItem = {
152
+ ...cacheItem,
153
+ _id: (0, import_utils.getUniqueId)(),
154
+ _extend: {
155
+ ...cacheItem._extend,
156
+ holder_id: void 0,
157
+ quantity: cacheItem._extend.quantity - 1
158
+ }
159
+ };
160
+ newItem._holderKey = (0, import_utils3.genHolderKey)(newItem);
161
+ list.unshift(newItem);
162
+ cacheItem._extend.quantity = 1;
163
+ }
164
+ }
165
+ return list.sort((a, b) => {
166
+ if (!hasHolderId(a) && hasHolderId(b)) return -1;
167
+ if (hasHolderId(a) && !hasHolderId(b)) return 1;
168
+ return 0;
169
+ });
170
+ }
171
+ var HolderAssignmentConfirmContent = ({ state, dispatch, open, onResolve, onStateChange }) => {
172
+ var _a, _b, _c;
173
+ const handleClose = () => {
174
+ if (!open) {
175
+ return;
176
+ }
177
+ import_antd.Modal.confirm({
178
+ title: import_utils.locales.getText("pisell2.text.deposit-delete-message-title"),
179
+ content: import_utils.locales.getText("pisell2.text.close-confirm-message"),
180
+ okText: import_utils.locales.getText("pisell2.text.confirm"),
181
+ cancelText: import_utils.locales.getText("pisell2.text.cancel"),
182
+ centered: true,
183
+ onOk: onResolve
184
+ });
185
+ };
186
+ const { run: debouncedHandleClose } = (0, import_ahooks.useDebounceFn)(handleClose, {
187
+ wait: 500,
188
+ leading: true,
189
+ trailing: false
190
+ });
191
+ const syncServiceValueChange = (nextServiceState) => {
192
+ const nextValue = nextServiceState == null ? void 0 : nextServiceState.value;
193
+ if (!Array.isArray(nextValue)) {
194
+ return false;
195
+ }
196
+ const nextService = {
197
+ ...state.service,
198
+ ...nextServiceState,
199
+ value: nextValue,
200
+ edit: true
201
+ };
202
+ const nextState = {
203
+ ...state,
204
+ service: nextService
205
+ };
206
+ dispatch({
207
+ type: "setService",
208
+ payload: nextService
209
+ });
210
+ onStateChange(nextState);
211
+ return true;
212
+ };
213
+ const handleListChange = async (nextServiceState) => {
214
+ var _a2, _b2, _c2;
215
+ const hasSyncedServiceValue = syncServiceValueChange(nextServiceState);
216
+ if (hasSyncedServiceValue) {
217
+ return;
218
+ }
219
+ if (!(state == null ? void 0 : state.isBookingTicket2)) {
220
+ return;
221
+ }
222
+ const currentItem = nextServiceState == null ? void 0 : nextServiceState.cacheItem;
223
+ if (!currentItem) {
224
+ return;
225
+ }
226
+ const holderConfig = ((_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.holder) || {};
227
+ const currentMaxSelectedCount = (holderConfig == null ? void 0 : holderConfig.maxSelectedCount) || ((_b2 = currentItem == null ? void 0 : currentItem._extend) == null ? void 0 : _b2.quantity) || 1;
228
+ const currentHolderId = (_c2 = currentItem == null ? void 0 : currentItem._extend) == null ? void 0 : _c2.holder_id;
229
+ const initialValue = currentHolderId ? Array.isArray(currentHolderId) ? currentHolderId : [currentHolderId] : void 0;
230
+ const result = await (0, import_selectHolderModal.selectHolderModal)({
231
+ state,
232
+ dispatch,
233
+ initialValue,
234
+ maxSelectedCount: currentMaxSelectedCount
235
+ });
236
+ if (!(result == null ? void 0 : result.length)) {
237
+ return;
238
+ }
239
+ const nextValue = updateProductHolder(state, currentItem, result);
240
+ const nextState = {
241
+ ...state,
242
+ service: {
243
+ ...state.service,
244
+ value: nextValue,
245
+ edit: true
246
+ }
247
+ };
248
+ dispatch({
249
+ type: "setService",
250
+ payload: nextState.service
251
+ });
252
+ onStateChange(nextState);
253
+ };
254
+ if (!open) {
255
+ return null;
256
+ }
257
+ const unassignedCount = calculateUnassignedHolderCount(state);
258
+ const title = import_utils.locales.getText("pisell2.text.holder-unassigned")(unassignedCount);
259
+ const hintText = import_utils.locales.getText("pisell2.text.press-card-assign-holder");
260
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
261
+ import_materials.PisellContainer,
262
+ {
263
+ renderType: "modal",
264
+ props: {
265
+ open,
266
+ onCancel: debouncedHandleClose,
267
+ title,
268
+ footer: null,
269
+ platform: "pc",
270
+ width: 800,
271
+ destroyOnClose: true,
272
+ maskClosable: false,
273
+ closable: true
274
+ }
275
+ },
276
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-hint" }, hintText), /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-service" }, /* @__PURE__ */ import_react.default.createElement(
277
+ import_Lists.default,
278
+ {
279
+ isParallelResource: true,
280
+ isShowDelete: false,
281
+ isShowAmountFooter: false,
282
+ onChange: handleListChange
283
+ }
284
+ )), /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-footer" }, ((_c = (_b = (_a = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.basic) == null ? void 0 : _c.subject_require) !== "require" ? /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: onResolve, className: "skip-button", size: "large" }, import_utils.locales.getText("pisell2.text.skip-for-now")) : null, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: onResolve, className: "confirm-button" }, import_utils.locales.getText("pisell2.text.confirm"))))
285
+ ), !(state == null ? void 0 : state.isBookingTicket2) ? /* @__PURE__ */ import_react.default.createElement(import_selectHolderModal.SelectHolderModal, null) : null);
286
+ };
287
+ var HolderAssignmentConfirmModal = () => {
288
+ const bookingContext = (0, import_react.useContext)(import_model.Context);
289
+ const [open, setOpen] = (0, import_react.useState)(false);
290
+ const [request, setRequest] = (0, import_react.useState)(
291
+ null
292
+ );
293
+ const [modalState, setModalState] = (0, import_react.useState)(null);
294
+ const requestRef = (0, import_react.useRef)(null);
295
+ const bookingContextRef = (0, import_react.useRef)(bookingContext);
296
+ requestRef.current = request;
297
+ bookingContextRef.current = bookingContext;
298
+ const handleResolve = () => {
299
+ setOpen(false);
300
+ const currentRequest = requestRef.current;
301
+ if (currentRequest) {
302
+ settleHolderAssignmentConfirmRequest(currentRequest, true);
303
+ }
304
+ setTimeout(() => {
305
+ setRequest(null);
306
+ }, 300);
307
+ };
308
+ (0, import_react.useLayoutEffect)(() => {
309
+ const subscriber = (nextRequest) => {
310
+ var _a;
311
+ if (!nextRequest) {
312
+ setOpen(false);
313
+ setTimeout(() => {
314
+ setRequest(null);
315
+ }, 300);
316
+ return false;
317
+ }
318
+ if (nextRequest.state !== ((_a = bookingContextRef.current) == null ? void 0 : _a.state)) {
319
+ return false;
320
+ }
321
+ setRequest(nextRequest);
322
+ setModalState(nextRequest.state);
323
+ setOpen(true);
324
+ return true;
325
+ };
326
+ holderAssignmentConfirmSubscribers.add(subscriber);
327
+ return () => {
328
+ holderAssignmentConfirmSubscribers.delete(subscriber);
329
+ const currentRequest = requestRef.current;
330
+ if (currentRequest) {
331
+ settleHolderAssignmentConfirmRequest(currentRequest, false);
332
+ }
333
+ };
334
+ }, []);
335
+ if (!request || !modalState) {
336
+ return null;
337
+ }
338
+ return /* @__PURE__ */ import_react.default.createElement(import_model.Context.Provider, { value: { state: modalState, dispatch: bookingContext == null ? void 0 : bookingContext.dispatch } }, /* @__PURE__ */ import_react.default.createElement(
339
+ HolderAssignmentConfirmContent,
340
+ {
341
+ state: modalState,
342
+ dispatch: bookingContext == null ? void 0 : bookingContext.dispatch,
343
+ open,
344
+ onResolve: handleResolve,
345
+ onStateChange: setModalState
346
+ }
347
+ ));
348
+ };
349
+ function showHolderAssignmentConfirmModal(state) {
350
+ if (activeHolderAssignmentConfirm) {
351
+ settleHolderAssignmentConfirmRequest(activeHolderAssignmentConfirm, false);
352
+ }
353
+ return new Promise((resolve) => {
354
+ const request = {
355
+ id: Symbol("HolderAssignmentConfirmRequest"),
356
+ state,
357
+ resolve,
358
+ settled: false
359
+ };
360
+ activeHolderAssignmentConfirm = request;
361
+ const handledCount = notifyHolderAssignmentConfirmHost(request);
362
+ if (handledCount === 0) {
363
+ console.warn(
364
+ "HolderAssignmentConfirmModal host is not mounted. Please render <HolderAssignmentConfirmModal /> in your booking component tree."
365
+ );
366
+ settleHolderAssignmentConfirmRequest(request, false);
367
+ }
368
+ });
369
+ }
370
+ // Annotate the CommonJS export names for ESM import in node:
371
+ 0 && (module.exports = {
372
+ HolderAssignmentConfirmModal,
373
+ showHolderAssignmentConfirmModal
374
+ });
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -299,8 +299,8 @@ export declare const backUpFree: (payload: Partial<State>) => {
299
299
  amount?: string | number | undefined;
300
300
  mode?: "pay" | "refund" | "fullPay" | "query" | undefined;
301
301
  order_id?: string | number | undefined;
302
- eftpos?: "stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | undefined;
303
- action?: "pay" | "amount" | "deviceList" | undefined;
302
+ eftpos?: "stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | undefined;
303
+ action?: "amount" | "pay" | "deviceList" | undefined;
304
304
  key?: number | undefined;
305
305
  step?: number | undefined;
306
306
  title?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.6.70",
3
+ "version": "6.6.73",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",