@pisell/private-materials 6.12.362 → 6.12.364
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/plus/saasDevice/devicePasscodes/model.js +4 -4
- package/es/plus/salesSdk/bookingEditService/BookingEditHolderField.js +66 -27
- package/es/plus/walletPassGallery/components/timelineSection/index.js +4 -4
- package/lib/plus/salesSdk/bookingEditService/BookingEditHolderField.js +65 -26
- package/package.json +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import timezonePlugin from "dayjs/plugin/timezone";
|
|
4
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
5
5
|
//#region src/plus/saasDevice/devicePasscodes/model.ts
|
|
6
|
-
dayjs.extend(
|
|
7
|
-
dayjs.extend(
|
|
6
|
+
dayjs.extend(utcPlugin);
|
|
7
|
+
dayjs.extend(timezonePlugin);
|
|
8
8
|
const INITIAL_DEVICE_PASSCODE_STATE = {
|
|
9
9
|
deviceIds: [],
|
|
10
10
|
devicesById: {}
|
|
@@ -13,7 +13,7 @@ import { buildHolderListRequestParams } from "../utils/enrichCartLineHolderDispl
|
|
|
13
13
|
import { useSalesSdkHolderOptional } from "../context/SalesSdkHolderContext.js";
|
|
14
14
|
import { SalesSdkSelectHolderModal } from "../components/SalesSdkSelectHolderModal.js";
|
|
15
15
|
import { useBookingEditPetState } from "./useBookingEditPetState.js";
|
|
16
|
-
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
16
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
17
17
|
import { Button, Col, Row, message } from "antd";
|
|
18
18
|
import { locales } from "@pisell/utils";
|
|
19
19
|
import { Iconfont } from "@pisell/materials";
|
|
@@ -31,7 +31,7 @@ function hasHolderFormFields(formDataConfig) {
|
|
|
31
31
|
return Array.isArray(formDataConfig === null || formDataConfig === void 0 ? void 0 : formDataConfig.field) || Array.isArray(formDataConfig === null || formDataConfig === void 0 ? void 0 : formDataConfig.form_field);
|
|
32
32
|
}
|
|
33
33
|
const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, getCurrentCacheItem, presentation = "modal" }) => {
|
|
34
|
-
var _context$appHelper, _currentCacheItem$_ex, _cacheItem$_extend, _inlinePet$formData, _state$pet, _state$pet6, _state$pet7, _state$pet8, _inlineState$pet2, _state$client2, _inlineState$
|
|
34
|
+
var _context$appHelper, _currentCacheItem$_ex, _cacheItem$_extend, _inlinePet$formData, _state$pet, _state$pet6, _state$pet7, _state$pet8, _inlineState$client, _inlineState$pet2, _state$client2, _inlineState$client6;
|
|
35
35
|
const bridges = useSalesSdkHostBridges();
|
|
36
36
|
const platform = usePlatform();
|
|
37
37
|
const context = useEngineContext();
|
|
@@ -122,6 +122,33 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
122
122
|
const handleApply = useCallback((nextValues) => {
|
|
123
123
|
onChange === null || onChange === void 0 || onChange(nextValues);
|
|
124
124
|
}, [onChange]);
|
|
125
|
+
const defaultSelectionKey = JSON.stringify([inlineState === null || inlineState === void 0 || (_inlineState$client = inlineState.client) === null || _inlineState$client === void 0 || (_inlineState$client = _inlineState$client.value) === null || _inlineState$client === void 0 ? void 0 : _inlineState$client.id, currentHolderFormId]);
|
|
126
|
+
const defaultSelectionRef = useRef(null);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
var _ref4, _holder$id;
|
|
129
|
+
if (!isInline || !isRequired || maxSelectedCount !== 1) return;
|
|
130
|
+
if (defaultSelectionRef.current === defaultSelectionKey) return;
|
|
131
|
+
if (selectedValues.length) {
|
|
132
|
+
defaultSelectionRef.current = defaultSelectionKey;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(inlinePet.holders)) return;
|
|
136
|
+
if (inlinePet.holders.length !== 1) return;
|
|
137
|
+
const holder = inlinePet.holders[0];
|
|
138
|
+
const id = (_ref4 = (_holder$id = holder === null || holder === void 0 ? void 0 : holder.id) !== null && _holder$id !== void 0 ? _holder$id : holder === null || holder === void 0 ? void 0 : holder.form_record_id) !== null && _ref4 !== void 0 ? _ref4 : holder === null || holder === void 0 ? void 0 : holder.value;
|
|
139
|
+
if (id == null) return;
|
|
140
|
+
defaultSelectionRef.current = defaultSelectionKey;
|
|
141
|
+
setSelectedValues([id]);
|
|
142
|
+
handleApply([id]);
|
|
143
|
+
}, [
|
|
144
|
+
defaultSelectionKey,
|
|
145
|
+
handleApply,
|
|
146
|
+
inlinePet.holders,
|
|
147
|
+
isInline,
|
|
148
|
+
isRequired,
|
|
149
|
+
maxSelectedCount,
|
|
150
|
+
selectedValues
|
|
151
|
+
]);
|
|
125
152
|
const { formDataConfig, isMinorAndWaiver } = useMemo(() => {
|
|
126
153
|
var _inlineState$pet;
|
|
127
154
|
const productHolderFormData = inlineState === null || inlineState === void 0 || (_inlineState$pet = inlineState.pet) === null || _inlineState$pet === void 0 || (_inlineState$pet = _inlineState$pet.formData) === null || _inlineState$pet === void 0 ? void 0 : _inlineState$pet[0];
|
|
@@ -139,9 +166,9 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
139
166
|
};
|
|
140
167
|
}, [inlineState === null || inlineState === void 0 || (_inlineState$pet2 = inlineState.pet) === null || _inlineState$pet2 === void 0 ? void 0 : _inlineState$pet2.formData]);
|
|
141
168
|
const refreshHoldersFromServer = useMemoizedFn(_asyncToGenerator(function* () {
|
|
142
|
-
var _inlineState$
|
|
169
|
+
var _inlineState$client2;
|
|
143
170
|
const params = buildHolderListRequestParams({
|
|
144
|
-
customerId: inlineState === null || inlineState === void 0 || (_inlineState$
|
|
171
|
+
customerId: inlineState === null || inlineState === void 0 || (_inlineState$client2 = inlineState.client) === null || _inlineState$client2 === void 0 || (_inlineState$client2 = _inlineState$client2.value) === null || _inlineState$client2 === void 0 ? void 0 : _inlineState$client2.id,
|
|
145
172
|
source: currentCacheItem
|
|
146
173
|
});
|
|
147
174
|
if (!params) return;
|
|
@@ -155,20 +182,23 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
155
182
|
reloadHolderOptions();
|
|
156
183
|
return list;
|
|
157
184
|
}));
|
|
158
|
-
const
|
|
159
|
-
var
|
|
160
|
-
|
|
161
|
-
const id = (_ref4 = (_holder$id = holder === null || holder === void 0 ? void 0 : holder.id) !== null && _holder$id !== void 0 ? _holder$id : holder === null || holder === void 0 ? void 0 : holder.form_record_id) !== null && _ref4 !== void 0 ? _ref4 : holder === null || holder === void 0 ? void 0 : holder.value;
|
|
185
|
+
const applyCreatedHolderSelection = useMemoizedFn((holder) => {
|
|
186
|
+
var _ref5, _holder$id2;
|
|
187
|
+
const id = (_ref5 = (_holder$id2 = holder === null || holder === void 0 ? void 0 : holder.id) !== null && _holder$id2 !== void 0 ? _holder$id2 : holder === null || holder === void 0 ? void 0 : holder.form_record_id) !== null && _ref5 !== void 0 ? _ref5 : holder === null || holder === void 0 ? void 0 : holder.value;
|
|
162
188
|
if (id == null || selectedValues.some((value) => String(value) === String(id))) return;
|
|
163
189
|
const nextValues = maxSelectedCount === 1 ? [id] : [...selectedValues.slice(0, Math.max(0, maxSelectedCount - 1)), id];
|
|
164
190
|
setSelectedValues(nextValues);
|
|
165
191
|
handleApply(nextValues);
|
|
166
192
|
});
|
|
193
|
+
const selectCreatedHolder = useMemoizedFn((holder) => {
|
|
194
|
+
if (!isNormalProduct) return;
|
|
195
|
+
applyCreatedHolderSelection(holder);
|
|
196
|
+
});
|
|
167
197
|
const handleAddHolder = useMemoizedFn(() => {
|
|
168
198
|
if (!action || !inlineState) return;
|
|
169
199
|
(function() {
|
|
170
|
-
var
|
|
171
|
-
var _inlineState$pet3, _waiverForm$form_id, _inlineState$
|
|
200
|
+
var _ref11 = _asyncToGenerator(function* () {
|
|
201
|
+
var _inlineState$pet3, _waiverForm$form_id, _inlineState$client3, _inlineState$pet4, _inlineState$client4;
|
|
172
202
|
let waiverForm = (_inlineState$pet3 = inlineState.pet) === null || _inlineState$pet3 === void 0 ? void 0 : _inlineState$pet3.waiverForm;
|
|
173
203
|
if (isMinorAndWaiver && !hasHolderFormFields(waiverForm)) {
|
|
174
204
|
waiverForm = yield getCachedWaiverFormDetail(Number(isMinorAndWaiver), platform);
|
|
@@ -179,37 +209,45 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
179
209
|
}
|
|
180
210
|
const resolvedActionFormDataConfig = ensureProductHolderFormId(isMinorAndWaiver ? _objectSpread2(_objectSpread2({}, waiverForm), {}, {
|
|
181
211
|
form_id: (_waiverForm$form_id = waiverForm === null || waiverForm === void 0 ? void 0 : waiverForm.form_id) !== null && _waiverForm$form_id !== void 0 ? _waiverForm$form_id : Number(isMinorAndWaiver),
|
|
182
|
-
customer_id: (_inlineState$
|
|
212
|
+
customer_id: (_inlineState$client3 = inlineState.client) === null || _inlineState$client3 === void 0 || (_inlineState$client3 = _inlineState$client3.value) === null || _inlineState$client3 === void 0 ? void 0 : _inlineState$client3.id,
|
|
183
213
|
is_franchisor: formDataConfig === null || formDataConfig === void 0 ? void 0 : formDataConfig.is_franchisor
|
|
184
214
|
}) : _objectSpread2({}, formDataConfig || {}), currentCacheItem);
|
|
185
215
|
if (resolvedActionFormDataConfig.form_id === void 0 || resolvedActionFormDataConfig.form_id === null || resolvedActionFormDataConfig.form_id === "") {
|
|
186
216
|
message.error(locales.getText("pisell-select-holder-form-unavailable"));
|
|
187
217
|
return;
|
|
188
218
|
}
|
|
219
|
+
const previousHolderIds = new Set((((_inlineState$pet4 = inlineState.pet) === null || _inlineState$pet4 === void 0 ? void 0 : _inlineState$pet4.holders) || []).map((holder) => {
|
|
220
|
+
var _ref6, _holder$id3;
|
|
221
|
+
return String((_ref6 = (_holder$id3 = holder.id) !== null && _holder$id3 !== void 0 ? _holder$id3 : holder.form_record_id) !== null && _ref6 !== void 0 ? _ref6 : holder.value);
|
|
222
|
+
}));
|
|
189
223
|
action({
|
|
190
224
|
type: "pisell1.goCustomFormAddData",
|
|
191
225
|
data: {
|
|
192
226
|
zIndex: 1101,
|
|
193
|
-
customerId: (_inlineState$
|
|
227
|
+
customerId: (_inlineState$client4 = inlineState.client) === null || _inlineState$client4 === void 0 || (_inlineState$client4 = _inlineState$client4.value) === null || _inlineState$client4 === void 0 ? void 0 : _inlineState$client4.id,
|
|
194
228
|
formDataConfig: resolvedActionFormDataConfig
|
|
195
229
|
},
|
|
196
230
|
callback: function() {
|
|
197
|
-
var
|
|
198
|
-
var _inlineState$
|
|
231
|
+
var _ref10 = _asyncToGenerator(function* (res) {
|
|
232
|
+
var _inlineState$client5, _inlineState$pet6;
|
|
199
233
|
const obj = {};
|
|
200
234
|
for (const item of Array.isArray(res) ? res : []) obj[item.key] = item.value;
|
|
201
235
|
if (isMinorAndWaiver) {
|
|
202
236
|
try {
|
|
203
237
|
const list = yield refreshHoldersFromServer();
|
|
238
|
+
if (isInline && !isNormalProduct) applyCreatedHolderSelection(list === null || list === void 0 ? void 0 : list.find((holder) => {
|
|
239
|
+
var _ref7, _holder$id4;
|
|
240
|
+
return !previousHolderIds.has(String((_ref7 = (_holder$id4 = holder.id) !== null && _holder$id4 !== void 0 ? _holder$id4 : holder.form_record_id) !== null && _ref7 !== void 0 ? _ref7 : holder.value));
|
|
241
|
+
}));
|
|
204
242
|
if (isNormalProduct) {
|
|
205
|
-
var _inlineState$
|
|
206
|
-
const previousIds = new Set((((_inlineState$
|
|
207
|
-
var
|
|
208
|
-
return String((
|
|
243
|
+
var _inlineState$pet5;
|
|
244
|
+
const previousIds = new Set((((_inlineState$pet5 = inlineState.pet) === null || _inlineState$pet5 === void 0 ? void 0 : _inlineState$pet5.holders) || []).map((holder) => {
|
|
245
|
+
var _ref8, _holder$id5;
|
|
246
|
+
return String((_ref8 = (_holder$id5 = holder.id) !== null && _holder$id5 !== void 0 ? _holder$id5 : holder.form_record_id) !== null && _ref8 !== void 0 ? _ref8 : holder.value);
|
|
209
247
|
}));
|
|
210
248
|
selectCreatedHolder(list === null || list === void 0 ? void 0 : list.find((holder) => {
|
|
211
|
-
var
|
|
212
|
-
return !previousIds.has(String((
|
|
249
|
+
var _ref9, _holder$id6;
|
|
250
|
+
return !previousIds.has(String((_ref9 = (_holder$id6 = holder.id) !== null && _holder$id6 !== void 0 ? _holder$id6 : holder.form_record_id) !== null && _ref9 !== void 0 ? _ref9 : holder.value));
|
|
213
251
|
}));
|
|
214
252
|
}
|
|
215
253
|
} catch (err) {
|
|
@@ -217,22 +255,23 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
217
255
|
}
|
|
218
256
|
return;
|
|
219
257
|
}
|
|
220
|
-
if (isWalkIn((_inlineState$
|
|
258
|
+
if (isWalkIn((_inlineState$client5 = inlineState.client) === null || _inlineState$client5 === void 0 || (_inlineState$client5 = _inlineState$client5.value) === null || _inlineState$client5 === void 0 ? void 0 : _inlineState$client5.id)) return;
|
|
221
259
|
inlineDispatch({
|
|
222
260
|
type: "setPet",
|
|
223
|
-
payload: { holders: [obj, ...((_inlineState$
|
|
261
|
+
payload: { holders: [obj, ...((_inlineState$pet6 = inlineState.pet) === null || _inlineState$pet6 === void 0 ? void 0 : _inlineState$pet6.holders) || []] }
|
|
224
262
|
});
|
|
225
263
|
upsertHolderOptions([obj], currentCacheItem);
|
|
264
|
+
if (isInline && !isNormalProduct) applyCreatedHolderSelection(obj);
|
|
226
265
|
selectCreatedHolder(obj);
|
|
227
266
|
});
|
|
228
267
|
return function callback(_x) {
|
|
229
|
-
return
|
|
268
|
+
return _ref10.apply(this, arguments);
|
|
230
269
|
};
|
|
231
270
|
}()
|
|
232
271
|
});
|
|
233
272
|
});
|
|
234
273
|
return function run() {
|
|
235
|
-
return
|
|
274
|
+
return _ref11.apply(this, arguments);
|
|
236
275
|
};
|
|
237
276
|
})()().catch((error) => {
|
|
238
277
|
console.warn("[SalesSdk] open add holder form failed", error);
|
|
@@ -244,7 +283,7 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
244
283
|
handleApply(nextValues);
|
|
245
284
|
}, [handleApply]);
|
|
246
285
|
const handleEdit = useCallback(function() {
|
|
247
|
-
var
|
|
286
|
+
var _ref12 = _asyncToGenerator(function* (event) {
|
|
248
287
|
var _latestCacheItem$_ext, _latestCacheItem$_ext2, _state$client;
|
|
249
288
|
event === null || event === void 0 || event.preventDefault();
|
|
250
289
|
const latestCacheItem = (getCurrentCacheItem === null || getCurrentCacheItem === void 0 ? void 0 : getCurrentCacheItem()) || cacheItem;
|
|
@@ -263,7 +302,7 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
263
302
|
}
|
|
264
303
|
});
|
|
265
304
|
return function(_x2) {
|
|
266
|
-
return
|
|
305
|
+
return _ref12.apply(this, arguments);
|
|
267
306
|
};
|
|
268
307
|
}(), [
|
|
269
308
|
bridges.holder,
|
|
@@ -298,7 +337,7 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
298
337
|
holders: inlineHolders,
|
|
299
338
|
productSource: currentCacheItem,
|
|
300
339
|
holderTitle: title,
|
|
301
|
-
customerId: inlineState === null || inlineState === void 0 || (_inlineState$
|
|
340
|
+
customerId: inlineState === null || inlineState === void 0 || (_inlineState$client6 = inlineState.client) === null || _inlineState$client6 === void 0 || (_inlineState$client6 = _inlineState$client6.value) === null || _inlineState$client6 === void 0 ? void 0 : _inlineState$client6.id,
|
|
302
341
|
initialValue: selectedValues,
|
|
303
342
|
maxSelectedCount,
|
|
304
343
|
onAddHolder: action ? handleAddHolder : void 0,
|
|
@@ -6,12 +6,12 @@ import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
6
6
|
import { locales } from "@pisell/utils";
|
|
7
7
|
import { Button, PisellEmpty, PisellModal, PisellStatisticList, Skeleton, Timeline, usePisellConfig } from "@pisell/materials";
|
|
8
8
|
import { useRequest } from "ahooks";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import timezonePlugin from "dayjs/plugin/timezone";
|
|
10
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
11
11
|
import "./index.less";
|
|
12
12
|
//#region src/plus/walletPassGallery/components/timelineSection/index.tsx
|
|
13
|
-
dayjs.extend(
|
|
14
|
-
dayjs.extend(
|
|
13
|
+
dayjs.extend(timezonePlugin);
|
|
14
|
+
dayjs.extend(utcPlugin);
|
|
15
15
|
const stateTimeUnix = 1723255863;
|
|
16
16
|
const POLL_INTERVAL = 2e3;
|
|
17
17
|
const POLL_MAX_TIMES = 5;
|
|
@@ -33,7 +33,7 @@ function hasHolderFormFields(formDataConfig) {
|
|
|
33
33
|
return Array.isArray(formDataConfig === null || formDataConfig === void 0 ? void 0 : formDataConfig.field) || Array.isArray(formDataConfig === null || formDataConfig === void 0 ? void 0 : formDataConfig.form_field);
|
|
34
34
|
}
|
|
35
35
|
const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, getCurrentCacheItem, presentation = "modal" }) => {
|
|
36
|
-
var _context$appHelper, _currentCacheItem$_ex, _cacheItem$_extend, _inlinePet$formData, _state$pet, _state$pet6, _state$pet7, _state$pet8, _inlineState$pet2, _state$client2, _inlineState$
|
|
36
|
+
var _context$appHelper, _currentCacheItem$_ex, _cacheItem$_extend, _inlinePet$formData, _state$pet, _state$pet6, _state$pet7, _state$pet8, _inlineState$client, _inlineState$pet2, _state$client2, _inlineState$client6;
|
|
37
37
|
const bridges = require_SalesSdkHostBridgesContext.useSalesSdkHostBridges();
|
|
38
38
|
const platform = require_useEngineContext.usePlatform();
|
|
39
39
|
const context = require_useEngineContext.default();
|
|
@@ -124,6 +124,33 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
124
124
|
const handleApply = (0, react.useCallback)((nextValues) => {
|
|
125
125
|
onChange === null || onChange === void 0 || onChange(nextValues);
|
|
126
126
|
}, [onChange]);
|
|
127
|
+
const defaultSelectionKey = JSON.stringify([inlineState === null || inlineState === void 0 || (_inlineState$client = inlineState.client) === null || _inlineState$client === void 0 || (_inlineState$client = _inlineState$client.value) === null || _inlineState$client === void 0 ? void 0 : _inlineState$client.id, currentHolderFormId]);
|
|
128
|
+
const defaultSelectionRef = (0, react.useRef)(null);
|
|
129
|
+
(0, react.useEffect)(() => {
|
|
130
|
+
var _ref4, _holder$id;
|
|
131
|
+
if (!isInline || !isRequired || maxSelectedCount !== 1) return;
|
|
132
|
+
if (defaultSelectionRef.current === defaultSelectionKey) return;
|
|
133
|
+
if (selectedValues.length) {
|
|
134
|
+
defaultSelectionRef.current = defaultSelectionKey;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (!Array.isArray(inlinePet.holders)) return;
|
|
138
|
+
if (inlinePet.holders.length !== 1) return;
|
|
139
|
+
const holder = inlinePet.holders[0];
|
|
140
|
+
const id = (_ref4 = (_holder$id = holder === null || holder === void 0 ? void 0 : holder.id) !== null && _holder$id !== void 0 ? _holder$id : holder === null || holder === void 0 ? void 0 : holder.form_record_id) !== null && _ref4 !== void 0 ? _ref4 : holder === null || holder === void 0 ? void 0 : holder.value;
|
|
141
|
+
if (id == null) return;
|
|
142
|
+
defaultSelectionRef.current = defaultSelectionKey;
|
|
143
|
+
setSelectedValues([id]);
|
|
144
|
+
handleApply([id]);
|
|
145
|
+
}, [
|
|
146
|
+
defaultSelectionKey,
|
|
147
|
+
handleApply,
|
|
148
|
+
inlinePet.holders,
|
|
149
|
+
isInline,
|
|
150
|
+
isRequired,
|
|
151
|
+
maxSelectedCount,
|
|
152
|
+
selectedValues
|
|
153
|
+
]);
|
|
127
154
|
const { formDataConfig, isMinorAndWaiver } = (0, react.useMemo)(() => {
|
|
128
155
|
var _inlineState$pet;
|
|
129
156
|
const productHolderFormData = inlineState === null || inlineState === void 0 || (_inlineState$pet = inlineState.pet) === null || _inlineState$pet === void 0 || (_inlineState$pet = _inlineState$pet.formData) === null || _inlineState$pet === void 0 ? void 0 : _inlineState$pet[0];
|
|
@@ -141,9 +168,9 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
141
168
|
};
|
|
142
169
|
}, [inlineState === null || inlineState === void 0 || (_inlineState$pet2 = inlineState.pet) === null || _inlineState$pet2 === void 0 ? void 0 : _inlineState$pet2.formData]);
|
|
143
170
|
const refreshHoldersFromServer = (0, ahooks.useMemoizedFn)(require_asyncToGenerator._asyncToGenerator(function* () {
|
|
144
|
-
var _inlineState$
|
|
171
|
+
var _inlineState$client2;
|
|
145
172
|
const params = require_enrichCartLineHolderDisplay.buildHolderListRequestParams({
|
|
146
|
-
customerId: inlineState === null || inlineState === void 0 || (_inlineState$
|
|
173
|
+
customerId: inlineState === null || inlineState === void 0 || (_inlineState$client2 = inlineState.client) === null || _inlineState$client2 === void 0 || (_inlineState$client2 = _inlineState$client2.value) === null || _inlineState$client2 === void 0 ? void 0 : _inlineState$client2.id,
|
|
147
174
|
source: currentCacheItem
|
|
148
175
|
});
|
|
149
176
|
if (!params) return;
|
|
@@ -157,20 +184,23 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
157
184
|
reloadHolderOptions();
|
|
158
185
|
return list;
|
|
159
186
|
}));
|
|
160
|
-
const
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
const id = (_ref4 = (_holder$id = holder === null || holder === void 0 ? void 0 : holder.id) !== null && _holder$id !== void 0 ? _holder$id : holder === null || holder === void 0 ? void 0 : holder.form_record_id) !== null && _ref4 !== void 0 ? _ref4 : holder === null || holder === void 0 ? void 0 : holder.value;
|
|
187
|
+
const applyCreatedHolderSelection = (0, ahooks.useMemoizedFn)((holder) => {
|
|
188
|
+
var _ref5, _holder$id2;
|
|
189
|
+
const id = (_ref5 = (_holder$id2 = holder === null || holder === void 0 ? void 0 : holder.id) !== null && _holder$id2 !== void 0 ? _holder$id2 : holder === null || holder === void 0 ? void 0 : holder.form_record_id) !== null && _ref5 !== void 0 ? _ref5 : holder === null || holder === void 0 ? void 0 : holder.value;
|
|
164
190
|
if (id == null || selectedValues.some((value) => String(value) === String(id))) return;
|
|
165
191
|
const nextValues = maxSelectedCount === 1 ? [id] : [...selectedValues.slice(0, Math.max(0, maxSelectedCount - 1)), id];
|
|
166
192
|
setSelectedValues(nextValues);
|
|
167
193
|
handleApply(nextValues);
|
|
168
194
|
});
|
|
195
|
+
const selectCreatedHolder = (0, ahooks.useMemoizedFn)((holder) => {
|
|
196
|
+
if (!isNormalProduct) return;
|
|
197
|
+
applyCreatedHolderSelection(holder);
|
|
198
|
+
});
|
|
169
199
|
const handleAddHolder = (0, ahooks.useMemoizedFn)(() => {
|
|
170
200
|
if (!action || !inlineState) return;
|
|
171
201
|
(function() {
|
|
172
|
-
var
|
|
173
|
-
var _inlineState$pet3, _waiverForm$form_id, _inlineState$
|
|
202
|
+
var _ref11 = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
203
|
+
var _inlineState$pet3, _waiverForm$form_id, _inlineState$client3, _inlineState$pet4, _inlineState$client4;
|
|
174
204
|
let waiverForm = (_inlineState$pet3 = inlineState.pet) === null || _inlineState$pet3 === void 0 ? void 0 : _inlineState$pet3.waiverForm;
|
|
175
205
|
if (isMinorAndWaiver && !hasHolderFormFields(waiverForm)) {
|
|
176
206
|
waiverForm = yield require_waiverFormDetailCache.getCachedWaiverFormDetail(Number(isMinorAndWaiver), platform);
|
|
@@ -181,37 +211,45 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
181
211
|
}
|
|
182
212
|
const resolvedActionFormDataConfig = require_productHolderConfig.ensureProductHolderFormId(isMinorAndWaiver ? require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, waiverForm), {}, {
|
|
183
213
|
form_id: (_waiverForm$form_id = waiverForm === null || waiverForm === void 0 ? void 0 : waiverForm.form_id) !== null && _waiverForm$form_id !== void 0 ? _waiverForm$form_id : Number(isMinorAndWaiver),
|
|
184
|
-
customer_id: (_inlineState$
|
|
214
|
+
customer_id: (_inlineState$client3 = inlineState.client) === null || _inlineState$client3 === void 0 || (_inlineState$client3 = _inlineState$client3.value) === null || _inlineState$client3 === void 0 ? void 0 : _inlineState$client3.id,
|
|
185
215
|
is_franchisor: formDataConfig === null || formDataConfig === void 0 ? void 0 : formDataConfig.is_franchisor
|
|
186
216
|
}) : require_objectSpread2._objectSpread2({}, formDataConfig || {}), currentCacheItem);
|
|
187
217
|
if (resolvedActionFormDataConfig.form_id === void 0 || resolvedActionFormDataConfig.form_id === null || resolvedActionFormDataConfig.form_id === "") {
|
|
188
218
|
antd.message.error(_pisell_utils.locales.getText("pisell-select-holder-form-unavailable"));
|
|
189
219
|
return;
|
|
190
220
|
}
|
|
221
|
+
const previousHolderIds = new Set((((_inlineState$pet4 = inlineState.pet) === null || _inlineState$pet4 === void 0 ? void 0 : _inlineState$pet4.holders) || []).map((holder) => {
|
|
222
|
+
var _ref6, _holder$id3;
|
|
223
|
+
return String((_ref6 = (_holder$id3 = holder.id) !== null && _holder$id3 !== void 0 ? _holder$id3 : holder.form_record_id) !== null && _ref6 !== void 0 ? _ref6 : holder.value);
|
|
224
|
+
}));
|
|
191
225
|
action({
|
|
192
226
|
type: "pisell1.goCustomFormAddData",
|
|
193
227
|
data: {
|
|
194
228
|
zIndex: 1101,
|
|
195
|
-
customerId: (_inlineState$
|
|
229
|
+
customerId: (_inlineState$client4 = inlineState.client) === null || _inlineState$client4 === void 0 || (_inlineState$client4 = _inlineState$client4.value) === null || _inlineState$client4 === void 0 ? void 0 : _inlineState$client4.id,
|
|
196
230
|
formDataConfig: resolvedActionFormDataConfig
|
|
197
231
|
},
|
|
198
232
|
callback: function() {
|
|
199
|
-
var
|
|
200
|
-
var _inlineState$
|
|
233
|
+
var _ref10 = require_asyncToGenerator._asyncToGenerator(function* (res) {
|
|
234
|
+
var _inlineState$client5, _inlineState$pet6;
|
|
201
235
|
const obj = {};
|
|
202
236
|
for (const item of Array.isArray(res) ? res : []) obj[item.key] = item.value;
|
|
203
237
|
if (isMinorAndWaiver) {
|
|
204
238
|
try {
|
|
205
239
|
const list = yield refreshHoldersFromServer();
|
|
240
|
+
if (isInline && !isNormalProduct) applyCreatedHolderSelection(list === null || list === void 0 ? void 0 : list.find((holder) => {
|
|
241
|
+
var _ref7, _holder$id4;
|
|
242
|
+
return !previousHolderIds.has(String((_ref7 = (_holder$id4 = holder.id) !== null && _holder$id4 !== void 0 ? _holder$id4 : holder.form_record_id) !== null && _ref7 !== void 0 ? _ref7 : holder.value));
|
|
243
|
+
}));
|
|
206
244
|
if (isNormalProduct) {
|
|
207
|
-
var _inlineState$
|
|
208
|
-
const previousIds = new Set((((_inlineState$
|
|
209
|
-
var
|
|
210
|
-
return String((
|
|
245
|
+
var _inlineState$pet5;
|
|
246
|
+
const previousIds = new Set((((_inlineState$pet5 = inlineState.pet) === null || _inlineState$pet5 === void 0 ? void 0 : _inlineState$pet5.holders) || []).map((holder) => {
|
|
247
|
+
var _ref8, _holder$id5;
|
|
248
|
+
return String((_ref8 = (_holder$id5 = holder.id) !== null && _holder$id5 !== void 0 ? _holder$id5 : holder.form_record_id) !== null && _ref8 !== void 0 ? _ref8 : holder.value);
|
|
211
249
|
}));
|
|
212
250
|
selectCreatedHolder(list === null || list === void 0 ? void 0 : list.find((holder) => {
|
|
213
|
-
var
|
|
214
|
-
return !previousIds.has(String((
|
|
251
|
+
var _ref9, _holder$id6;
|
|
252
|
+
return !previousIds.has(String((_ref9 = (_holder$id6 = holder.id) !== null && _holder$id6 !== void 0 ? _holder$id6 : holder.form_record_id) !== null && _ref9 !== void 0 ? _ref9 : holder.value));
|
|
215
253
|
}));
|
|
216
254
|
}
|
|
217
255
|
} catch (err) {
|
|
@@ -219,22 +257,23 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
219
257
|
}
|
|
220
258
|
return;
|
|
221
259
|
}
|
|
222
|
-
if (require_utils$1.isWalkIn((_inlineState$
|
|
260
|
+
if (require_utils$1.isWalkIn((_inlineState$client5 = inlineState.client) === null || _inlineState$client5 === void 0 || (_inlineState$client5 = _inlineState$client5.value) === null || _inlineState$client5 === void 0 ? void 0 : _inlineState$client5.id)) return;
|
|
223
261
|
inlineDispatch({
|
|
224
262
|
type: "setPet",
|
|
225
|
-
payload: { holders: [obj, ...((_inlineState$
|
|
263
|
+
payload: { holders: [obj, ...((_inlineState$pet6 = inlineState.pet) === null || _inlineState$pet6 === void 0 ? void 0 : _inlineState$pet6.holders) || []] }
|
|
226
264
|
});
|
|
227
265
|
upsertHolderOptions([obj], currentCacheItem);
|
|
266
|
+
if (isInline && !isNormalProduct) applyCreatedHolderSelection(obj);
|
|
228
267
|
selectCreatedHolder(obj);
|
|
229
268
|
});
|
|
230
269
|
return function callback(_x) {
|
|
231
|
-
return
|
|
270
|
+
return _ref10.apply(this, arguments);
|
|
232
271
|
};
|
|
233
272
|
}()
|
|
234
273
|
});
|
|
235
274
|
});
|
|
236
275
|
return function run() {
|
|
237
|
-
return
|
|
276
|
+
return _ref11.apply(this, arguments);
|
|
238
277
|
};
|
|
239
278
|
})()().catch((error) => {
|
|
240
279
|
console.warn("[SalesSdk] open add holder form failed", error);
|
|
@@ -246,7 +285,7 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
246
285
|
handleApply(nextValues);
|
|
247
286
|
}, [handleApply]);
|
|
248
287
|
const handleEdit = (0, react.useCallback)(function() {
|
|
249
|
-
var
|
|
288
|
+
var _ref12 = require_asyncToGenerator._asyncToGenerator(function* (event) {
|
|
250
289
|
var _latestCacheItem$_ext, _latestCacheItem$_ext2, _state$client;
|
|
251
290
|
event === null || event === void 0 || event.preventDefault();
|
|
252
291
|
const latestCacheItem = (getCurrentCacheItem === null || getCurrentCacheItem === void 0 ? void 0 : getCurrentCacheItem()) || cacheItem;
|
|
@@ -265,7 +304,7 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
265
304
|
}
|
|
266
305
|
});
|
|
267
306
|
return function(_x2) {
|
|
268
|
-
return
|
|
307
|
+
return _ref12.apply(this, arguments);
|
|
269
308
|
};
|
|
270
309
|
}(), [
|
|
271
310
|
bridges.holder,
|
|
@@ -300,7 +339,7 @@ const BookingEditHolderField = ({ state, cacheItem, required, value, onChange, g
|
|
|
300
339
|
holders: inlineHolders,
|
|
301
340
|
productSource: currentCacheItem,
|
|
302
341
|
holderTitle: title,
|
|
303
|
-
customerId: inlineState === null || inlineState === void 0 || (_inlineState$
|
|
342
|
+
customerId: inlineState === null || inlineState === void 0 || (_inlineState$client6 = inlineState.client) === null || _inlineState$client6 === void 0 || (_inlineState$client6 = _inlineState$client6.value) === null || _inlineState$client6 === void 0 ? void 0 : _inlineState$client6.id,
|
|
304
343
|
initialValue: selectedValues,
|
|
305
344
|
maxSelectedCount,
|
|
306
345
|
onAddHolder: action ? handleAddHolder : void 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.364",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"use-sync-external-store": "^1.6.0",
|
|
76
76
|
"@pisell/pi-payment-sdk": "0.0.4",
|
|
77
77
|
"@pisell/utils": "3.0.7",
|
|
78
|
-
"@pisell/materials": "6.12.
|
|
79
|
-
"@pisell/
|
|
80
|
-
"@pisell/
|
|
78
|
+
"@pisell/materials": "6.12.87",
|
|
79
|
+
"@pisell/date-picker": "3.0.12",
|
|
80
|
+
"@pisell/icon": "0.0.11"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"react": "^18.0.0",
|