@pisell/private-materials 6.11.661 → 6.11.662
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 +18 -18
- package/build/lowcode/view.js +18 -18
- package/es/components/booking/utils.js +1 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.js +5 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/index.js +9 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/SelectDate/index.js +3 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/index.d.ts +5 -0
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/index.js +2 -1
- package/es/plus/salesSdk/normalProductDetail/NormalProductDetailHostRenderer.js +103 -43
- package/es/plus/salesSdk/normalProductDetail/availabilityContextRouting.js +29 -0
- package/es/pro/skuDetailModal/flow/modules/date/availabilityWindow.js +71 -0
- package/es/pro/skuDetailModal/flow/modules/date/index.js +24 -9
- package/es/pro/skuDetailModal/flow/modules/time/index.js +28 -13
- package/es/pro/skuDetailModal/flow/modules/time/posCustomTime.js +7 -1
- package/es/pro/skuDetailModal/flow/types.d.ts +8 -0
- package/lib/components/booking/utils.js +1 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.js +5 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/index.js +9 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/SelectDate/index.js +3 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/index.d.ts +5 -0
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/index.js +2 -1
- package/lib/plus/salesSdk/normalProductDetail/NormalProductDetailHostRenderer.js +103 -43
- package/lib/plus/salesSdk/normalProductDetail/availabilityContextRouting.js +32 -0
- package/lib/pro/skuDetailModal/flow/modules/date/availabilityWindow.js +74 -0
- package/lib/pro/skuDetailModal/flow/modules/date/index.js +24 -9
- package/lib/pro/skuDetailModal/flow/modules/time/index.js +27 -12
- package/lib/pro/skuDetailModal/flow/modules/time/posCustomTime.js +8 -0
- package/lib/pro/skuDetailModal/flow/types.d.ts +8 -0
- package/package.json +4 -4
|
@@ -21,6 +21,7 @@ const require_transformNormalProductConfirm = require("./transformNormalProductC
|
|
|
21
21
|
const require_resolveBookingCommitCount = require("./resolveBookingCommitCount.js");
|
|
22
22
|
const require_bookingSelectionPrice = require("./bookingSelectionPrice.js");
|
|
23
23
|
const require_buildBookingSelectionCacheItem = require("./buildBookingSelectionCacheItem.js");
|
|
24
|
+
const require_availabilityContextRouting = require("./availabilityContextRouting.js");
|
|
24
25
|
let dayjs = require("dayjs");
|
|
25
26
|
dayjs = require_runtime.__toESM(dayjs);
|
|
26
27
|
let react = require("react");
|
|
@@ -118,11 +119,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
118
119
|
tempOrderRef.current = tempOrder;
|
|
119
120
|
const handledDismissRevisionRef = (0, react.useRef)(dismissRevision);
|
|
120
121
|
const availabilityContextIdRef = (0, react.useRef)(null);
|
|
122
|
+
const availabilityContextsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
121
123
|
const releaseAvailabilityContext = (0, ahooks.useMemoizedFn)(() => {
|
|
122
|
-
const
|
|
123
|
-
if (!contextId) return;
|
|
124
|
+
const contextIds = Array.from(availabilityContextsRef.current.keys());
|
|
124
125
|
availabilityContextIdRef.current = null;
|
|
125
|
-
|
|
126
|
+
availabilityContextsRef.current.clear();
|
|
127
|
+
contextIds.forEach((contextId) => {
|
|
128
|
+
salesModule.releaseAvailabilityContext(contextId);
|
|
129
|
+
});
|
|
126
130
|
});
|
|
127
131
|
const commitAvailabilitySelection = (0, ahooks.useMemoizedFn)(function() {
|
|
128
132
|
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (orderProduct, selection, commit) {
|
|
@@ -217,7 +221,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
217
221
|
activePendingRef.current = null;
|
|
218
222
|
};
|
|
219
223
|
(function() {
|
|
220
|
-
var
|
|
224
|
+
var _ref19 = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
221
225
|
var _bookingTicket$getBoo3, _bookingTicket$getBoo4;
|
|
222
226
|
const payload = capturedPending.payload;
|
|
223
227
|
let openArgs;
|
|
@@ -252,12 +256,25 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
252
256
|
const prepareAvailability = (productId, date, editingProductLineUids) => {
|
|
253
257
|
const numericProductId = Number(productId);
|
|
254
258
|
if (!Number.isFinite(numericProductId)) throw new Error("预约商品缺少有效 product id。");
|
|
259
|
+
const initialScheduleDate = (0, dayjs.default)(date).format("YYYY-MM-DD");
|
|
260
|
+
const initialDateRange = {
|
|
261
|
+
startDate: initialScheduleDate,
|
|
262
|
+
endDate: (0, dayjs.default)(initialScheduleDate).add(31, "day").format("YYYY-MM-DD")
|
|
263
|
+
};
|
|
255
264
|
let availabilityReady;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
265
|
+
let dateAvailabilityContextId = null;
|
|
266
|
+
let latestDateRangeRequestId = 0;
|
|
267
|
+
const dateRangePrepareTasks = /* @__PURE__ */ new Map();
|
|
268
|
+
const getRegisteredContexts = () => Array.from(availabilityContextsRef.current.values());
|
|
269
|
+
const prepareDateRange = (dateRange) => {
|
|
270
|
+
const coveringContext = [...getRegisteredContexts()].reverse().find((item) => require_availabilityContextRouting.availabilityDateRangeContains(item.dateRange, dateRange));
|
|
271
|
+
if (coveringContext) return Promise.resolve(coveringContext.contextId);
|
|
272
|
+
const rangeKey = `${dateRange.startDate}:${dateRange.endDate}`;
|
|
273
|
+
const pendingRange = dateRangePrepareTasks.get(rangeKey);
|
|
274
|
+
if (pendingRange) return pendingRange;
|
|
275
|
+
const task = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
259
276
|
var _getProductCatalog;
|
|
260
|
-
const scheduleDate =
|
|
277
|
+
const scheduleDate = dateRange.startDate;
|
|
261
278
|
const availabilityProduct = yield salesModule.queryProductDetail({
|
|
262
279
|
product_id: numericProductId,
|
|
263
280
|
schedule_date: scheduleDate,
|
|
@@ -271,35 +288,78 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
271
288
|
catalogWithAvailabilityProduct.push(availabilityProduct);
|
|
272
289
|
const prepared = yield salesModule.prepareAvailabilityProjection(require_objectSpread2._objectSpread2({
|
|
273
290
|
productIds: [numericProductId],
|
|
291
|
+
dateRange,
|
|
274
292
|
rawProducts: catalogWithAvailabilityProduct
|
|
275
293
|
}, (editingProductLineUids === null || editingProductLineUids === void 0 ? void 0 : editingProductLineUids.length) ? { editingProductLineUids } : {}));
|
|
276
294
|
if (!isCurrentPending()) {
|
|
277
295
|
salesModule.releaseAvailabilityContext(prepared.contextId);
|
|
278
296
|
throw new Error("预约商品选择已取消。");
|
|
279
297
|
}
|
|
280
|
-
|
|
298
|
+
availabilityContextsRef.current.set(prepared.contextId, {
|
|
299
|
+
contextId: prepared.contextId,
|
|
300
|
+
dateRange
|
|
301
|
+
});
|
|
281
302
|
return prepared.contextId;
|
|
282
303
|
})();
|
|
304
|
+
dateRangePrepareTasks.set(rangeKey, task);
|
|
305
|
+
task.finally(() => {
|
|
306
|
+
if (dateRangePrepareTasks.get(rangeKey) === task) dateRangePrepareTasks.delete(rangeKey);
|
|
307
|
+
}).catch(() => void 0);
|
|
308
|
+
return task;
|
|
309
|
+
};
|
|
310
|
+
const getAvailabilityReady = () => {
|
|
311
|
+
if (availabilityReady) return availabilityReady;
|
|
312
|
+
availabilityReady = prepareDateRange(initialDateRange).then((contextId) => {
|
|
313
|
+
dateAvailabilityContextId = contextId;
|
|
314
|
+
availabilityContextIdRef.current = contextId;
|
|
315
|
+
return contextId;
|
|
316
|
+
});
|
|
283
317
|
availabilityReady.catch((error) => {
|
|
284
318
|
if (isCurrentPending()) console.warn("[SalesSdk] Availability context 初始化失败", error);
|
|
285
319
|
});
|
|
286
320
|
return availabilityReady;
|
|
287
321
|
};
|
|
322
|
+
const ensureDateRange = function() {
|
|
323
|
+
var _ref4 = require_asyncToGenerator._asyncToGenerator(function* (dateRange) {
|
|
324
|
+
yield getAvailabilityReady();
|
|
325
|
+
const requestId = ++latestDateRangeRequestId;
|
|
326
|
+
const contextId = yield prepareDateRange(dateRange);
|
|
327
|
+
if (!isCurrentPending()) throw new Error("预约商品选择已取消。");
|
|
328
|
+
if (requestId === latestDateRangeRequestId) dateAvailabilityContextId = contextId;
|
|
329
|
+
});
|
|
330
|
+
return function ensureDateRange(_x6) {
|
|
331
|
+
return _ref4.apply(this, arguments);
|
|
332
|
+
};
|
|
333
|
+
}();
|
|
334
|
+
const resolveContextId = function() {
|
|
335
|
+
var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (request, target) {
|
|
336
|
+
const initialContextId = yield getAvailabilityReady();
|
|
337
|
+
if (target === "date") return dateAvailabilityContextId || initialContextId;
|
|
338
|
+
const contextId = require_availabilityContextRouting.resolveAvailabilityRequestContextId(getRegisteredContexts(), request, dateAvailabilityContextId || initialContextId) || initialContextId;
|
|
339
|
+
availabilityContextIdRef.current = contextId;
|
|
340
|
+
return contextId;
|
|
341
|
+
});
|
|
342
|
+
return function resolveContextId(_x7, _x8) {
|
|
343
|
+
return _ref5.apply(this, arguments);
|
|
344
|
+
};
|
|
345
|
+
}();
|
|
288
346
|
let availabilityQuerySequence = 0;
|
|
289
347
|
selectionFlowServices = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, selectionFlowServices), {}, { availability: {
|
|
290
348
|
contextId: `pending:${numericProductId}`,
|
|
291
349
|
productId,
|
|
292
350
|
partySize: 1,
|
|
351
|
+
ensureDateRange,
|
|
293
352
|
getProductTimeRanges: function() {
|
|
294
|
-
var
|
|
295
|
-
|
|
353
|
+
var _ref6 = require_asyncToGenerator._asyncToGenerator(function* (_contextId, request) {
|
|
354
|
+
const contextId = yield resolveContextId(request);
|
|
355
|
+
return salesModule.getProductTimeRanges(contextId, request);
|
|
296
356
|
});
|
|
297
|
-
return function getProductTimeRanges(
|
|
298
|
-
return
|
|
357
|
+
return function getProductTimeRanges(_x9, _x10) {
|
|
358
|
+
return _ref6.apply(this, arguments);
|
|
299
359
|
};
|
|
300
360
|
}(),
|
|
301
361
|
queryBookingAvailability: function() {
|
|
302
|
-
var
|
|
362
|
+
var _ref7 = require_asyncToGenerator._asyncToGenerator(function* (_contextId, request) {
|
|
303
363
|
availabilityQuerySequence += 1;
|
|
304
364
|
const callId = `${numericProductId}-${availabilityQuerySequence}`;
|
|
305
365
|
console.info("[SelectionFlowAvailability][queryBookingAvailability][input]", {
|
|
@@ -308,7 +368,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
308
368
|
request
|
|
309
369
|
});
|
|
310
370
|
try {
|
|
311
|
-
const contextId = yield
|
|
371
|
+
const contextId = yield resolveContextId(request, request.target);
|
|
312
372
|
const result = yield salesModule.queryBookingAvailability(contextId, request);
|
|
313
373
|
console.info("[SelectionFlowAvailability][queryBookingAvailability][output]", {
|
|
314
374
|
callId,
|
|
@@ -327,14 +387,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
327
387
|
throw error;
|
|
328
388
|
}
|
|
329
389
|
});
|
|
330
|
-
return function queryBookingAvailability(
|
|
331
|
-
return
|
|
390
|
+
return function queryBookingAvailability(_x11, _x12) {
|
|
391
|
+
return _ref7.apply(this, arguments);
|
|
332
392
|
};
|
|
333
393
|
}()
|
|
334
394
|
} });
|
|
335
395
|
};
|
|
336
396
|
const refreshHolderContextFromHydratedProduct = function() {
|
|
337
|
-
var
|
|
397
|
+
var _ref8 = require_asyncToGenerator._asyncToGenerator(function* ({ productData }) {
|
|
338
398
|
holderSource = productData;
|
|
339
399
|
try {
|
|
340
400
|
holderOptions = yield ensureHolderOptionsForSource(productData);
|
|
@@ -363,14 +423,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
363
423
|
holderSource: productData
|
|
364
424
|
});
|
|
365
425
|
});
|
|
366
|
-
return function refreshHolderContextFromHydratedProduct(
|
|
367
|
-
return
|
|
426
|
+
return function refreshHolderContextFromHydratedProduct(_x13) {
|
|
427
|
+
return _ref8.apply(this, arguments);
|
|
368
428
|
};
|
|
369
429
|
}();
|
|
370
430
|
if (payload.mode === "create") {
|
|
371
|
-
var
|
|
431
|
+
var _ref9, _detailPayload$produc;
|
|
372
432
|
const detailPayload = payload.requiresDetailPayload;
|
|
373
|
-
const item = require_resolveCatalogProductId.normalizeCatalogProduct((
|
|
433
|
+
const item = require_resolveCatalogProductId.normalizeCatalogProduct((_ref9 = (_detailPayload$produc = detailPayload.productData) !== null && _detailPayload$produc !== void 0 ? _detailPayload$produc : detailPayload.item) !== null && _ref9 !== void 0 ? _ref9 : {});
|
|
374
434
|
const detailProductData = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { is_eject: detailPayload.isEject });
|
|
375
435
|
const productId = require_resolveCatalogProductId.resolveCatalogProductId(item);
|
|
376
436
|
const rawDate = detailPayload.date;
|
|
@@ -382,26 +442,26 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
382
442
|
const liveTempOrder = (_bookingTicket$getTem = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getTem2 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem2 === void 0 ? void 0 : _bookingTicket$getTem2.call(bookingTicket)) !== null && _bookingTicket$getTem !== void 0 ? _bookingTicket$getTem : tempOrderRef.current;
|
|
383
443
|
if (usesUnifiedBookingSales) {
|
|
384
444
|
if (!bookingConfig && typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.initBookingContext) === "function") {
|
|
385
|
-
var
|
|
445
|
+
var _ref10, _result$bookingConfig, _bookingTicket$getBoo5;
|
|
386
446
|
const bookingIds = require_buildDefaultLoadProductsParams.collectBookingIdsFromTempOrder(liveTempOrder);
|
|
387
447
|
const result = yield bookingTicket.initBookingContext(require_buildDefaultLoadProductsParams.buildInitBookingContextParams(bookingConfigParams, {
|
|
388
448
|
date: (0, dayjs.default)(date),
|
|
389
449
|
bookingIds: bookingIds.length ? bookingIds : void 0,
|
|
390
450
|
loadResources: initializeFullBookingContext
|
|
391
451
|
}));
|
|
392
|
-
bookingConfig = (
|
|
452
|
+
bookingConfig = (_ref10 = (_result$bookingConfig = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig !== void 0 ? _result$bookingConfig : (_bookingTicket$getBoo5 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo5 === void 0 ? void 0 : _bookingTicket$getBoo5.call(bookingTicket)) !== null && _ref10 !== void 0 ? _ref10 : null;
|
|
393
453
|
}
|
|
394
454
|
} else if (typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.initBookingContext) !== "function") {
|
|
395
455
|
if (!bookingConfig) throw new Error("当前 SalesSdk 运行时不支持初始化 BookingContext。");
|
|
396
456
|
} else {
|
|
397
|
-
var
|
|
457
|
+
var _ref11, _result$bookingConfig2, _bookingTicket$getBoo6;
|
|
398
458
|
const bookingIds = require_buildDefaultLoadProductsParams.collectBookingIdsFromTempOrder(liveTempOrder);
|
|
399
459
|
const result = yield bookingTicket.initBookingContext(require_buildDefaultLoadProductsParams.buildInitBookingContextParams(bookingConfigParams, {
|
|
400
460
|
date: (0, dayjs.default)(date),
|
|
401
461
|
bookingIds: bookingIds.length ? bookingIds : void 0,
|
|
402
462
|
loadResources: true
|
|
403
463
|
}));
|
|
404
|
-
bookingConfig = (
|
|
464
|
+
bookingConfig = (_ref11 = (_result$bookingConfig2 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig2 !== void 0 ? _result$bookingConfig2 : (_bookingTicket$getBoo6 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo6 === void 0 ? void 0 : _bookingTicket$getBoo6.call(bookingTicket)) !== null && _ref11 !== void 0 ? _ref11 : null;
|
|
405
465
|
}
|
|
406
466
|
if (!usesUnifiedBookingSales && !bookingConfig) throw new Error("BookingContext 初始化完成后仍缺少 bookingConfig。");
|
|
407
467
|
const customerId = require_buildBookingEditDrawerState.resolveBookingEditCustomerId(liveTempOrder, detailPayload.customerId, bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getOrd2 = bookingTicket.getOrderCustomerSnapshot) === null || _bookingTicket$getOrd2 === void 0 || (_bookingTicket$getOrd2 = _bookingTicket$getOrd2.call(bookingTicket)) === null || _bookingTicket$getOrd2 === void 0 ? void 0 : _bookingTicket$getOrd2.id);
|
|
@@ -453,14 +513,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
453
513
|
return true;
|
|
454
514
|
} } : {}), {}, { skuDetailConfig });
|
|
455
515
|
} else if (payload.mode === "booking-create" || payload.mode === "booking-edit") {
|
|
456
|
-
var
|
|
516
|
+
var _ref12, _ref13, _ref14, _ref15, _bookingPayload$date, _bookingPayload$cache, _bookingTicket$getTem3, _bookingTicket$getTem4, _bookingTicket$getOrd3, _ref17, _bookingTicket$getRes3, _bookingTicket$getRes4, _initialCacheItem$_da, _ref18, _bookingPayload$catal, _initialCacheItem$_ex, _bookingTicket$getOth3, _initialCacheItem$_ex2;
|
|
457
517
|
const isBookingEdit = payload.mode === "booking-edit";
|
|
458
518
|
const bookingPayload = isBookingEdit ? payload.bookingEditPayload : payload.requiresBookingEditPayload;
|
|
459
519
|
selectionFlowServices = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, selectionFlowServices), {}, {
|
|
460
520
|
selectionFlowMode: isBookingEdit ? "edit" : "create",
|
|
461
521
|
deferAvailabilityCommit: Boolean(isBookingEdit && bookingPayload.deferCommit)
|
|
462
522
|
});
|
|
463
|
-
const item = require_resolveCatalogProductId.normalizeCatalogProduct((
|
|
523
|
+
const item = require_resolveCatalogProductId.normalizeCatalogProduct((_ref12 = (_ref13 = (_ref14 = (_ref15 = isBookingEdit ? bookingPayload.catalogProduct : null) !== null && _ref15 !== void 0 ? _ref15 : bookingPayload.catalogProduct) !== null && _ref14 !== void 0 ? _ref14 : bookingPayload.sourceProduct) !== null && _ref13 !== void 0 ? _ref13 : bookingPayload.cacheItem) !== null && _ref12 !== void 0 ? _ref12 : {});
|
|
464
524
|
const skuDetailConfig = mergeSkuDetailConfig(item === null || item === void 0 ? void 0 : item.skuDetailConfig, defaultSkuDetailConfig);
|
|
465
525
|
if (!(Array.isArray(skuDetailConfig.steps) || typeof skuDetailConfig.resolveSteps === "function") || require_index.getUnsupportedBookingFlowReason(item) && !require_utils.isMultiDayProduct(item) || !bookingTicket) {
|
|
466
526
|
completeCaptured({ mode: "booking-fallback" });
|
|
@@ -476,13 +536,13 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
476
536
|
const liveTempOrder = (_bookingTicket$getTem3 = (_bookingTicket$getTem4 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem4 === void 0 ? void 0 : _bookingTicket$getTem4.call(bookingTicket)) !== null && _bookingTicket$getTem3 !== void 0 ? _bookingTicket$getTem3 : tempOrderRef.current;
|
|
477
537
|
const bookingIds = require_buildDefaultLoadProductsParams.collectBookingIdsFromTempOrder(liveTempOrder);
|
|
478
538
|
if (typeof bookingTicket.initBookingContext === "function") {
|
|
479
|
-
var
|
|
539
|
+
var _ref16, _result$bookingConfig3, _bookingTicket$getBoo7;
|
|
480
540
|
const result = yield bookingTicket.initBookingContext(require_buildDefaultLoadProductsParams.buildInitBookingContextParams(bookingConfigParams, {
|
|
481
541
|
date: (0, dayjs.default)(date),
|
|
482
542
|
bookingIds: bookingIds.length ? bookingIds : void 0,
|
|
483
543
|
loadResources: !usesUnifiedBookingSales || initializeFullBookingContext
|
|
484
544
|
}));
|
|
485
|
-
bookingConfig = (
|
|
545
|
+
bookingConfig = (_ref16 = (_result$bookingConfig3 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig3 !== void 0 ? _result$bookingConfig3 : (_bookingTicket$getBoo7 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo7 === void 0 ? void 0 : _bookingTicket$getBoo7.call(bookingTicket)) !== null && _ref16 !== void 0 ? _ref16 : null;
|
|
486
546
|
}
|
|
487
547
|
if (!usesUnifiedBookingSales && !bookingConfig) throw new Error("预约 Selection Flow 初始化后仍缺少 bookingConfig。");
|
|
488
548
|
let initialCacheItem = bookingPayload.cacheItem;
|
|
@@ -494,10 +554,10 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
494
554
|
initialCacheItem = require_prepareCacheItemForBookingEdit.prepareCacheItemForBookingEdit(initialCacheItem);
|
|
495
555
|
if (isBookingEdit && bookingPayload.orderProduct) initialCacheItem = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, initialCacheItem), {}, { discount_list: Array.isArray(bookingPayload.orderProduct.discount_list) ? [...bookingPayload.orderProduct.discount_list] : [] });
|
|
496
556
|
const customerId = require_buildBookingEditDrawerState.resolveBookingEditCustomerId(liveTempOrder, bookingPayload.customerId, (_bookingTicket$getOrd3 = bookingTicket.getOrderCustomerSnapshot) === null || _bookingTicket$getOrd3 === void 0 || (_bookingTicket$getOrd3 = _bookingTicket$getOrd3.call(bookingTicket)) === null || _bookingTicket$getOrd3 === void 0 ? void 0 : _bookingTicket$getOrd3.id);
|
|
497
|
-
const resourcesOrigin = (
|
|
557
|
+
const resourcesOrigin = (_ref17 = (_bookingTicket$getRes3 = (_bookingTicket$getRes4 = bookingTicket.getResourcesOrigin) === null || _bookingTicket$getRes4 === void 0 ? void 0 : _bookingTicket$getRes4.call(bookingTicket)) !== null && _bookingTicket$getRes3 !== void 0 ? _bookingTicket$getRes3 : initialCacheItem === null || initialCacheItem === void 0 || (_initialCacheItem$_da = initialCacheItem._data) === null || _initialCacheItem$_da === void 0 ? void 0 : _initialCacheItem$_da.resourcesOrigin) !== null && _ref17 !== void 0 ? _ref17 : [];
|
|
498
558
|
initialCacheItem = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, initialCacheItem), {}, { _data: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, (initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem._data) || {}), {}, { resourcesOrigin }) });
|
|
499
559
|
bookingInitialCacheItem = initialCacheItem;
|
|
500
|
-
holderSource = (
|
|
560
|
+
holderSource = (_ref18 = (_bookingPayload$catal = bookingPayload.catalogProduct) !== null && _bookingPayload$catal !== void 0 ? _bookingPayload$catal : bookingPayload.sourceProduct) !== null && _ref18 !== void 0 ? _ref18 : initialCacheItem;
|
|
501
561
|
if (usesUnifiedBookingSales) holderOptions = getHolderOptionsForSource(holderSource);
|
|
502
562
|
else try {
|
|
503
563
|
holderOptions = yield ensureHolderOptionsForSource(holderSource);
|
|
@@ -582,7 +642,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
582
642
|
});
|
|
583
643
|
});
|
|
584
644
|
return function prepareOpen() {
|
|
585
|
-
return
|
|
645
|
+
return _ref19.apply(this, arguments);
|
|
586
646
|
};
|
|
587
647
|
})()().catch((error) => {
|
|
588
648
|
if (!isCurrentPending()) return;
|
|
@@ -632,7 +692,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
632
692
|
showHostError
|
|
633
693
|
]);
|
|
634
694
|
const handleConfirm = (0, ahooks.useMemoizedFn)(function() {
|
|
635
|
-
var
|
|
695
|
+
var _ref29 = require_asyncToGenerator._asyncToGenerator(function* (data) {
|
|
636
696
|
const activePending = activePendingRef.current;
|
|
637
697
|
if (!activePending || bridge.getSnapshot() !== activePending) return false;
|
|
638
698
|
const completeActive = (result) => {
|
|
@@ -643,9 +703,9 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
643
703
|
return true;
|
|
644
704
|
};
|
|
645
705
|
if (activePending.payload.mode === "create") {
|
|
646
|
-
var
|
|
706
|
+
var _ref20, _detailPayload$produc2;
|
|
647
707
|
const detailPayload = activePending.payload.requiresDetailPayload;
|
|
648
|
-
const item = require_resolveCatalogProductId.normalizeCatalogProduct((
|
|
708
|
+
const item = require_resolveCatalogProductId.normalizeCatalogProduct((_ref20 = (_detailPayload$produc2 = detailPayload.productData) !== null && _detailPayload$produc2 !== void 0 ? _detailPayload$produc2 : detailPayload.item) !== null && _ref20 !== void 0 ? _ref20 : {});
|
|
649
709
|
const productId = require_resolveCatalogProductId.resolveCatalogProductId(item);
|
|
650
710
|
if (!productId) {
|
|
651
711
|
console.warn("[SalesSdk] openNormalProductDetail: 商品缺少有效 id/product_id");
|
|
@@ -659,13 +719,13 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
659
719
|
let detailResult = require_transformNormalProductConfirm.transformNormalProductCreateConfirm(productId, data);
|
|
660
720
|
const holderIds = (_detailResult$detail = detailResult.detail) === null || _detailResult$detail === void 0 || (_detailResult$detail = _detailResult$detail._extend) === null || _detailResult$detail === void 0 ? void 0 : _detailResult$detail.holder_id;
|
|
661
721
|
if (Array.isArray(holderIds) && holderIds.length > 0 && activeBookingState) {
|
|
662
|
-
var _activeBookingState$b, _activeBookingState$c,
|
|
722
|
+
var _activeBookingState$b, _activeBookingState$c, _ref21, _ref22, _ref23;
|
|
663
723
|
detailResult = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, detailResult), {}, { detail: require_applyHolderToCacheItem.applyHolderToCacheItem(detailResult.detail, holderIds, {
|
|
664
724
|
bookingConfig: (_activeBookingState$b = activeBookingState.bookingConfig) !== null && _activeBookingState$b !== void 0 ? _activeBookingState$b : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingConfig,
|
|
665
725
|
customerId: (_activeBookingState$c = activeBookingState.client) === null || _activeBookingState$c === void 0 || (_activeBookingState$c = _activeBookingState$c.value) === null || _activeBookingState$c === void 0 ? void 0 : _activeBookingState$c.id,
|
|
666
726
|
isFranchisee: activeBookingState.isFranchisee,
|
|
667
727
|
holderOptions: activeHolderOptions,
|
|
668
|
-
productSource: (
|
|
728
|
+
productSource: (_ref21 = (_ref22 = (_ref23 = data !== null && data !== void 0 ? data : detailResult.detail) !== null && _ref23 !== void 0 ? _ref23 : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref22 !== void 0 ? _ref22 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref21 !== void 0 ? _ref21 : item
|
|
669
729
|
}) });
|
|
670
730
|
}
|
|
671
731
|
const availabilitySelection = (_detailResult$detail2 = detailResult.detail) === null || _detailResult$detail2 === void 0 || (_detailResult$detail2 = _detailResult$detail2._extend) === null || _detailResult$detail2 === void 0 ? void 0 : _detailResult$detail2.availabilitySelection;
|
|
@@ -690,11 +750,11 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
690
750
|
const isBookingEdit = activePending.payload.mode === "booking-edit";
|
|
691
751
|
const bookingPayload = isBookingEdit ? activePending.payload.bookingEditPayload : activePending.payload.requiresBookingEditPayload;
|
|
692
752
|
try {
|
|
693
|
-
var _hydratedContext$book2,
|
|
753
|
+
var _hydratedContext$book2, _ref24, _hydratedContext$hold2, _bookingState$booking, _bookingState$client, _ref25, _ref26, _ref27, _ref28, _cacheItem$_extend3;
|
|
694
754
|
if (isBookingEdit && !bookingPayload.deferCommit) require_resolveBookingCommitCount.assertBookingEditQuantityUnchanged(data);
|
|
695
755
|
const hydratedContext = (hydratedHolderContext === null || hydratedHolderContext === void 0 ? void 0 : hydratedHolderContext.pending) === activePending ? hydratedHolderContext : null;
|
|
696
756
|
const bookingState = (_hydratedContext$book2 = hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.bookingState) !== null && _hydratedContext$book2 !== void 0 ? _hydratedContext$book2 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingState;
|
|
697
|
-
const holderOptions = (
|
|
757
|
+
const holderOptions = (_ref24 = (_hydratedContext$hold2 = hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderOptions) !== null && _hydratedContext$hold2 !== void 0 ? _hydratedContext$hold2 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderOptions) !== null && _ref24 !== void 0 ? _ref24 : [];
|
|
698
758
|
const cacheItem = require_buildBookingSelectionCacheItem.buildBookingSelectionCacheItem(data, {
|
|
699
759
|
bookingConfig: (_bookingState$booking = bookingState === null || bookingState === void 0 ? void 0 : bookingState.bookingConfig) !== null && _bookingState$booking !== void 0 ? _bookingState$booking : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingConfig,
|
|
700
760
|
customerId: bookingState === null || bookingState === void 0 || (_bookingState$client = bookingState.client) === null || _bookingState$client === void 0 || (_bookingState$client = _bookingState$client.value) === null || _bookingState$client === void 0 ? void 0 : _bookingState$client.id,
|
|
@@ -702,7 +762,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
702
762
|
isPriceIncludeTax: data === null || data === void 0 ? void 0 : data.is_price_include_tax,
|
|
703
763
|
holderOptions,
|
|
704
764
|
initialCacheItem: preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.initialCacheItem,
|
|
705
|
-
productSource: (
|
|
765
|
+
productSource: (_ref25 = (_ref26 = (_ref27 = (_ref28 = data !== null && data !== void 0 ? data : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref28 !== void 0 ? _ref28 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref27 !== void 0 ? _ref27 : bookingPayload.catalogProduct) !== null && _ref26 !== void 0 ? _ref26 : bookingPayload.sourceProduct) !== null && _ref25 !== void 0 ? _ref25 : bookingPayload.cacheItem
|
|
706
766
|
});
|
|
707
767
|
cacheItem._holderOptionsSnapshot = holderOptions;
|
|
708
768
|
const selection = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.availabilitySelection;
|
|
@@ -753,8 +813,8 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
753
813
|
return false;
|
|
754
814
|
}
|
|
755
815
|
});
|
|
756
|
-
return function(
|
|
757
|
-
return
|
|
816
|
+
return function(_x14) {
|
|
817
|
+
return _ref29.apply(this, arguments);
|
|
758
818
|
};
|
|
759
819
|
}());
|
|
760
820
|
const handleClose = (0, ahooks.useMemoizedFn)(() => {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let dayjs = require("dayjs");
|
|
3
|
+
dayjs = require_runtime.__toESM(dayjs);
|
|
4
|
+
//#region src/plus/salesSdk/normalProductDetail/availabilityContextRouting.ts
|
|
5
|
+
const normalizeDate = (value) => {
|
|
6
|
+
if (value == null || value === "") return void 0;
|
|
7
|
+
const parsed = (0, dayjs.default)(value);
|
|
8
|
+
return parsed.isValid() ? parsed.format("YYYY-MM-DD") : void 0;
|
|
9
|
+
};
|
|
10
|
+
const availabilityDateRangeContains = (coverage, requested) => !(0, dayjs.default)(requested.startDate).isBefore((0, dayjs.default)(coverage.startDate), "day") && !(0, dayjs.default)(requested.endDate).isAfter((0, dayjs.default)(coverage.endDate), "day");
|
|
11
|
+
const resolveAvailabilityRequestContextId = (contexts, request, preferredContextId) => {
|
|
12
|
+
var _rangeCandidates$find, _rawDateRange$endDate, _contexts;
|
|
13
|
+
const candidateContextId = (_rangeCandidates$find = [...Array.isArray(request.candidates) ? request.candidates : [], ...Array.isArray(request.selectedRanges) ? request.selectedRanges : []].find((item) => typeof (item === null || item === void 0 ? void 0 : item.availabilityContextId) === "string")) === null || _rangeCandidates$find === void 0 ? void 0 : _rangeCandidates$find.availabilityContextId;
|
|
14
|
+
if (candidateContextId && contexts.some((item) => item.contextId === candidateContextId)) return candidateContextId;
|
|
15
|
+
const rawDateRange = request.dateRange;
|
|
16
|
+
const startDate = normalizeDate(rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.startDate);
|
|
17
|
+
const endDate = normalizeDate((_rawDateRange$endDate = rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.endDate) !== null && _rawDateRange$endDate !== void 0 ? _rawDateRange$endDate : rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.startDate);
|
|
18
|
+
if (startDate && endDate) {
|
|
19
|
+
var _reverse$find;
|
|
20
|
+
const requestedRange = {
|
|
21
|
+
startDate,
|
|
22
|
+
endDate
|
|
23
|
+
};
|
|
24
|
+
const preferred = contexts.find((item) => item.contextId === preferredContextId && availabilityDateRangeContains(item.dateRange, requestedRange));
|
|
25
|
+
if (preferred) return preferred.contextId;
|
|
26
|
+
return (_reverse$find = [...contexts].reverse().find((item) => availabilityDateRangeContains(item.dateRange, requestedRange))) === null || _reverse$find === void 0 ? void 0 : _reverse$find.contextId;
|
|
27
|
+
}
|
|
28
|
+
return contexts.some((item) => item.contextId === preferredContextId) ? preferredContextId || void 0 : (_contexts = contexts[contexts.length - 1]) === null || _contexts === void 0 ? void 0 : _contexts.contextId;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.availabilityDateRangeContains = availabilityDateRangeContains;
|
|
32
|
+
exports.resolveAvailabilityRequestContextId = resolveAvailabilityRequestContextId;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let dayjs = require("dayjs");
|
|
3
|
+
dayjs = require_runtime.__toESM(dayjs);
|
|
4
|
+
//#region src/pro/skuDetailModal/flow/modules/date/availabilityWindow.ts
|
|
5
|
+
const AVAILABILITY_RANGE_EDGE_DAYS = 7;
|
|
6
|
+
const AVAILABILITY_RANGE_PRELOAD_DAYS = 28;
|
|
7
|
+
const MAX_AVAILABILITY_RANGE_DAYS = 90;
|
|
8
|
+
const normalizeRange = (range) => {
|
|
9
|
+
const start = (0, dayjs.default)(range.startDate);
|
|
10
|
+
const end = (0, dayjs.default)(range.endDate);
|
|
11
|
+
if (!start.isValid() || !end.isValid()) return null;
|
|
12
|
+
return start.isAfter(end, "day") ? {
|
|
13
|
+
startDate: end.format("YYYY-MM-DD"),
|
|
14
|
+
endDate: start.format("YYYY-MM-DD")
|
|
15
|
+
} : {
|
|
16
|
+
startDate: start.format("YYYY-MM-DD"),
|
|
17
|
+
endDate: end.format("YYYY-MM-DD")
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const resolveAvailabilityDatesCoverage = (dates) => {
|
|
21
|
+
const normalizedDates = (dates || []).map((item) => (0, dayjs.default)(item === null || item === void 0 ? void 0 : item.date)).filter((date) => date.isValid()).sort((left, right) => left.valueOf() - right.valueOf());
|
|
22
|
+
if (normalizedDates.length === 0) return null;
|
|
23
|
+
return {
|
|
24
|
+
startDate: normalizedDates[0].format("YYYY-MM-DD"),
|
|
25
|
+
endDate: normalizedDates[normalizedDates.length - 1].format("YYYY-MM-DD")
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const inclusiveDays = (range) => (0, dayjs.default)(range.endDate).diff((0, dayjs.default)(range.startDate), "day") + 1;
|
|
29
|
+
/**
|
|
30
|
+
* 日历只在接近当前缓存边缘时向外扩展。能与现有覆盖合并且不超过 UBS
|
|
31
|
+
* 90 天上限时优先扩展;跨度更大时围绕用户正在查看的范围移动窗口。
|
|
32
|
+
*/
|
|
33
|
+
const resolveSlidingAvailabilityDateRange = (params) => {
|
|
34
|
+
const visibleRange = normalizeRange(params.visibleRange);
|
|
35
|
+
const coverage = resolveAvailabilityDatesCoverage(params.availabilityDates);
|
|
36
|
+
if (!visibleRange || !coverage) return null;
|
|
37
|
+
const visibleStart = (0, dayjs.default)(visibleRange.startDate);
|
|
38
|
+
const visibleEnd = (0, dayjs.default)(visibleRange.endDate);
|
|
39
|
+
const coverageStart = (0, dayjs.default)(coverage.startDate);
|
|
40
|
+
const coverageEnd = (0, dayjs.default)(coverage.endDate);
|
|
41
|
+
const beforeStart = visibleStart.isBefore(coverageStart, "day");
|
|
42
|
+
const nearEnd = visibleEnd.isAfter(coverageEnd.subtract(AVAILABILITY_RANGE_EDGE_DAYS, "day"), "day");
|
|
43
|
+
if (!beforeStart && !nearEnd) return null;
|
|
44
|
+
const browsingForward = !beforeStart;
|
|
45
|
+
const requestedStart = browsingForward ? coverageStart : visibleStart.subtract(AVAILABILITY_RANGE_PRELOAD_DAYS, "day");
|
|
46
|
+
const requestedEnd = browsingForward ? visibleEnd.add(AVAILABILITY_RANGE_PRELOAD_DAYS, "day") : coverageEnd;
|
|
47
|
+
const mergedRange = normalizeRange({
|
|
48
|
+
startDate: requestedStart.format("YYYY-MM-DD"),
|
|
49
|
+
endDate: requestedEnd.format("YYYY-MM-DD")
|
|
50
|
+
});
|
|
51
|
+
if (inclusiveDays(mergedRange) <= MAX_AVAILABILITY_RANGE_DAYS) return mergedRange;
|
|
52
|
+
if (browsingForward) {
|
|
53
|
+
const endDate = requestedEnd;
|
|
54
|
+
return {
|
|
55
|
+
startDate: endDate.subtract(MAX_AVAILABILITY_RANGE_DAYS - 1, "day").format("YYYY-MM-DD"),
|
|
56
|
+
endDate: endDate.format("YYYY-MM-DD")
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const startDate = requestedStart;
|
|
60
|
+
return {
|
|
61
|
+
startDate: startDate.format("YYYY-MM-DD"),
|
|
62
|
+
endDate: startDate.add(MAX_AVAILABILITY_RANGE_DAYS - 1, "day").format("YYYY-MM-DD")
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const mergeAvailabilityDates = (previousDates, nextDates) => {
|
|
66
|
+
const byDate = /* @__PURE__ */ new Map();
|
|
67
|
+
[...previousDates || [], ...nextDates].forEach((item) => {
|
|
68
|
+
if (typeof (item === null || item === void 0 ? void 0 : item.date) === "string" && (0, dayjs.default)(item.date).isValid()) byDate.set(item.date, item);
|
|
69
|
+
});
|
|
70
|
+
return Array.from(byDate.values()).sort((left, right) => (0, dayjs.default)(left.date).valueOf() - (0, dayjs.default)(right.date).valueOf());
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.mergeAvailabilityDates = mergeAvailabilityDates;
|
|
74
|
+
exports.resolveSlidingAvailabilityDateRange = resolveSlidingAvailabilityDateRange;
|
|
@@ -10,6 +10,7 @@ const require_utils$2 = require("../../../../../components/eventBooking/componen
|
|
|
10
10
|
const require_autoResolution = require("../autoResolution.js");
|
|
11
11
|
const require_index$1 = require("../../../../../components/eventBooking/components/bookingAvailabilityCalendar/index.js");
|
|
12
12
|
const require_MultiDayTimeSelect = require("../../../../multiDayTimeSelect/MultiDayTimeSelect.js");
|
|
13
|
+
const require_availabilityWindow = require("./availabilityWindow.js");
|
|
13
14
|
let dayjs = require("dayjs");
|
|
14
15
|
dayjs = require_runtime.__toESM(dayjs);
|
|
15
16
|
let react = require("react");
|
|
@@ -18,7 +19,7 @@ let antd = require("antd");
|
|
|
18
19
|
let _pisell_utils = require("@pisell/utils");
|
|
19
20
|
//#region src/pro/skuDetailModal/flow/modules/date/index.tsx
|
|
20
21
|
const refreshAvailabilityDates = function() {
|
|
21
|
-
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, module) {
|
|
22
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, module, requestedDateRange) {
|
|
22
23
|
const availability = context.services.availability;
|
|
23
24
|
const allowUnavailable = context.services.allowUnavailableBookingSelection === true;
|
|
24
25
|
const previousData = context.getModuleData(module.key);
|
|
@@ -26,11 +27,13 @@ const refreshAvailabilityDates = function() {
|
|
|
26
27
|
context.setModuleData(module.key, {
|
|
27
28
|
requestVersion,
|
|
28
29
|
status: "loading",
|
|
29
|
-
hasResolvedInitialDate: previousData === null || previousData === void 0 ? void 0 : previousData.hasResolvedInitialDate
|
|
30
|
+
hasResolvedInitialDate: previousData === null || previousData === void 0 ? void 0 : previousData.hasResolvedInitialDate,
|
|
31
|
+
availabilityDates: previousData === null || previousData === void 0 ? void 0 : previousData.availabilityDates
|
|
30
32
|
});
|
|
31
33
|
context.setModuleStatus(module.key, "loading");
|
|
32
34
|
try {
|
|
33
35
|
var _context$getModuleDat;
|
|
36
|
+
if (requestedDateRange && availability.ensureDateRange) yield availability.ensureDateRange(requestedDateRange);
|
|
34
37
|
const result = yield availability.queryBookingAvailability(availability.contextId, {
|
|
35
38
|
target: "date",
|
|
36
39
|
productIds: [availability.productId],
|
|
@@ -38,7 +41,8 @@ const refreshAvailabilityDates = function() {
|
|
|
38
41
|
});
|
|
39
42
|
if (((_context$getModuleDat = context.getModuleData(module.key)) === null || _context$getModuleDat === void 0 ? void 0 : _context$getModuleDat.requestVersion) !== requestVersion) return;
|
|
40
43
|
const group = result.data.find((item) => String(item === null || item === void 0 ? void 0 : item.productId) === String(availability.productId));
|
|
41
|
-
const
|
|
44
|
+
const queriedAvailabilityDates = Array.isArray(group === null || group === void 0 ? void 0 : group.dates) ? group.dates : [];
|
|
45
|
+
const availabilityDates = requestedDateRange ? require_availabilityWindow.mergeAvailabilityDates(previousData === null || previousData === void 0 ? void 0 : previousData.availabilityDates, queriedAvailabilityDates) : queriedAvailabilityDates;
|
|
42
46
|
const hasResolvedInitialDate = Boolean(previousData === null || previousData === void 0 ? void 0 : previousData.hasResolvedInitialDate);
|
|
43
47
|
context.setModuleData(module.key, {
|
|
44
48
|
requestVersion,
|
|
@@ -71,13 +75,15 @@ const refreshAvailabilityDates = function() {
|
|
|
71
75
|
context.setModuleData(module.key, {
|
|
72
76
|
requestVersion,
|
|
73
77
|
status: "error",
|
|
74
|
-
error
|
|
78
|
+
error,
|
|
79
|
+
availabilityDates: previousData === null || previousData === void 0 ? void 0 : previousData.availabilityDates,
|
|
80
|
+
hasResolvedInitialDate: previousData === null || previousData === void 0 ? void 0 : previousData.hasResolvedInitialDate
|
|
75
81
|
});
|
|
76
82
|
context.setModuleStatus(module.key, "error", message, error);
|
|
77
83
|
throw error;
|
|
78
84
|
}
|
|
79
85
|
});
|
|
80
|
-
return function refreshAvailabilityDates(_x, _x2) {
|
|
86
|
+
return function refreshAvailabilityDates(_x, _x2, _x3) {
|
|
81
87
|
return _ref.apply(this, arguments);
|
|
82
88
|
};
|
|
83
89
|
}();
|
|
@@ -141,7 +147,7 @@ const hydrateProductDataForDate = function() {
|
|
|
141
147
|
context.setModuleStatus(module.key, "loading");
|
|
142
148
|
return promise;
|
|
143
149
|
});
|
|
144
|
-
return function hydrateProductDataForDate(
|
|
150
|
+
return function hydrateProductDataForDate(_x4, _x5, _x6) {
|
|
145
151
|
return _ref2.apply(this, arguments);
|
|
146
152
|
};
|
|
147
153
|
}();
|
|
@@ -157,7 +163,7 @@ const awaitLatestDateHydration = function() {
|
|
|
157
163
|
}
|
|
158
164
|
if ((data === null || data === void 0 ? void 0 : data.status) === "error") throw data.error instanceof Error ? data.error : new Error(require_i18n.selectionFlowText("pisell2.text.sku.detail.modal.validation.date.refresh.failed"));
|
|
159
165
|
});
|
|
160
|
-
return function awaitLatestDateHydration(
|
|
166
|
+
return function awaitLatestDateHydration(_x7, _x8) {
|
|
161
167
|
return _ref3.apply(this, arguments);
|
|
162
168
|
};
|
|
163
169
|
}();
|
|
@@ -293,7 +299,7 @@ const DateFlowModuleComponent = ({ context, module, registerHandle }) => {
|
|
|
293
299
|
});
|
|
294
300
|
}
|
|
295
301
|
if (availability) {
|
|
296
|
-
if (
|
|
302
|
+
if (!(availabilityData === null || availabilityData === void 0 ? void 0 : availabilityData.availabilityDates)) return /* @__PURE__ */ react.default.createElement(require_LoadingPanel.default, null);
|
|
297
303
|
if (availabilityData.status === "error") {
|
|
298
304
|
var _context$moduleState$2;
|
|
299
305
|
return /* @__PURE__ */ react.default.createElement(antd.Alert, {
|
|
@@ -308,6 +314,15 @@ const DateFlowModuleComponent = ({ context, module, registerHandle }) => {
|
|
|
308
314
|
availabilityDates: availabilityData.availabilityDates,
|
|
309
315
|
currentDate: (startDate || (0, dayjs.default)()).format("YYYY-MM-DD"),
|
|
310
316
|
onCurrentDateChange: () => void 0,
|
|
317
|
+
onVisibleDateRangeChange: (visibleRange) => {
|
|
318
|
+
if (!availability.ensureDateRange) return;
|
|
319
|
+
const requestedDateRange = require_availabilityWindow.resolveSlidingAvailabilityDateRange({
|
|
320
|
+
availabilityDates: availabilityData.availabilityDates,
|
|
321
|
+
visibleRange
|
|
322
|
+
});
|
|
323
|
+
if (!requestedDateRange) return;
|
|
324
|
+
refreshAvailabilityDates(context, module, requestedDateRange).catch(() => void 0);
|
|
325
|
+
},
|
|
311
326
|
onDateChange: (value) => {
|
|
312
327
|
const nextDate = (0, dayjs.default)(value);
|
|
313
328
|
updateDates(nextDate, nextDate, ["booking.startDate", "booking.endDate"]);
|
|
@@ -378,7 +393,7 @@ const dateFlowModule = {
|
|
|
378
393
|
yield awaitLatestDateHydration(context, module.key);
|
|
379
394
|
}
|
|
380
395
|
});
|
|
381
|
-
return function refresh(
|
|
396
|
+
return function refresh(_x9, _x10) {
|
|
382
397
|
return _ref4.apply(this, arguments);
|
|
383
398
|
};
|
|
384
399
|
}(),
|