@pisell/private-materials 3.0.78 → 3.0.80

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 (67) 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 +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +9 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +8 -8
  11. package/es/components/booking/components/addButton/index.js +3 -3
  12. package/es/components/booking/components/customSelect/index.d.ts +2 -0
  13. package/es/components/booking/components/customSelect/index.js +6 -1
  14. package/es/components/booking/components/drawer/index.d.ts +1 -0
  15. package/es/components/booking/components/drawer/index.js +4 -2
  16. package/es/components/booking/components/footer/index.js +0 -1
  17. package/es/components/booking/info/client/index.js +3 -0
  18. package/es/components/booking/info/clientVariant/hooks/useClientFn.d.ts +39 -0
  19. package/es/components/booking/info/clientVariant/hooks/useClientFn.js +378 -0
  20. package/es/components/booking/info/clientVariant/index.d.ts +1 -0
  21. package/es/components/booking/info/clientVariant/index.js +1 -0
  22. package/es/components/booking/info/clientVariant/vertical/SelectDrawer.d.ts +22 -0
  23. package/es/components/booking/info/clientVariant/vertical/SelectDrawer.js +321 -0
  24. package/es/components/booking/info/clientVariant/vertical/SelectDrawer.less +66 -0
  25. package/es/components/booking/info/clientVariant/vertical/index.d.ts +8 -0
  26. package/es/components/booking/info/clientVariant/vertical/index.js +205 -0
  27. package/es/components/booking/info/clientVariant/vertical/index.less +61 -0
  28. package/es/components/booking/info/index.js +1 -1
  29. package/es/components/booking/info/pet/index.d.ts +10 -1
  30. package/es/components/booking/info/pet/index.js +22 -14
  31. package/es/components/booking/info/service/addService/index.js +1 -1
  32. package/es/components/booking/info/utils.d.ts +1 -0
  33. package/es/components/booking/info/utils.js +12 -0
  34. package/es/components/booking/locales.d.ts +6 -0
  35. package/es/components/booking/locales.js +9 -3
  36. package/es/components/booking/model.d.ts +2 -0
  37. package/es/index.d.ts +1 -0
  38. package/es/index.js +1 -0
  39. package/lib/components/booking/components/addButton/index.js +2 -2
  40. package/lib/components/booking/components/customSelect/index.d.ts +2 -0
  41. package/lib/components/booking/components/customSelect/index.js +6 -1
  42. package/lib/components/booking/components/drawer/index.d.ts +1 -0
  43. package/lib/components/booking/components/drawer/index.js +2 -2
  44. package/lib/components/booking/components/footer/index.js +0 -1
  45. package/lib/components/booking/info/client/index.js +2 -1
  46. package/lib/components/booking/info/clientVariant/hooks/useClientFn.d.ts +39 -0
  47. package/lib/components/booking/info/clientVariant/hooks/useClientFn.js +308 -0
  48. package/lib/components/booking/info/clientVariant/index.d.ts +1 -0
  49. package/lib/components/booking/info/clientVariant/index.js +39 -0
  50. package/lib/components/booking/info/clientVariant/vertical/SelectDrawer.d.ts +22 -0
  51. package/lib/components/booking/info/clientVariant/vertical/SelectDrawer.js +344 -0
  52. package/lib/components/booking/info/clientVariant/vertical/SelectDrawer.less +66 -0
  53. package/lib/components/booking/info/clientVariant/vertical/index.d.ts +8 -0
  54. package/lib/components/booking/info/clientVariant/vertical/index.js +230 -0
  55. package/lib/components/booking/info/clientVariant/vertical/index.less +61 -0
  56. package/lib/components/booking/info/index.js +1 -1
  57. package/lib/components/booking/info/pet/index.d.ts +10 -1
  58. package/lib/components/booking/info/pet/index.js +15 -8
  59. package/lib/components/booking/info/service/addService/index.js +1 -1
  60. package/lib/components/booking/info/utils.d.ts +1 -0
  61. package/lib/components/booking/info/utils.js +16 -2
  62. package/lib/components/booking/locales.d.ts +6 -0
  63. package/lib/components/booking/locales.js +9 -3
  64. package/lib/components/booking/model.d.ts +2 -0
  65. package/lib/index.d.ts +1 -0
  66. package/lib/index.js +5 -2
  67. package/package.json +2 -2
@@ -0,0 +1,344 @@
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/info/clientVariant/vertical/SelectDrawer.tsx
30
+ var SelectDrawer_exports = {};
31
+ __export(SelectDrawer_exports, {
32
+ default: () => SelectDrawer_default
33
+ });
34
+ module.exports = __toCommonJS(SelectDrawer_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_drawer = __toESM(require("../../../components/drawer"));
37
+ var import_antd = require("antd");
38
+ var import_SearchLg = __toESM(require("@pisell/icon/es/SearchLg"));
39
+ var import_utils = require("@pisell/utils");
40
+ var import_Plus = __toESM(require("@pisell/icon/es/Plus"));
41
+ var import_User01 = __toESM(require("@pisell/icon/es/User01"));
42
+ var import_utils2 = require("../../../utils");
43
+ var import_classnames = __toESM(require("classnames"));
44
+ var import_SelectDrawer = require("./SelectDrawer.less");
45
+ var import_format = require("../../../forms/format");
46
+ var import_utils3 = require("../../utils");
47
+ var import_PlusCircle = __toESM(require("@pisell/icon/es/PlusCircle"));
48
+ var ActionItem = (props) => {
49
+ return /* @__PURE__ */ import_react.default.createElement(
50
+ "div",
51
+ {
52
+ className: "vertical-client-select-drawer-item-wrap",
53
+ onClick: props.onClick
54
+ },
55
+ /* @__PURE__ */ import_react.default.createElement("span", { className: "vertical-client-item-icon-wrap" }, /* @__PURE__ */ import_react.default.createElement(import_Plus.default, { style: { fontSize: 28, color: "#7F56D9" } })),
56
+ /* @__PURE__ */ import_react.default.createElement("span", { className: "vertical-client-item-title" }, props.title)
57
+ );
58
+ };
59
+ var Item = ({
60
+ cover,
61
+ onClick,
62
+ title,
63
+ desc,
64
+ coverSize,
65
+ checked
66
+ }) => {
67
+ return /* @__PURE__ */ import_react.default.createElement(
68
+ "div",
69
+ {
70
+ className: (0, import_classnames.default)("vertical-client-select-drawer-item-wrap", {
71
+ ["checked"]: checked
72
+ }),
73
+ onClick
74
+ },
75
+ /* @__PURE__ */ import_react.default.createElement(
76
+ import_antd.Avatar,
77
+ {
78
+ className: "pisell-lowcode__booking-client-list-item-avatar",
79
+ src: import_utils.image.ali(cover, 100) || void 0,
80
+ size: coverSize || 56,
81
+ icon: /* @__PURE__ */ import_react.default.createElement(import_User01.default, { className: "pisell-lowcode__booking-client-list-item-avatar-icon" })
82
+ }
83
+ ),
84
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-list-item-info" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-list-item-info-name" }, title), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-list-item-info-desc" }, (desc || []).map((d) => /* @__PURE__ */ import_react.default.createElement("div", { className: "" }, d))))
85
+ );
86
+ };
87
+ var defaultArr = [];
88
+ var SelectDrawer = (props, ref) => {
89
+ const {
90
+ autoFocus,
91
+ onClose,
92
+ handleSelectClient,
93
+ handleCreateItem,
94
+ childrenValue,
95
+ handleSelectPet,
96
+ formData,
97
+ searchChange,
98
+ options,
99
+ loading,
100
+ holder,
101
+ client,
102
+ loadMore,
103
+ showPet,
104
+ handleAddPet,
105
+ modalOpen
106
+ } = props;
107
+ const form = (formData == null ? void 0 : formData[0]) || {};
108
+ const valList = (childrenValue == null ? void 0 : childrenValue[form.id]) || defaultArr;
109
+ const [_value, setValue] = (0, import_react.useState)(valList);
110
+ const clientRef = (0, import_react.useRef)();
111
+ (0, import_react.useEffect)(() => {
112
+ setValue(valList);
113
+ }, [valList]);
114
+ const searchRef = (0, import_react.useRef)();
115
+ const [open, setOpen] = (0, import_react.useState)(false);
116
+ const [search, setSearch] = (0, import_react.useState)("");
117
+ (0, import_react.useEffect)(() => {
118
+ if (!modalOpen) {
119
+ setOpen(false);
120
+ }
121
+ }, [modalOpen]);
122
+ const closeDrawer = () => {
123
+ setOpen(false);
124
+ setSearch("");
125
+ onClose == null ? void 0 : onClose();
126
+ };
127
+ const handleOpenModal = () => {
128
+ setOpen(true);
129
+ if (autoFocus) {
130
+ setTimeout(() => {
131
+ var _a, _b;
132
+ (_b = (_a = searchRef.current) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
133
+ }, 400);
134
+ }
135
+ };
136
+ (0, import_react.useImperativeHandle)(ref, () => {
137
+ return {
138
+ open: handleOpenModal
139
+ // setValue: set_value,
140
+ };
141
+ });
142
+ (0, import_react.useEffect)(() => {
143
+ if (!open) {
144
+ clientRef.current = null;
145
+ }
146
+ }, [open]);
147
+ const getNickname = (0, import_react.useCallback)(
148
+ (item) => {
149
+ if ((0, import_utils2.isWalkIn)(item == null ? void 0 : item.id)) {
150
+ return import_utils.locales.getText("pisell2.text.select-a-customer");
151
+ }
152
+ return item.name || (item.display_name || "").trim() || (item.nickname || "").trim() || "";
153
+ },
154
+ [import_utils.locales.localeMap]
155
+ );
156
+ const handleAddClient = () => {
157
+ handleCreateItem();
158
+ };
159
+ const handleChildrenValueChange = (value, item) => {
160
+ if (mode === "single") {
161
+ if (!(client == null ? void 0 : client.id) || client.id === 1) {
162
+ handleSelectClient([item]);
163
+ }
164
+ handleSelectPet({
165
+ [form.id]: (0, import_format.formatAddFormValues)({
166
+ clientId: item == null ? void 0 : item.id,
167
+ value: [value],
168
+ data_range: holder.data_range
169
+ })
170
+ });
171
+ setTimeout(() => {
172
+ closeDrawer();
173
+ });
174
+ } else {
175
+ const index = _value.findIndex(
176
+ (item2) => item2.id === value.id || item2.form_record_id === value.id
177
+ );
178
+ if (!clientRef.current) {
179
+ clientRef.current = item;
180
+ }
181
+ if (index >= 0) {
182
+ const newList = [..._value];
183
+ newList.splice(index, 1);
184
+ setValue(
185
+ (0, import_format.formatAddFormValues)({
186
+ clientId: item == null ? void 0 : item.id,
187
+ value: newList,
188
+ data_range: holder.data_range
189
+ })
190
+ );
191
+ } else {
192
+ setValue(
193
+ (0, import_format.formatAddFormValues)({
194
+ clientId: item == null ? void 0 : item.id,
195
+ value: [..._value, value],
196
+ data_range: holder.data_range
197
+ })
198
+ );
199
+ }
200
+ }
201
+ };
202
+ const mode = (0, import_react.useMemo)(() => {
203
+ if (["form"].includes(holder == null ? void 0 : holder.type)) {
204
+ return "single";
205
+ }
206
+ if (["table"].includes(holder == null ? void 0 : holder.type)) {
207
+ return "multiple";
208
+ }
209
+ return holder == null ? void 0 : holder.type;
210
+ }, [holder == null ? void 0 : holder.type]);
211
+ const handleOk = () => {
212
+ var _a;
213
+ if (!(client == null ? void 0 : client.id)) {
214
+ handleSelectClient([clientRef.current]);
215
+ }
216
+ handleSelectPet({
217
+ [(_a = holder == null ? void 0 : holder.form) == null ? void 0 : _a.id]: _value
218
+ });
219
+ closeDrawer();
220
+ };
221
+ const handleClientClick = (item) => {
222
+ handleSelectClient([item]);
223
+ if (mode === "multiple") {
224
+ const isHasChildren = _value.some(
225
+ (val) => item.form_record.some(
226
+ (f) => f.id || f.form_record_id === val.id || val.form_record_id
227
+ )
228
+ );
229
+ handleSelectPet({
230
+ [form.id]: (0, import_utils3.uniqueByField)(
231
+ [
232
+ ..._value,
233
+ ...isHasChildren ? [] : (0, import_format.formatAddFormValues)({
234
+ clientId: item.id,
235
+ data_range: holder.data_range,
236
+ value: item.form_record
237
+ })
238
+ ],
239
+ "id"
240
+ )
241
+ });
242
+ }
243
+ closeDrawer();
244
+ };
245
+ return /* @__PURE__ */ import_react.default.createElement(
246
+ import_drawer.default,
247
+ {
248
+ title: import_utils.locales.getText("pisell2.text.select-customer"),
249
+ open,
250
+ onClose: closeDrawer,
251
+ header: /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
252
+ import_antd.Input,
253
+ {
254
+ ref: searchRef,
255
+ prefix: /* @__PURE__ */ import_react.default.createElement(import_SearchLg.default, null),
256
+ style: { margin: "16px 0", height: 44 },
257
+ placeholder: import_utils.locales.getText("pisell2.text.search"),
258
+ value: search,
259
+ allowClear: true,
260
+ onChange: (e) => {
261
+ setSearch(e.target.value);
262
+ if (searchChange) {
263
+ searchChange(e.target.value);
264
+ }
265
+ }
266
+ }
267
+ )),
268
+ width: 300,
269
+ getContainer: false,
270
+ destroyOnClose: true,
271
+ push: { distance: 180 },
272
+ footer: mode === "multiple" && /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { block: true, type: "primary", onClick: handleOk }, import_utils.locales.getText("pisell2.text.apply")))
273
+ },
274
+ /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, { spinning: loading }, /* @__PURE__ */ import_react.default.createElement("div", { className: "vertical-client-select-drawer-content-wrap" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "vertical-client-select-drawer-top" }, /* @__PURE__ */ import_react.default.createElement(
275
+ ActionItem,
276
+ {
277
+ title: import_utils.locales.getText("pisell2.text.create-new-customer"),
278
+ onClick: handleAddClient
279
+ }
280
+ ), /* @__PURE__ */ import_react.default.createElement(
281
+ ActionItem,
282
+ {
283
+ title: "Walk-In",
284
+ onClick: () => {
285
+ handleSelectClient([]);
286
+ closeDrawer();
287
+ }
288
+ }
289
+ )), !!options.length ? options.map((item) => {
290
+ var _a;
291
+ return /* @__PURE__ */ import_react.default.createElement(
292
+ "div",
293
+ {
294
+ className: "vertical-client-select-drawer-content-item",
295
+ key: item.id
296
+ },
297
+ /* @__PURE__ */ import_react.default.createElement(
298
+ Item,
299
+ {
300
+ onClick: () => handleClientClick(item),
301
+ cover: item.cover,
302
+ title: getNickname(item),
303
+ desc: [item.email, item.phone],
304
+ checked: item.id === client.id
305
+ }
306
+ ),
307
+ showPet && /* @__PURE__ */ import_react.default.createElement("div", { className: "vertical-client-select-drawer-content-item-children" }, ((item == null ? void 0 : item.form_record) || []).map((f) => {
308
+ const checked = _value.some(
309
+ (item2) => item2.id === f.id || item2.form_record_id === f.id
310
+ );
311
+ return /* @__PURE__ */ import_react.default.createElement(
312
+ "div",
313
+ {
314
+ onClick: () => {
315
+ handleChildrenValueChange(f, item);
316
+ },
317
+ id: `${f.id}`,
318
+ key: f.id,
319
+ className: (0, import_classnames.default)(
320
+ "vertical-client-select-drawer-content-item-children-item",
321
+ {
322
+ ["checked"]: checked
323
+ }
324
+ )
325
+ },
326
+ mode === "multiple" && /* @__PURE__ */ import_react.default.createElement(import_antd.Checkbox, { checked }),
327
+ /* @__PURE__ */ import_react.default.createElement(Item, { coverSize: 48, title: f.main_field })
328
+ );
329
+ }), /* @__PURE__ */ import_react.default.createElement(
330
+ "div",
331
+ {
332
+ className: "pisell-lowcode__custom-select-create",
333
+ onClick: () => {
334
+ handleAddPet == null ? void 0 : handleAddPet(item);
335
+ },
336
+ style: { padding: 16 }
337
+ },
338
+ /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_PlusCircle.default, { className: "pisell-lowcode__custom-select-create-icon" }), /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__custom-select-create-txt" }, `${import_utils.locales.getText("pisell2.text.create-new")} ${((_a = holder.form) == null ? void 0 : _a.title) || "-"}`))
339
+ ), /* @__PURE__ */ import_react.default.createElement("div", null))
340
+ );
341
+ }) : /* @__PURE__ */ import_react.default.createElement(import_antd.Empty, { image: import_antd.Empty.PRESENTED_IMAGE_SIMPLE }), /* @__PURE__ */ import_react.default.createElement("div", null, loadMore)))
342
+ );
343
+ };
344
+ var SelectDrawer_default = (0, import_react.forwardRef)(SelectDrawer);
@@ -0,0 +1,66 @@
1
+ .vertical-client-select-drawer-content-wrap {
2
+ padding:0 12px 12px;
3
+ }
4
+ .vertical-client-select-drawer-top {
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: 24px;
8
+ padding: 0 0 12px;
9
+ border-bottom: 1px solid var(--Gray-200, #eaecf0);
10
+ }
11
+
12
+ .vertical-client-select-drawer-item-wrap {
13
+ display: flex;
14
+ padding: 8px 12px;
15
+ align-items: center;
16
+ gap: 10px;
17
+ align-self: stretch;
18
+ cursor: pointer;
19
+ border-radius: 8px;
20
+ &:checked {
21
+ background: var(--Gray-true-50, #fafafa);
22
+ }
23
+ &:hover {
24
+ background: var(--Gray-true-50, #fafafa);
25
+ }
26
+ .vertical-client-item-icon-wrap {
27
+ display: flex;
28
+ width: 56px;
29
+ height: 56px;
30
+ justify-content: center;
31
+ align-items: center;
32
+ gap: 10px;
33
+ border-radius: 50px;
34
+ background: var(--Primary-100, #f4ebff);
35
+ }
36
+ .vertical-client-item-title {
37
+ color: var(--Text-Text_1, #1B1B1B);
38
+ font-size: 16px;
39
+ font-style: normal;
40
+ font-weight: 600;
41
+ line-height: 22px; /* 137.5% */
42
+ }
43
+ }
44
+ .vertical-client-select-drawer-content-item {
45
+ border-bottom: 1px solid var(--Gray-200, #eaecf0);
46
+ //margin-bottom: 24px;
47
+ padding: 24px 0;
48
+ }
49
+ .vertical-client-select-drawer-content-item-children {
50
+ margin-left: 18px;
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 16px;
54
+ .vertical-client-select-drawer-content-item-children-item {
55
+ display: flex;
56
+ border-radius: 8px;
57
+ padding: 0 12px;
58
+ cursor: pointer;
59
+ &.checked {
60
+ background: var(--Gray-true-50, #fafafa);
61
+ }
62
+ &:hover {
63
+ background: var(--Gray-true-50, #fafafa);
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import "./index.less";
3
+ interface VerticalClientProps {
4
+ globalState: any;
5
+ setGlobalState: any;
6
+ }
7
+ declare const VerticalClient: (props: VerticalClientProps) => React.JSX.Element;
8
+ export default VerticalClient;
@@ -0,0 +1,230 @@
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/info/clientVariant/vertical/index.tsx
30
+ var vertical_exports = {};
31
+ __export(vertical_exports, {
32
+ default: () => vertical_default
33
+ });
34
+ module.exports = __toCommonJS(vertical_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_User01 = __toESM(require("@pisell/icon/es/User01"));
37
+ var import_antd = require("antd");
38
+ var import_utils = require("@pisell/utils");
39
+ var import_icons = require("@ant-design/icons");
40
+ var import_useClientFn = __toESM(require("../hooks/useClientFn"));
41
+ var import_SelectDrawer = __toESM(require("./SelectDrawer"));
42
+ var import_pet = __toESM(require("../../pet"));
43
+ var import_index = require("./index.less");
44
+ var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
45
+ var VerticalClient = (props) => {
46
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
47
+ const { globalState, setGlobalState } = props;
48
+ const modalRef = (0, import_react.useRef)();
49
+ const state = globalState;
50
+ const stateRef = (0, import_react.useRef)(state);
51
+ const context = (0, import_useEngineContext.default)();
52
+ stateRef.current = state;
53
+ const {
54
+ isWalkIn,
55
+ setClient,
56
+ handleSelectClient,
57
+ menuChange,
58
+ handleViewClient,
59
+ menus,
60
+ handleCreateItem,
61
+ getClients,
62
+ params,
63
+ searchChange,
64
+ loading,
65
+ loadMore,
66
+ handleOpenClientModal
67
+ } = (0, import_useClientFn.default)({
68
+ state,
69
+ setGlobalState,
70
+ modalRef
71
+ });
72
+ const renderList = (0, import_react.useMemo)(() => {
73
+ let _list = [...state.client.clients];
74
+ return _list;
75
+ }, [state.client.clients]);
76
+ const handleClose = () => {
77
+ setTimeout(() => {
78
+ setClient({
79
+ showModal: false
80
+ });
81
+ });
82
+ };
83
+ const petDispatch = ({ type, payload }) => {
84
+ if (type === "setPet") {
85
+ setGlobalState({
86
+ pet: {
87
+ ...stateRef.current.pet,
88
+ ...payload
89
+ }
90
+ });
91
+ }
92
+ };
93
+ const boardConfig = (0, import_react.useMemo)(() => {
94
+ var _a2, _b2, _c2;
95
+ return ((_c2 = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.basic) == null ? void 0 : _c2.appointment_subject) || {};
96
+ }, [(_b = (_a = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.basic]);
97
+ (0, import_react.useEffect)(() => {
98
+ var _a2, _b2, _c2, _d2;
99
+ if (((_d2 = (_c2 = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.basic) == null ? void 0 : _c2.appointment_customer) == null ? void 0 : _d2.type) === "customer" && (state == null ? void 0 : state.modalOpen) && !(state == null ? void 0 : state.bookingId)) {
100
+ handleOpenClientModal();
101
+ }
102
+ }, [
103
+ (_f = (_e = (_d = (_c = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _c.config) == null ? void 0 : _d.basic) == null ? void 0 : _e.appointment_customer) == null ? void 0 : _f.type,
104
+ state == null ? void 0 : state.modalOpen
105
+ ]);
106
+ const handleSelectPet = (val) => {
107
+ setGlobalState({
108
+ pet: {
109
+ ...state.pet,
110
+ edit: true,
111
+ value: val
112
+ }
113
+ });
114
+ };
115
+ const handleOpenModal = () => {
116
+ handleOpenClientModal();
117
+ };
118
+ const handleAddPet = (_client) => {
119
+ var _a2;
120
+ let _data = {
121
+ formDataConfig: { ...((_a2 = state.pet.formData) == null ? void 0 : _a2[0]) || {} }
122
+ };
123
+ _data.customerId = _client.id;
124
+ state.action({
125
+ type: "pisell1.goCustomFormAddData",
126
+ data: _data,
127
+ callback: (res) => {
128
+ const newClients = stateRef.current.client.clients.map((item) => {
129
+ if (item.id === _client.id) {
130
+ const newFormRecordObj = res.reduce((p, c) => {
131
+ return {
132
+ ...p,
133
+ [c.key]: c.value
134
+ };
135
+ }, {});
136
+ return {
137
+ ...item,
138
+ form_record: [...item.form_record, {
139
+ ...newFormRecordObj,
140
+ id: newFormRecordObj.form_record_id,
141
+ data: newFormRecordObj
142
+ }]
143
+ };
144
+ }
145
+ return item;
146
+ });
147
+ setClient({
148
+ clients: newClients
149
+ });
150
+ }
151
+ });
152
+ };
153
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-vertical-client-wrap" }, /* @__PURE__ */ import_react.default.createElement(
154
+ "div",
155
+ {
156
+ className: "pisell-lowcode__booking-vertical-client",
157
+ onClick: () => {
158
+ if (!isWalkIn || (state == null ? void 0 : state.disableEventBookingEdit)) {
159
+ return;
160
+ }
161
+ handleOpenClientModal();
162
+ }
163
+ },
164
+ /* @__PURE__ */ import_react.default.createElement(
165
+ import_antd.Avatar,
166
+ {
167
+ className: "pisell-lowcode__booking-client-avatar",
168
+ src: import_utils.image.ali((_g = state.client.value) == null ? void 0 : _g.cover, 100),
169
+ size: 64,
170
+ icon: /* @__PURE__ */ import_react.default.createElement(import_User01.default, { className: "pisell-lowcode__booking-client-list-item-avatar-icon" })
171
+ }
172
+ ),
173
+ isWalkIn ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-info-desc" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-title" }, import_utils.locales.getText("pisell2.text.add-client")), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-desc-item" }, import_utils.locales.getText("pisell2.text.leave-empty-for-walk-in"))) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-title" }, (_h = state.client.value) == null ? void 0 : _h.name), ((_i = state.client.value) == null ? void 0 : _i.email) ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-desc-item" }, (_j = state.client.value) == null ? void 0 : _j.email) : null, ((_k = state.client.value) == null ? void 0 : _k.phone) ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-desc-item" }, (_l = state.client.value) == null ? void 0 : _l.phone) : null),
174
+ !isWalkIn && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-client-action-wrap" }, /* @__PURE__ */ import_react.default.createElement(
175
+ import_antd.Dropdown,
176
+ {
177
+ menu: {
178
+ items: menus,
179
+ onClick: menuChange
180
+ },
181
+ placement: "bottomRight"
182
+ },
183
+ /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ import_react.default.createElement(import_antd.Space, null, import_utils.locales.getText("pisell2.text.actions"), /* @__PURE__ */ import_react.default.createElement(import_icons.DownOutlined, null)))
184
+ ), /* @__PURE__ */ import_react.default.createElement(
185
+ import_antd.Button,
186
+ {
187
+ onClick: (e) => {
188
+ e.stopPropagation();
189
+ handleViewClient();
190
+ }
191
+ },
192
+ import_utils.locales.getText("pisell2.text.view-profile")
193
+ ))
194
+ ), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-vertical-pet" }, !(state == null ? void 0 : state.disabledEdit) ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, boardConfig.type === "form" ? /* @__PURE__ */ import_react.default.createElement(
195
+ import_pet.default,
196
+ {
197
+ clientChangeNotSetPet: true,
198
+ state,
199
+ dispatch: petDispatch,
200
+ hideTitle: !((_n = (_m = state.pet) == null ? void 0 : _m.value) == null ? void 0 : _n.length),
201
+ handleOpenModal,
202
+ addButtonProps: {
203
+ onClick: handleOpenClientModal,
204
+ style: (isShowSub) => isShowSub ? {} : { display: "none" }
205
+ }
206
+ }
207
+ ) : null) : null), /* @__PURE__ */ import_react.default.createElement(
208
+ import_SelectDrawer.default,
209
+ {
210
+ modalOpen: state.modalOpen,
211
+ loading,
212
+ autoFocus: !((_q = (_p = (_o = context == null ? void 0 : context.appHelper) == null ? void 0 : _o.utils) == null ? void 0 : _p.isTerminal) == null ? void 0 : _q.call(_p)),
213
+ ref: modalRef,
214
+ onClose: handleClose,
215
+ handleSelectClient,
216
+ handleCreateItem,
217
+ childrenValue: state.pet.value,
218
+ handleSelectPet,
219
+ formData: state.pet.formData,
220
+ searchChange,
221
+ options: renderList,
222
+ holder: (_r = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _r.holder,
223
+ client: (_s = state == null ? void 0 : state.client) == null ? void 0 : _s.value,
224
+ loadMore,
225
+ showPet: (boardConfig == null ? void 0 : boardConfig.type) === "form",
226
+ handleAddPet
227
+ }
228
+ ));
229
+ };
230
+ var vertical_default = VerticalClient;