@pisell/private-materials 6.12.409 → 6.12.411
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 +11 -11
- package/build/lowcode/view.js +11 -11
- package/es/components/bigSale/templates/Kiosk/payment/index.js +16 -0
- package/es/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.js +9 -3
- package/es/components/checkout/components/PaymentOptionsModule/index.js +10 -2
- package/es/components/vendingMachine/README.md +1 -1
- package/es/components/venueBookingSales/VenueBookingShared.js +1 -1
- package/es/components/venueBookingSales/VenueExitButton.js +22 -11
- package/es/components/venueBookingSales/checkout/VenueBookingHolderStep.js +15 -3
- package/es/components/venueBookingSales/checkout/useVenueReviewAccess.js +111 -0
- package/es/components/venueBookingSales/useVenueBookingSteps.js +61 -11
- package/lib/components/bigSale/templates/Kiosk/payment/index.js +16 -0
- package/lib/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.js +9 -3
- package/lib/components/checkout/components/PaymentOptionsModule/index.js +10 -2
- package/lib/components/vendingMachine/README.md +1 -1
- package/lib/components/venueBookingSales/VenueBookingShared.js +1 -1
- package/lib/components/venueBookingSales/VenueExitButton.js +21 -10
- package/lib/components/venueBookingSales/checkout/VenueBookingHolderStep.js +15 -3
- package/lib/components/venueBookingSales/checkout/useVenueReviewAccess.js +112 -0
- package/lib/components/venueBookingSales/useVenueBookingSteps.js +61 -11
- package/package.json +3 -3
|
@@ -36,6 +36,8 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
36
36
|
const normalizedChannel = String(channel || "").trim().toLowerCase();
|
|
37
37
|
const toast = useToast();
|
|
38
38
|
const runtimeRef = useRef(null);
|
|
39
|
+
const paymentOptionsRef = useRef(null);
|
|
40
|
+
const autoPaymentAttemptedRef = useRef(false);
|
|
39
41
|
const preparationRef = useRef(checkoutPreparation);
|
|
40
42
|
const mountedRef = useRef(true);
|
|
41
43
|
const stateRef = useRef(hasUnresolvedDevicePayment(baseSales) ? "uncertain" : "idle");
|
|
@@ -139,6 +141,7 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
139
141
|
if (stateRef.current !== "idle" || !runtimeRef.current) return;
|
|
140
142
|
const method = methods.find((item) => String(item.id) === String(selected.id));
|
|
141
143
|
if (!method) return;
|
|
144
|
+
autoPaymentAttemptedRef.current = true;
|
|
142
145
|
transition("paying");
|
|
143
146
|
try {
|
|
144
147
|
var _utils$businessUtils2, _utils$businessUtils3;
|
|
@@ -176,6 +179,17 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
176
179
|
return _ref2.apply(this, arguments);
|
|
177
180
|
};
|
|
178
181
|
}());
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!["vending", "kiosk"].includes(normalizedChannel) || !ready || amount === void 0 || amount <= 0 || methods.length !== 1 || state !== "idle" || autoPaymentAttemptedRef.current || !paymentOptionsRef.current) return;
|
|
184
|
+
autoPaymentAttemptedRef.current = true;
|
|
185
|
+
paymentOptionsRef.current.activateSinglePaymentMethod();
|
|
186
|
+
}, [
|
|
187
|
+
normalizedChannel,
|
|
188
|
+
ready,
|
|
189
|
+
amount,
|
|
190
|
+
methods,
|
|
191
|
+
state
|
|
192
|
+
]);
|
|
179
193
|
const retrySync = useMemoizedFn(_asyncToGenerator(function* () {
|
|
180
194
|
if (stateRef.current !== "sync-failed" || !retryRef.current) return;
|
|
181
195
|
const retry = retryRef.current;
|
|
@@ -203,6 +217,7 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
203
217
|
const beginAuthorization = useMemoizedFn((_source) => {
|
|
204
218
|
var _globalThis$crypto, _globalThis$crypto$ra;
|
|
205
219
|
if (stateRef.current !== "idle") return null;
|
|
220
|
+
autoPaymentAttemptedRef.current = true;
|
|
206
221
|
if (!authorizationAvailableRef.current) {
|
|
207
222
|
toast.fail(locales.getText("pisell2.checkout.self-service.empty"));
|
|
208
223
|
return null;
|
|
@@ -316,6 +331,7 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
316
331
|
}
|
|
317
332
|
}
|
|
318
333
|
}, /* @__PURE__ */ React.createElement(PaymentOptionsModule, {
|
|
334
|
+
ref: paymentOptionsRef,
|
|
319
335
|
appearance: "self-service",
|
|
320
336
|
orderInfo: { remainingAmount: String(amount !== null && amount !== void 0 ? amount : 0) },
|
|
321
337
|
paymentMethods: methods,
|
|
@@ -13,7 +13,7 @@ import { Iconfont } from "@pisell/materials";
|
|
|
13
13
|
import classNames from "classnames";
|
|
14
14
|
import "./index.less";
|
|
15
15
|
//#region src/components/checkout/components/PaymentOptionsModule/PaymentMethodItem.tsx
|
|
16
|
-
const PaymentMethodItem = ({ appearance = "default", method, amountSymbol, customAmount, disabled = false, onClick, getText, size = "default", surchargeDisplay, directCustomPayment = false, beginKioskPaymentActivity, currentBaseSales })
|
|
16
|
+
const PaymentMethodItem = React.forwardRef(function PaymentMethodItem({ appearance = "default", method, amountSymbol, customAmount, disabled = false, onClick, getText, size = "default", surchargeDisplay, directCustomPayment = false, beginKioskPaymentActivity, currentBaseSales }, ref) {
|
|
17
17
|
var _context$appHelper;
|
|
18
18
|
const context = useEngineContext();
|
|
19
19
|
const { getData, getApp } = (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
|
|
@@ -162,6 +162,12 @@ const PaymentMethodItem = ({ appearance = "default", method, amountSymbol, custo
|
|
|
162
162
|
return _ref.apply(this, arguments);
|
|
163
163
|
};
|
|
164
164
|
}();
|
|
165
|
+
const activate = () => {
|
|
166
|
+
if (disabled) return;
|
|
167
|
+
if (appearance === "self-service" && isEftpos) submitCurrentAmount();
|
|
168
|
+
else showKeyboard();
|
|
169
|
+
};
|
|
170
|
+
React.useImperativeHandle(ref, () => ({ activate }));
|
|
165
171
|
const renderLeftContent = () => /* @__PURE__ */ React.createElement("div", { className: classNames("payment-options-module-payment-method-left") }, appearance === "self-service" ? renderPaymentIcon(method) : /* @__PURE__ */ React.createElement("div", { className: classNames("payment-options-module-icon-container") }, renderPaymentIcon(method)), /* @__PURE__ */ React.createElement("div", { className: classNames("payment-options-module-payment-info") }, /* @__PURE__ */ React.createElement("div", { className: classNames("payment-options-module-payment-info-inner") }, /* @__PURE__ */ React.createElement("div", { className: classNames("payment-options-module-payment-name") }, method.name), /* @__PURE__ */ React.createElement("div", { className: classNames("payment-options-module-payment-info-inner-surcharge") }, !!(displaySurchargeConfig === null || displaySurchargeConfig === void 0 ? void 0 : displaySurchargeConfig.is_surcharge) && calculateSurcharge(displaySurchargeConfig) !== 0 && /* @__PURE__ */ React.createElement("div", { className: classNames("payment-options-module-surcharge-text") }, (getText === null || getText === void 0 ? void 0 : getText("pisell2.payment-options.surcharge-label", "Surcharge")) || "Surcharge", ":", formatAmount(calculateSurcharge(displaySurchargeConfig), 2, amountSymbol)), false))));
|
|
166
172
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
167
173
|
className: classNames("payment-options-module-payment-method-item", {
|
|
@@ -169,7 +175,7 @@ const PaymentMethodItem = ({ appearance = "default", method, amountSymbol, custo
|
|
|
169
175
|
"payment-options-module-disabled": disabled
|
|
170
176
|
}),
|
|
171
177
|
style: appearance === "self-service" ? void 0 : { height: size === "large" ? "82px" : "62px" },
|
|
172
|
-
onClick:
|
|
178
|
+
onClick: activate,
|
|
173
179
|
type: "button",
|
|
174
180
|
disabled
|
|
175
181
|
}, renderLeftContent(), appearance === "self-service" ? /* @__PURE__ */ React.createElement("span", {
|
|
@@ -221,6 +227,6 @@ const PaymentMethodItem = ({ appearance = "default", method, amountSymbol, custo
|
|
|
221
227
|
}
|
|
222
228
|
}
|
|
223
229
|
}));
|
|
224
|
-
};
|
|
230
|
+
});
|
|
225
231
|
//#endregion
|
|
226
232
|
export { PaymentMethodItem as default };
|
|
@@ -10,7 +10,7 @@ import classNames from "classnames";
|
|
|
10
10
|
import { useDebounceFn } from "ahooks";
|
|
11
11
|
import "./index.less";
|
|
12
12
|
//#region src/components/checkout/components/PaymentOptionsModule/index.tsx
|
|
13
|
-
function PaymentOptionsModule({ appearance = "default", amountSymbol, orderInfo, onClick, paymentMethods = [], customAmount, title, disabled = false, showCashPayment = false, channel = "pos", columnCount, sciSurchargeDisplayMap = {}, directCustomPayment = false, isModalOpen = false, paymentMethodsReady = false, autoTriggerSinglePaymentOption = false, beginKioskPaymentActivity, currentBaseSales }) {
|
|
13
|
+
const PaymentOptionsModule = React.forwardRef(function PaymentOptionsModule({ appearance = "default", amountSymbol, orderInfo, onClick, paymentMethods = [], customAmount, title, disabled = false, showCashPayment = false, channel = "pos", columnCount, sciSurchargeDisplayMap = {}, directCustomPayment = false, isModalOpen = false, paymentMethodsReady = false, autoTriggerSinglePaymentOption = false, beginKioskPaymentActivity, currentBaseSales }, ref) {
|
|
14
14
|
var _context$appHelper, _context$appHelper$ge, _context$appHelper$ge2, _context$appHelper$ut;
|
|
15
15
|
const context = useEngineContext();
|
|
16
16
|
useInitLocalesOnce(locales_default, ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 || (_context$appHelper$ge = _context$appHelper.getApp) === null || _context$appHelper$ge === void 0 || (_context$appHelper$ge = _context$appHelper$ge.call(_context$appHelper)) === null || _context$appHelper$ge === void 0 || (_context$appHelper$ge = _context$appHelper$ge.locales) === null || _context$appHelper$ge === void 0 || (_context$appHelper$ge2 = _context$appHelper$ge.getLocale) === null || _context$appHelper$ge2 === void 0 ? void 0 : _context$appHelper$ge2.call(_context$appHelper$ge)) || ((_context$appHelper$ut = context.appHelper.utils) === null || _context$appHelper$ut === void 0 || (_context$appHelper$ut = _context$appHelper$ut.storage) === null || _context$appHelper$ut === void 0 ? void 0 : _context$appHelper$ut.get("umi_locale")) || "en");
|
|
@@ -24,6 +24,13 @@ function PaymentOptionsModule({ appearance = "default", amountSymbol, orderInfo,
|
|
|
24
24
|
const normalizedChannel = String(channel || "pos").trim().toLowerCase();
|
|
25
25
|
const resolvedColumnCount = columnCount !== null && columnCount !== void 0 ? columnCount : showCashPayment ? 1 : 2;
|
|
26
26
|
const filteredPaymentMethods = React.useMemo(() => filterPaymentMethodsForChannel(paymentMethods, normalizedChannel), [normalizedChannel, paymentMethods]);
|
|
27
|
+
const singleMethodRef = React.useRef(null);
|
|
28
|
+
React.useImperativeHandle(ref, () => ({ activateSinglePaymentMethod: () => {
|
|
29
|
+
if (!disabled && filteredPaymentMethods.length === 1) {
|
|
30
|
+
var _singleMethodRef$curr;
|
|
31
|
+
(_singleMethodRef$curr = singleMethodRef.current) === null || _singleMethodRef$curr === void 0 || _singleMethodRef$curr.activate();
|
|
32
|
+
}
|
|
33
|
+
} }));
|
|
27
34
|
const { run: handlePaymentClick } = useDebounceFn((method) => {
|
|
28
35
|
if (disabled) return;
|
|
29
36
|
if (typeof onClick === "function") onClick(method);
|
|
@@ -59,6 +66,7 @@ function PaymentOptionsModule({ appearance = "default", amountSymbol, orderInfo,
|
|
|
59
66
|
paymentMethodsReady
|
|
60
67
|
]);
|
|
61
68
|
const methodItems = filteredPaymentMethods.map((method) => /* @__PURE__ */ React.createElement(PaymentMethodItem, {
|
|
69
|
+
ref: filteredPaymentMethods.length === 1 ? singleMethodRef : void 0,
|
|
62
70
|
appearance,
|
|
63
71
|
size: filteredPaymentMethods.length === 2 ? "large" : "default",
|
|
64
72
|
key: method.id,
|
|
@@ -90,6 +98,6 @@ function PaymentOptionsModule({ appearance = "default", amountSymbol, orderInfo,
|
|
|
90
98
|
paddingBottom: 8
|
|
91
99
|
}
|
|
92
100
|
}, methodItems)));
|
|
93
|
-
}
|
|
101
|
+
});
|
|
94
102
|
//#endregion
|
|
95
103
|
export { PaymentOptionsModule as default };
|
|
@@ -78,7 +78,7 @@ Home 的 Redeem Socks 入口打开独立 `RedeemPage`,展示扫码指引、扫
|
|
|
78
78
|
- 购物车在 Order 的通用 `onBeforeCartCommit` 入口校验原始规则算出的草稿,不维护另一套订单合并规则;库存异常时允许减少/删除,禁止增加。未注入扩展的业务沿用既有库存与销售规则。
|
|
79
79
|
- 普通与 0 元结账都经过 SalesSdk `prepareCheckout`。本次准备凭据携带不可变 `checkoutSnapshot` 并校验提交前购物车是否变化;正常支付完成或确认完成的 0 元订单再通过 `onPaidCheckout` 交给宿主。库存请求与设备规则不写入 Kiosk 模板。
|
|
80
80
|
- 设备端购物车与支付页共用 `resolveKioskPresentation` 的 `self-service` 外观。Kiosk/Vending 待付金额大于 0 时进入 Kiosk 自身的 `payment` 页面,由 `Kiosk/payment` 负责控制,不经过 SalesSdk `openCheckout`、宿主 PaymentModalPlugin 或 PaymentModal。H5、PC 和 POS 继续使用既有支付入口;设备页的外观不再跨 SDK/宿主透传。
|
|
81
|
-
- 独立页复用公共 `PaymentMethodRuntime`、pending 支付生命周期和 BaseSales 订单 API,直接使用当前购物车/钱包。支付方式按实际 `channel` 和宿主终端偏好筛选,Vending
|
|
81
|
+
- 独立页复用公共 `PaymentMethodRuntime`、pending 支付生命周期和 BaseSales 订单 API,直接使用当前购物车/钱包。支付方式按实际 `channel` 和宿主终端偏好筛选,Vending 排除标准及自定义现金方式,也不开钱箱。Vending 与 Kiosk 支付页在方式加载及筛选完成、待付金额大于 0 且只有一种可用方式时,自动执行一次该支付卡片的操作;取消、失败或部分支付后不再次自动触发,可手动重试,退出后重新进入支付页可再次自动触发。付款结果待确认时锁定操作,已收款后的失败只重试订单同步。Kiosk 自定义支付的自动和手动入口均请求主屏授权并等候结果,不在本机直接记为已付。
|
|
82
82
|
- 仅 Vending 支付页优先复用首页初始化销售模块时已准备的支付方式;读取的是 BaseSales 当前镜像,由其原有配置变更事件更新。镜像缺失/为空时保留异步加载兜底,宿主显示偏好、排序及禁用现金规则仍每次应用。普通 Kiosk 保留原有支付方式加载路径。设备配置缓存及其失效由宿主管理,结账库存刷新和设备状态预检保持实时执行。
|
|
83
83
|
- 付款页面期间锁住销售扫码并暂停屏保,返回购物车保留原订单与券;只有明确足额支付并同步成功后,才冻结订单及原 checkoutSnapshot,再进入现有成功/出货交接。0 元仍使用原有直接确认流程,不进入支付方式页。
|
|
84
84
|
- 隐藏零元金额和显示 Confirm 由 Vending 平台决定,不依赖 `renderCatalog` 是否存在;自定义列表本身不改变其它 Kiosk/H5/PC 的金额展示规则。
|
|
@@ -19,9 +19,9 @@ import { usePartyConfigurationPrice } from "./usePartyConfigurationPrice.js";
|
|
|
19
19
|
import { isVenueExtraSellable } from "./extraCatalogAvailability.js";
|
|
20
20
|
import { getVenueExtraHolderSource } from "./extras/holder.js";
|
|
21
21
|
import { venueProductLineUid } from "./orderBindings.js";
|
|
22
|
+
import { groupVenueOrderBindings, venueBundleContents } from "./orderDisplayGroups.js";
|
|
22
23
|
import VenueExtraDetailModal from "./extras/VenueExtraDetailModal.js";
|
|
23
24
|
import { createVenueCatalogCardRenderer, extrasCardConfig, extrasPreferences, mainCardConfig, mainPreferences } from "./catalogPresentation.js";
|
|
24
|
-
import { groupVenueOrderBindings, venueBundleContents } from "./orderDisplayGroups.js";
|
|
25
25
|
import { groupVenueExtraRows } from "./extraDisplayGroups.js";
|
|
26
26
|
import { renderVenueOrderLinePrice } from "./orderLinePrice.js";
|
|
27
27
|
import VenueBookingPromotions from "./checkout/VenueBookingPromotions.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
2
|
import { Dialog } from "../../plus/venueBookingDesign/Dialog.js";
|
|
3
3
|
import React, { useEffect, useRef, useState } from "react";
|
|
4
|
-
import { X } from "@phosphor-icons/react";
|
|
4
|
+
import { ArrowLeft, X } from "@phosphor-icons/react";
|
|
5
5
|
//#region src/components/venueBookingSales/VenueExitButton.tsx
|
|
6
|
-
/**
|
|
7
|
-
function VenueExitButton({ runtime: r }) {
|
|
6
|
+
/** Later steps navigate back; only the entry step offers to abandon the draft. */
|
|
7
|
+
function VenueExitButton({ runtime: r, onBack, disabled = false }) {
|
|
8
8
|
const [open, setOpen] = useState(false);
|
|
9
9
|
const [leaving, setLeaving] = useState(false);
|
|
10
10
|
const pending = useRef(false);
|
|
@@ -15,11 +15,15 @@ function VenueExitButton({ runtime: r }) {
|
|
|
15
15
|
mounted.current = false;
|
|
16
16
|
};
|
|
17
17
|
}, []);
|
|
18
|
+
const hasBack = Boolean(onBack);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (hasBack) setOpen(false);
|
|
21
|
+
}, [hasBack]);
|
|
18
22
|
const current = useRef(r);
|
|
19
23
|
current.current = r;
|
|
20
24
|
const leave = function() {
|
|
21
25
|
var _ref = _asyncToGenerator(function* () {
|
|
22
|
-
if (pending.current || r.disabled) return;
|
|
26
|
+
if (pending.current || r.disabled || disabled) return;
|
|
23
27
|
const sessionId = r.session.sessionId;
|
|
24
28
|
pending.current = true;
|
|
25
29
|
setLeaving(true);
|
|
@@ -45,17 +49,24 @@ function VenueExitButton({ runtime: r }) {
|
|
|
45
49
|
return _ref.apply(this, arguments);
|
|
46
50
|
};
|
|
47
51
|
}();
|
|
52
|
+
const label = hasBack ? r.text("Previous step", "上一步") : r.text("Close booking", "关闭预订");
|
|
48
53
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
49
54
|
type: "button",
|
|
50
55
|
className: "venue-booking-exit icon-button",
|
|
51
|
-
"aria-label":
|
|
52
|
-
title:
|
|
53
|
-
disabled: r.disabled || leaving,
|
|
54
|
-
onClick: () =>
|
|
55
|
-
|
|
56
|
+
"aria-label": label,
|
|
57
|
+
title: label,
|
|
58
|
+
disabled: disabled || r.disabled || leaving,
|
|
59
|
+
onClick: () => {
|
|
60
|
+
if (onBack) onBack();
|
|
61
|
+
else setOpen(true);
|
|
62
|
+
}
|
|
63
|
+
}, hasBack ? /* @__PURE__ */ React.createElement(ArrowLeft, {
|
|
64
|
+
size: 22,
|
|
65
|
+
"aria-hidden": "true"
|
|
66
|
+
}) : /* @__PURE__ */ React.createElement(X, {
|
|
56
67
|
size: 22,
|
|
57
68
|
"aria-hidden": "true"
|
|
58
|
-
})), open && /* @__PURE__ */ React.createElement(Dialog, {
|
|
69
|
+
})), open && !hasBack && /* @__PURE__ */ React.createElement(Dialog, {
|
|
59
70
|
title: r.text("Leave this booking?", "退出本次预订?"),
|
|
60
71
|
closeLabel: r.text("Close", "关闭"),
|
|
61
72
|
onClose: () => setOpen(false),
|
|
@@ -71,7 +82,7 @@ function VenueExitButton({ runtime: r }) {
|
|
|
71
82
|
}, r.text("Keep booking", "继续预订")), /* @__PURE__ */ React.createElement("button", {
|
|
72
83
|
type: "button",
|
|
73
84
|
className: "button",
|
|
74
|
-
disabled: leaving || r.disabled,
|
|
85
|
+
disabled: disabled || leaving || r.disabled,
|
|
75
86
|
onClick: () => {
|
|
76
87
|
leave();
|
|
77
88
|
}
|
|
@@ -14,6 +14,7 @@ import { calendarDateLabel } from "../../../plus/venueBookingDesign/booking-date
|
|
|
14
14
|
import { inspectVenueHolderState, isVenueHolderCreateUncertain, isVenueHolderWriteUncertain, markVenueHolderCreateUncertain, markVenueHolderWriteUncertain, venueHolderOrderIdentity } from "./holderState.js";
|
|
15
15
|
import { confirmationErrorMessage } from "./errorMessage.js";
|
|
16
16
|
import { groupVenueBookingDisplayRows, venueBookingDisplayKey } from "../bookingDisplayGroups.js";
|
|
17
|
+
import { venueBundleContents } from "../orderDisplayGroups.js";
|
|
17
18
|
import { updateVenueBookingHolder } from "./updateVenueBookingHolder.js";
|
|
18
19
|
import { getVenueHolderCreatedRecordId } from "./holderCreateResult.js";
|
|
19
20
|
import VenueHolderCreateModal from "./VenueHolderCreateModal.js";
|
|
@@ -369,6 +370,7 @@ const VenueBookingHolderStep = forwardRef((props, ref) => {
|
|
|
369
370
|
const renderAssignments = (line, ordinalOffset = 0) => Array.from({ length: line.quantity }, (_, index) => {
|
|
370
371
|
var _line$orderLine$metad2;
|
|
371
372
|
const options = holder.getHolderOptionsForSource(line.cacheItem);
|
|
373
|
+
const noProfiles = options.length === 0;
|
|
372
374
|
const value = (draftFor(line) || line.ids)[index];
|
|
373
375
|
const selected = value == null ? void 0 : options.find((option) => String(option.id) === String(value));
|
|
374
376
|
const fieldId = `${id}-${line.uid}-${index}`;
|
|
@@ -398,7 +400,11 @@ const VenueBookingHolderStep = forwardRef((props, ref) => {
|
|
|
398
400
|
}, /* @__PURE__ */ React.createElement("span", null, text("Choose a holder profile", "选择持票人档案")), /* @__PURE__ */ React.createElement("select", {
|
|
399
401
|
id: fieldId,
|
|
400
402
|
value: value == null ? "" : String(value),
|
|
401
|
-
disabled: disabled || !!busy || !!creating || state.blocked,
|
|
403
|
+
disabled: disabled || !!busy || !!creating || state.blocked || noProfiles,
|
|
404
|
+
style: noProfiles ? {
|
|
405
|
+
opacity: .5,
|
|
406
|
+
cursor: "not-allowed"
|
|
407
|
+
} : void 0,
|
|
402
408
|
"aria-invalid": invalid || void 0,
|
|
403
409
|
"aria-describedby": invalid ? `${fieldId}-error` : void 0,
|
|
404
410
|
onChange: (event) => {
|
|
@@ -466,9 +472,12 @@ const VenueBookingHolderStep = forwardRef((props, ref) => {
|
|
|
466
472
|
key: group.key,
|
|
467
473
|
"aria-hidden": "true"
|
|
468
474
|
}, /* @__PURE__ */ React.createElement("span", { className: "venue-holder-skeleton-title" }), /* @__PURE__ */ React.createElement("span", { className: "venue-holder-skeleton-text" }), /* @__PURE__ */ React.createElement("div", { className: "holder-picker" }, /* @__PURE__ */ React.createElement("span", { className: "venue-holder-skeleton-field" }), /* @__PURE__ */ React.createElement("span", { className: "venue-holder-skeleton-field" }))))) : displayGroups.map((group) => {
|
|
469
|
-
var _line$cacheItem$_exte, _line$booking, _line$booking$metadat, _line$booking2, _line$booking3, _line$cacheItem$_exte2, _line$cacheItem$_exte3;
|
|
475
|
+
var _props$catalogProduct, _line$cacheItem$_exte, _line$booking, _line$booking$metadat, _line$booking2, _line$booking3, _line$cacheItem$_exte2, _line$cacheItem$_exte3;
|
|
470
476
|
const line = group.members[0];
|
|
471
477
|
const productSnapshot = line.orderLine;
|
|
478
|
+
const quantity = group.members.reduce((total, member) => total + member.quantity, 0);
|
|
479
|
+
const catalog = (_props$catalogProduct = props.catalogProducts) === null || _props$catalogProduct === void 0 ? void 0 : _props$catalogProduct.find((product) => String(product.id) === String(line.orderLine.product_id));
|
|
480
|
+
const contents = venueBundleContents(line.orderLine, quantity, locale || "en", catalog, line.cacheItem);
|
|
472
481
|
let ordinalOffset = 0;
|
|
473
482
|
const assignments = group.members.map((member) => {
|
|
474
483
|
const fields = renderAssignments(member, ordinalOffset);
|
|
@@ -492,7 +501,10 @@ const VenueBookingHolderStep = forwardRef((props, ref) => {
|
|
|
492
501
|
var _resource$metadata;
|
|
493
502
|
return localizedText(((_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name) || resource.title || resource.name || resource.resource_name, locale || "en");
|
|
494
503
|
}).filter(Boolean).join(" · ")), (line.cacheItem.product_option_string || ((_line$cacheItem$_exte2 = line.cacheItem._extend) === null || _line$cacheItem$_exte2 === void 0 ? void 0 : _line$cacheItem$_exte2.product_option_string) || productSnapshot.product_option_string) && /* @__PURE__ */ React.createElement("div", null, localizedText(line.cacheItem.product_option_string || ((_line$cacheItem$_exte3 = line.cacheItem._extend) === null || _line$cacheItem$_exte3 === void 0 ? void 0 : _line$cacheItem$_exte3.product_option_string) || productSnapshot.product_option_string, locale || "en")), /* @__PURE__ */ React.createElement("div", null, !line.config.enabled ? text("No holder required", "无需填写持票人") : line.config.required ? text("Holder required", "必填持票人") : text("Optional holder", "持票人选填")))
|
|
495
|
-
}
|
|
504
|
+
}, contents.length > 0 && /* @__PURE__ */ React.createElement("ul", {
|
|
505
|
+
className: "venue-order-bundle",
|
|
506
|
+
"aria-label": text("Included items", "套餐内含商品")
|
|
507
|
+
}, contents.map((child) => /* @__PURE__ */ React.createElement("li", { key: child.key }, /* @__PURE__ */ React.createElement("span", null, child.name || text("Included item", "套餐子商品")), /* @__PURE__ */ React.createElement("span", null, "× ", child.quantity))))), /* @__PURE__ */ React.createElement("div", { className: "child-assignments" }, assignments));
|
|
496
508
|
}), props.afterAssignments), creating && current(creating.identity) && /* @__PURE__ */ React.createElement(VenueHolderCreateModal, {
|
|
497
509
|
formId: creating.formId,
|
|
498
510
|
customerId: resolveBookingEditCustomerId(handle === null || handle === void 0 || (_handle$getTempOrder3 = handle.getTempOrder) === null || _handle$getTempOrder3 === void 0 ? void 0 : _handle$getTempOrder3.call(handle), void 0, handle === null || handle === void 0 || (_handle$getOrderCusto = handle.getOrderCustomerSnapshot) === null || _handle$getOrderCusto === void 0 || (_handle$getOrderCusto = _handle$getOrderCusto.call(handle)) === null || _handle$getOrderCusto === void 0 ? void 0 : _handle$getOrderCusto.id),
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
+
import useSalesUserLogin from "../../../hooks/useSalesUserLogin.js";
|
|
3
|
+
import { orderIdentity } from "../presentation.js";
|
|
4
|
+
import { confirmationErrorMessage } from "./errorMessage.js";
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { useMemoizedFn } from "ahooks";
|
|
7
|
+
//#region src/components/venueBookingSales/checkout/useVenueReviewAccess.ts
|
|
8
|
+
const ownerOf = (r) => {
|
|
9
|
+
var _r$os$getTempOrder, _r$os$getTempOrder2, _r$os;
|
|
10
|
+
return {
|
|
11
|
+
os: r.os,
|
|
12
|
+
scopeKey: r.scopeKey,
|
|
13
|
+
sessionId: r.session.sessionId,
|
|
14
|
+
identity: orderIdentity((_r$os$getTempOrder = (_r$os$getTempOrder2 = (_r$os = r.os).getTempOrder) === null || _r$os$getTempOrder2 === void 0 ? void 0 : _r$os$getTempOrder2.call(_r$os)) !== null && _r$os$getTempOrder !== void 0 ? _r$os$getTempOrder : r.order)
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const sameOwner = (left, right) => left.os === right.os && left.scopeKey === right.scopeKey && left.sessionId === right.sessionId && left.identity === right.identity;
|
|
18
|
+
const customerOf = (r) => {
|
|
19
|
+
var _ref, _r$os$getTempOrder3, _r$os$getTempOrder4, _r$os2;
|
|
20
|
+
return String(((_ref = (_r$os$getTempOrder3 = (_r$os$getTempOrder4 = (_r$os2 = r.os).getTempOrder) === null || _r$os$getTempOrder4 === void 0 ? void 0 : _r$os$getTempOrder4.call(_r$os2)) !== null && _r$os$getTempOrder3 !== void 0 ? _r$os$getTempOrder3 : r.order) === null || _ref === void 0 ? void 0 : _ref.customer_id) || "");
|
|
21
|
+
};
|
|
22
|
+
/** Review mounts only after login and the existing OS customer/contact synchronization settle. */
|
|
23
|
+
function useVenueReviewAccess(runtime) {
|
|
24
|
+
const login = useSalesUserLogin();
|
|
25
|
+
const latest = useRef(runtime);
|
|
26
|
+
latest.current = runtime;
|
|
27
|
+
const mounted = useRef(true);
|
|
28
|
+
const request = useRef();
|
|
29
|
+
const [pending, setPending] = useState(false);
|
|
30
|
+
const [approved, setApproved] = useState();
|
|
31
|
+
const owner = ownerOf(runtime);
|
|
32
|
+
const loggedIn = login.isLoggedIn();
|
|
33
|
+
const ready = loggedIn && !!approved && sameOwner(approved.owner, owner) && approved.customer === customerOf(runtime);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
mounted.current = true;
|
|
36
|
+
return () => {
|
|
37
|
+
var _request$current, _request$current$canc;
|
|
38
|
+
mounted.current = false;
|
|
39
|
+
(_request$current = request.current) === null || _request$current === void 0 || (_request$current$canc = _request$current.cancelLogin) === null || _request$current$canc === void 0 || _request$current$canc.call(_request$current);
|
|
40
|
+
request.current = void 0;
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (request.current && !sameOwner(request.current.owner, owner)) {
|
|
45
|
+
var _request$current$canc2, _request$current2;
|
|
46
|
+
(_request$current$canc2 = (_request$current2 = request.current).cancelLogin) === null || _request$current$canc2 === void 0 || _request$current$canc2.call(_request$current2);
|
|
47
|
+
request.current = void 0;
|
|
48
|
+
setPending(false);
|
|
49
|
+
}
|
|
50
|
+
}, [
|
|
51
|
+
owner.os,
|
|
52
|
+
owner.scopeKey,
|
|
53
|
+
owner.sessionId,
|
|
54
|
+
owner.identity
|
|
55
|
+
]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!loggedIn) setApproved(void 0);
|
|
58
|
+
}, [loggedIn]);
|
|
59
|
+
return {
|
|
60
|
+
ready,
|
|
61
|
+
pending,
|
|
62
|
+
ensure: useMemoizedFn(() => {
|
|
63
|
+
const started = latest.current;
|
|
64
|
+
const captured = ownerOf(started);
|
|
65
|
+
if (!mounted.current || !started.ready || started.props.isActive === false) return Promise.resolve(false);
|
|
66
|
+
if (login.isLoggedIn() && approved && sameOwner(approved.owner, captured) && approved.customer === customerOf(started)) return Promise.resolve(true);
|
|
67
|
+
if (request.current && sameOwner(request.current.owner, captured)) return request.current.promise;
|
|
68
|
+
const own = { owner: captured };
|
|
69
|
+
request.current = own;
|
|
70
|
+
const current = () => mounted.current && request.current === own && latest.current.props.isActive !== false && sameOwner(captured, ownerOf(latest.current));
|
|
71
|
+
own.promise = Promise.resolve().then(_asyncToGenerator(function* () {
|
|
72
|
+
try {
|
|
73
|
+
if (!current()) return false;
|
|
74
|
+
if (!login.isLoggedIn()) {
|
|
75
|
+
if (!(yield new Promise((resolve) => {
|
|
76
|
+
own.cancelLogin = () => resolve(false);
|
|
77
|
+
if (!login.openLoginModal({ callback: (status) => {
|
|
78
|
+
own.cancelLogin = void 0;
|
|
79
|
+
resolve(status === "success");
|
|
80
|
+
} })) {
|
|
81
|
+
own.cancelLogin = void 0;
|
|
82
|
+
throw new Error(started.text("Login is unavailable. Please try again.", "登录暂不可用,请重试。"));
|
|
83
|
+
}
|
|
84
|
+
})) || !current() || !login.isLoggedIn()) return false;
|
|
85
|
+
}
|
|
86
|
+
if (!current()) return false;
|
|
87
|
+
if (typeof captured.os.syncAuthenticatedOrderCustomer !== "function" || (yield captured.os.syncAuthenticatedOrderCustomer()) !== true) throw new Error(started.text("Could not load your account details. Please try again.", "无法读取账号信息,请重试。"));
|
|
88
|
+
if (!current() || !login.isLoggedIn()) return false;
|
|
89
|
+
latest.current.cart.refreshCartSnapshot();
|
|
90
|
+
setApproved({
|
|
91
|
+
owner: captured,
|
|
92
|
+
customer: customerOf(latest.current)
|
|
93
|
+
});
|
|
94
|
+
return true;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (current()) latest.current.setError(confirmationErrorMessage(error, started.text("Could not prepare checkout. Please try again.", "无法进入确认页面,请重试。")));
|
|
97
|
+
return false;
|
|
98
|
+
} finally {
|
|
99
|
+
if (request.current === own) {
|
|
100
|
+
request.current = void 0;
|
|
101
|
+
if (mounted.current) setPending(false);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
105
|
+
setPending(true);
|
|
106
|
+
return own.promise;
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { useVenueReviewAccess };
|
|
@@ -11,13 +11,16 @@ import VenueBookingConfirmation from "./checkout/VenueBookingConfirmation.js";
|
|
|
11
11
|
import VenueBookingHolderReview from "./checkout/VenueBookingHolderReview.js";
|
|
12
12
|
import { VenueExtras, VenueOrderAmounts, VenueOrderItems } from "./VenueBookingShared.js";
|
|
13
13
|
import VenueExitButton from "./VenueExitButton.js";
|
|
14
|
+
import { useVenueReviewAccess } from "./checkout/useVenueReviewAccess.js";
|
|
14
15
|
import React, { useEffect, useRef } from "react";
|
|
16
|
+
import { Spin } from "antd";
|
|
15
17
|
import { ArrowRight, Plus } from "@phosphor-icons/react";
|
|
16
18
|
//#region src/components/venueBookingSales/useVenueBookingSteps.tsx
|
|
17
19
|
/** Both independent templates share the guarded later stages; session remains the state owner. */
|
|
18
20
|
function useVenueBookingSteps(runtime) {
|
|
19
21
|
var _definitions, _r$order;
|
|
20
22
|
const r = runtime;
|
|
23
|
+
const reviewAccess = useVenueReviewAccess(r);
|
|
21
24
|
const progress = useBookingProgress();
|
|
22
25
|
const holderRef = useRef(null);
|
|
23
26
|
const latestRuntime = useRef(runtime);
|
|
@@ -29,12 +32,14 @@ function useVenueBookingSteps(runtime) {
|
|
|
29
32
|
mode: r.mode,
|
|
30
33
|
date: r.date,
|
|
31
34
|
customerId: r.customerId,
|
|
35
|
+
sessionId: r.session.sessionId,
|
|
32
36
|
os: r.os,
|
|
33
37
|
order: orderIdentity(r.order)
|
|
34
38
|
};
|
|
35
39
|
const ownerRef = useRef(owner);
|
|
36
40
|
if (Object.keys(owner).some((key) => owner[key] !== ownerRef.current[key])) ownerRef.current = owner;
|
|
37
41
|
const renderedOwner = ownerRef.current;
|
|
42
|
+
const sameSessionOwner = (left, right) => left.scopeKey === right.scopeKey && left.mode === right.mode && left.date === right.date && left.sessionId === right.sessionId && left.os === right.os && left.order === right.order;
|
|
38
43
|
useEffect(() => {
|
|
39
44
|
mounted.current = true;
|
|
40
45
|
return () => {
|
|
@@ -67,14 +72,16 @@ function useVenueBookingSteps(runtime) {
|
|
|
67
72
|
const started = latestRuntime.current;
|
|
68
73
|
if (target === "extras" && !started.hasExtras) target = "review";
|
|
69
74
|
if (target === "review" && started.hasExtras && (started.extrasCatalog.loading || started.extrasCatalog.error)) target = "extras";
|
|
70
|
-
if (!mounted.current || renderedOwner !== ownerRef.current || started.step !== r.step || started.isExtraQuantityPending()) return;
|
|
75
|
+
if (!mounted.current || reviewAccess.pending || renderedOwner !== ownerRef.current || started.step !== r.step || started.isExtraQuantityPending()) return;
|
|
76
|
+
const targetIndex = definitions.findIndex((item) => item.id === target);
|
|
77
|
+
const goingBack = targetIndex >= 0 && targetIndex < currentIndex;
|
|
71
78
|
const sequence = ++navigationSequence.current;
|
|
72
|
-
const isCurrent = () => {
|
|
79
|
+
const isCurrent = (afterLogin = false) => {
|
|
73
80
|
const current = latestRuntime.current;
|
|
74
|
-
return mounted.current && sequence === navigationSequence.current && renderedOwner === ownerRef.current && current.props.isActive !== false && current.step === started.step && !current.disabled && !current.isExtraQuantityPending() && !current.composer && !current.configurationModal && (target === "select" || current.hasBookings && current.mainDateMatches && !current.mainCatalogBlocked);
|
|
81
|
+
return mounted.current && sequence === navigationSequence.current && (afterLogin ? sameSessionOwner(renderedOwner, ownerRef.current) : renderedOwner === ownerRef.current) && current.props.isActive !== false && current.step === started.step && !current.disabled && !current.isExtraQuantityPending() && !current.composer && !current.configurationModal && (target === "select" || goingBack || current.hasBookings && current.mainDateMatches && (afterLogin ? !current.mainPoolEmpty && !current.main.error : !current.mainCatalogBlocked));
|
|
75
82
|
};
|
|
76
83
|
if (!isCurrent()) return;
|
|
77
|
-
if (target === "extras" || target === "review") {
|
|
84
|
+
if (!goingBack && (target === "extras" || target === "review")) {
|
|
78
85
|
if (started.step === "holder") {
|
|
79
86
|
var _holderRef$current;
|
|
80
87
|
const valid = yield (_holderRef$current = holderRef.current) === null || _holderRef$current === void 0 ? void 0 : _holderRef$current.validate();
|
|
@@ -90,6 +97,15 @@ function useVenueBookingSteps(runtime) {
|
|
|
90
97
|
if (target === "review" && !current.checkExtraHolders()) return;
|
|
91
98
|
}
|
|
92
99
|
if (!isCurrent()) return;
|
|
100
|
+
if (target === "review") {
|
|
101
|
+
if (!(yield reviewAccess.ensure()) || !isCurrent(true)) return;
|
|
102
|
+
const current = latestRuntime.current;
|
|
103
|
+
if (!inspectVenueHolderState(current.context, current.scopeKey).complete) {
|
|
104
|
+
current.setStep("holder");
|
|
105
|
+
progress("[data-booking-stage=\"holder\"]");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
93
109
|
const current = latestRuntime.current;
|
|
94
110
|
if (target === "select" && expandProducts) current.setExpandedSection("product");
|
|
95
111
|
current.setError(void 0);
|
|
@@ -102,8 +118,32 @@ function useVenueBookingSteps(runtime) {
|
|
|
102
118
|
};
|
|
103
119
|
}();
|
|
104
120
|
const back = () => {
|
|
105
|
-
if (previous && !r.disabled) goTo(previous);
|
|
121
|
+
if (previous && !r.disabled && !reviewAccess.pending) goTo(previous);
|
|
106
122
|
};
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (r.step !== "review" || !r.ready || reviewAccess.ready) return;
|
|
125
|
+
let active = true;
|
|
126
|
+
const captured = renderedOwner;
|
|
127
|
+
reviewAccess.ensure().then((allowed) => {
|
|
128
|
+
const current = latestRuntime.current;
|
|
129
|
+
if (!allowed && active && mounted.current && current.step === "review" && sameSessionOwner(captured, ownerRef.current)) current.setStep(previous || "select");
|
|
130
|
+
});
|
|
131
|
+
return () => {
|
|
132
|
+
active = false;
|
|
133
|
+
};
|
|
134
|
+
}, [
|
|
135
|
+
r.step,
|
|
136
|
+
r.ready,
|
|
137
|
+
reviewAccess.ready,
|
|
138
|
+
reviewAccess.ensure,
|
|
139
|
+
renderedOwner.scopeKey,
|
|
140
|
+
renderedOwner.mode,
|
|
141
|
+
renderedOwner.date,
|
|
142
|
+
renderedOwner.sessionId,
|
|
143
|
+
renderedOwner.os,
|
|
144
|
+
renderedOwner.order,
|
|
145
|
+
previous
|
|
146
|
+
]);
|
|
107
147
|
const nextAfterSelect = () => inspectVenueHolderState(r.context, r.scopeKey).required ? "holder" : r.nextAfterHolder;
|
|
108
148
|
const nextStep = r.step === "select" ? r.nextAfterSelect : r.step === "holder" ? r.nextAfterHolder : "review";
|
|
109
149
|
const nextLabel = r.step === "review" ? r.text("Confirm & pay", "确认并支付") : nextStep === "holder" ? r.text("Next: holder details", "下一步:持票人") : nextStep === "extras" ? r.text("Next: add extras", "下一步:附加商品") : r.step === "extras" && !r.extras.rows.some((line) => Number(line.num) > 0) ? translate(r.locale, "skipExtras") : r.text("Next: review & pay", "下一步:确认订单");
|
|
@@ -113,12 +153,13 @@ function useVenueBookingSteps(runtime) {
|
|
|
113
153
|
"aria-hidden": "true"
|
|
114
154
|
})),
|
|
115
155
|
compactLabel: nextLabel,
|
|
116
|
-
disabled: r.disabled || !r.hasBookings || !r.mainDateMatches || r.mainCatalogBlocked || !!r.composer || !!r.configurationModal || (r.step === "extras" || r.step === "review") && r.hasExtras && (r.extrasCatalog.loading || !!r.extrasCatalog.error),
|
|
117
|
-
busy: r.checkout.submitting || r.busy && !r.pendingExtraProductId || r.holderBusy,
|
|
156
|
+
disabled: r.disabled || reviewAccess.pending || r.step === "review" && !reviewAccess.ready || !r.hasBookings || !r.mainDateMatches || r.mainCatalogBlocked || !!r.composer || !!r.configurationModal || (r.step === "extras" || r.step === "review") && r.hasExtras && (r.extrasCatalog.loading || !!r.extrasCatalog.error),
|
|
157
|
+
busy: reviewAccess.pending || r.checkout.submitting || r.busy && !r.pendingExtraProductId || r.holderBusy,
|
|
118
158
|
onClick: function() {
|
|
119
159
|
var _ref2 = _asyncToGenerator(function* () {
|
|
120
|
-
if (r.disabled || r.isExtraQuantityPending()) return;
|
|
160
|
+
if (r.disabled || reviewAccess.pending || r.isExtraQuantityPending()) return;
|
|
121
161
|
if (r.step === "review") {
|
|
162
|
+
if (!(yield reviewAccess.ensure())) return;
|
|
122
163
|
if (yield r.checkout.checkout()) r.setHandoff(true);
|
|
123
164
|
} else if (r.step === "select") yield goTo(nextAfterSelect());
|
|
124
165
|
else if (r.step === "holder") yield goTo(r.nextAfterHolder);
|
|
@@ -133,18 +174,23 @@ function useVenueBookingSteps(runtime) {
|
|
|
133
174
|
context: r.context,
|
|
134
175
|
scopeKey: r.scopeKey,
|
|
135
176
|
locale: r.locale,
|
|
177
|
+
catalogProducts: r.main.products,
|
|
136
178
|
isActive: r.props.isActive,
|
|
137
179
|
disabled: r.externalHolderDisabled,
|
|
138
180
|
onMutation: r.refresh,
|
|
139
181
|
onStateChange: (state) => r.setHolderBusy(state.pending),
|
|
140
182
|
onRemoveTicket: r.mode === "tickets" ? r.removeTicket : void 0
|
|
141
183
|
};
|
|
142
|
-
const navigation = /* @__PURE__ */ React.createElement("div", { className: "venue-booking-navigation" }, /* @__PURE__ */ React.createElement(VenueExitButton, {
|
|
184
|
+
const navigation = /* @__PURE__ */ React.createElement("div", { className: "venue-booking-navigation" }, /* @__PURE__ */ React.createElement(VenueExitButton, {
|
|
185
|
+
runtime: r,
|
|
186
|
+
onBack: previous ? back : void 0,
|
|
187
|
+
disabled: reviewAccess.pending
|
|
188
|
+
}), /* @__PURE__ */ React.createElement(ConfigurableBookingSteps, {
|
|
143
189
|
current: currentIndex,
|
|
144
190
|
label: r.text("Booking steps", "预订步骤"),
|
|
145
191
|
currentLabel: r.text("Current step", "当前步骤"),
|
|
146
192
|
steps: definitions.map((item) => _objectSpread2(_objectSpread2({}, item), {}, {
|
|
147
|
-
status: (item.id === "select" || r.hasBookings && r.mainDateMatches && !r.mainCatalogBlocked && (item.id === "holder" || r.holderState.complete)) && !r.disabled ? "available" : "locked",
|
|
193
|
+
status: (item.id === "select" || r.hasBookings && r.mainDateMatches && !r.mainCatalogBlocked && (item.id === "holder" || r.holderState.complete)) && !r.disabled && !reviewAccess.pending ? "available" : "locked",
|
|
148
194
|
onClick: () => {
|
|
149
195
|
goTo(item.id);
|
|
150
196
|
}
|
|
@@ -192,7 +238,11 @@ function useVenueBookingSteps(runtime) {
|
|
|
192
238
|
back,
|
|
193
239
|
previous,
|
|
194
240
|
holderRef,
|
|
195
|
-
renderStage: /* @__PURE__ */ React.createElement(React.Fragment, null, r.step === "holder" && /* @__PURE__ */ React.createElement(VenueBookingHolderStep, _objectSpread2(_objectSpread2({ ref: holderRef }, holderProps), {}, { afterAssignments: addMoreTickets })), r.step === "extras" && /* @__PURE__ */ React.createElement(VenueExtras, { runtime: r }), r.step === "review" && /* @__PURE__ */ React.createElement(
|
|
241
|
+
renderStage: /* @__PURE__ */ React.createElement(React.Fragment, null, r.step === "holder" && /* @__PURE__ */ React.createElement(VenueBookingHolderStep, _objectSpread2(_objectSpread2({ ref: holderRef }, holderProps), {}, { afterAssignments: addMoreTickets })), r.step === "extras" && /* @__PURE__ */ React.createElement(VenueExtras, { runtime: r }), r.step === "review" && !reviewAccess.ready && /* @__PURE__ */ React.createElement("div", {
|
|
242
|
+
className: "venue-booking-sales__loading",
|
|
243
|
+
role: "status",
|
|
244
|
+
"aria-label": r.text("Loading checkout", "正在加载确认页面")
|
|
245
|
+
}, /* @__PURE__ */ React.createElement(Spin, null)), r.step === "review" && reviewAccess.ready && /* @__PURE__ */ React.createElement(VenueBookingConfirmation, {
|
|
196
246
|
ref: r.confirmation,
|
|
197
247
|
context: r.context,
|
|
198
248
|
scopeKey: r.scopeKey,
|
|
@@ -38,6 +38,8 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
38
38
|
const normalizedChannel = String(channel || "").trim().toLowerCase();
|
|
39
39
|
const toast = (0, _pisell_materials.useToast)();
|
|
40
40
|
const runtimeRef = (0, react.useRef)(null);
|
|
41
|
+
const paymentOptionsRef = (0, react.useRef)(null);
|
|
42
|
+
const autoPaymentAttemptedRef = (0, react.useRef)(false);
|
|
41
43
|
const preparationRef = (0, react.useRef)(checkoutPreparation);
|
|
42
44
|
const mountedRef = (0, react.useRef)(true);
|
|
43
45
|
const stateRef = (0, react.useRef)(require_transaction.hasUnresolvedDevicePayment(baseSales) ? "uncertain" : "idle");
|
|
@@ -141,6 +143,7 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
141
143
|
if (stateRef.current !== "idle" || !runtimeRef.current) return;
|
|
142
144
|
const method = methods.find((item) => String(item.id) === String(selected.id));
|
|
143
145
|
if (!method) return;
|
|
146
|
+
autoPaymentAttemptedRef.current = true;
|
|
144
147
|
transition("paying");
|
|
145
148
|
try {
|
|
146
149
|
var _utils$businessUtils2, _utils$businessUtils3;
|
|
@@ -178,6 +181,17 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
178
181
|
return _ref2.apply(this, arguments);
|
|
179
182
|
};
|
|
180
183
|
}());
|
|
184
|
+
(0, react.useEffect)(() => {
|
|
185
|
+
if (!["vending", "kiosk"].includes(normalizedChannel) || !ready || amount === void 0 || amount <= 0 || methods.length !== 1 || state !== "idle" || autoPaymentAttemptedRef.current || !paymentOptionsRef.current) return;
|
|
186
|
+
autoPaymentAttemptedRef.current = true;
|
|
187
|
+
paymentOptionsRef.current.activateSinglePaymentMethod();
|
|
188
|
+
}, [
|
|
189
|
+
normalizedChannel,
|
|
190
|
+
ready,
|
|
191
|
+
amount,
|
|
192
|
+
methods,
|
|
193
|
+
state
|
|
194
|
+
]);
|
|
181
195
|
const retrySync = (0, ahooks.useMemoizedFn)(require_asyncToGenerator._asyncToGenerator(function* () {
|
|
182
196
|
if (stateRef.current !== "sync-failed" || !retryRef.current) return;
|
|
183
197
|
const retry = retryRef.current;
|
|
@@ -205,6 +219,7 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
205
219
|
const beginAuthorization = (0, ahooks.useMemoizedFn)((_source) => {
|
|
206
220
|
var _globalThis$crypto, _globalThis$crypto$ra;
|
|
207
221
|
if (stateRef.current !== "idle") return null;
|
|
222
|
+
autoPaymentAttemptedRef.current = true;
|
|
208
223
|
if (!authorizationAvailableRef.current) {
|
|
209
224
|
toast.fail(_pisell_utils.locales.getText("pisell2.checkout.self-service.empty"));
|
|
210
225
|
return null;
|
|
@@ -318,6 +333,7 @@ function KioskPaymentPage({ context, checkoutPreparation, channel, onBack, onPai
|
|
|
318
333
|
}
|
|
319
334
|
}
|
|
320
335
|
}, /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
336
|
+
ref: paymentOptionsRef,
|
|
321
337
|
appearance: "self-service",
|
|
322
338
|
orderInfo: { remainingAmount: String(amount !== null && amount !== void 0 ? amount : 0) },
|
|
323
339
|
paymentMethods: methods,
|