@blocklet/payment-react 1.25.10 → 1.26.0
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/es/checkout-v2/checkout-v2.d.ts +2 -0
- package/es/checkout-v2/checkout-v2.js +121 -0
- package/es/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
- package/es/checkout-v2/components/dialogs/checkout-dialogs.js +106 -0
- package/es/checkout-v2/components/left/billing-toggle.d.ts +6 -0
- package/es/checkout-v2/components/left/billing-toggle.js +118 -0
- package/es/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
- package/es/checkout-v2/components/left/cross-sell-card.js +167 -0
- package/es/checkout-v2/components/left/product-item-card.d.ts +26 -0
- package/es/checkout-v2/components/left/product-item-card.js +571 -0
- package/es/checkout-v2/components/left/promotion-input.d.ts +19 -0
- package/es/checkout-v2/components/left/promotion-input.js +178 -0
- package/es/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
- package/es/checkout-v2/components/left/staking-breakdown.js +48 -0
- package/es/checkout-v2/components/left/trial-info.d.ts +13 -0
- package/es/checkout-v2/components/left/trial-info.js +48 -0
- package/es/checkout-v2/components/right/currency-grid.d.ts +8 -0
- package/es/checkout-v2/components/right/currency-grid.js +48 -0
- package/es/checkout-v2/components/right/customer-info-card.d.ts +17 -0
- package/es/checkout-v2/components/right/customer-info-card.js +156 -0
- package/es/checkout-v2/components/right/status-feedback.d.ts +7 -0
- package/es/checkout-v2/components/right/status-feedback.js +17 -0
- package/es/checkout-v2/components/right/submit-button.d.ts +10 -0
- package/es/checkout-v2/components/right/submit-button.js +29 -0
- package/es/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
- package/es/checkout-v2/components/right/subscription-disclaimer.js +8 -0
- package/es/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
- package/es/checkout-v2/components/shared/exchange-rate-footer.js +182 -0
- package/es/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
- package/es/checkout-v2/components/shared/scenario-badge.js +47 -0
- package/es/checkout-v2/components/shared/total-display.d.ts +7 -0
- package/es/checkout-v2/components/shared/total-display.js +84 -0
- package/es/checkout-v2/index.d.ts +2 -0
- package/es/checkout-v2/index.js +1 -0
- package/es/checkout-v2/layouts/checkout-layout.d.ts +7 -0
- package/es/checkout-v2/layouts/checkout-layout.js +226 -0
- package/es/checkout-v2/panels/left/composite-panel.d.ts +1 -0
- package/es/checkout-v2/panels/left/composite-panel.js +423 -0
- package/es/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
- package/es/checkout-v2/panels/left/credit-topup-panel.js +615 -0
- package/es/checkout-v2/panels/left/scenario-router.d.ts +1 -0
- package/es/checkout-v2/panels/left/scenario-router.js +19 -0
- package/es/checkout-v2/panels/right/payment-panel.d.ts +1 -0
- package/es/checkout-v2/panels/right/payment-panel.js +644 -0
- package/es/checkout-v2/types.d.ts +15 -0
- package/es/checkout-v2/types.js +0 -0
- package/es/checkout-v2/utils/format.d.ts +59 -0
- package/es/checkout-v2/utils/format.js +125 -0
- package/es/checkout-v2/utils/scenario-detector.d.ts +3 -0
- package/es/checkout-v2/utils/scenario-detector.js +17 -0
- package/es/checkout-v2/views/error-view.d.ts +7 -0
- package/es/checkout-v2/views/error-view.js +269 -0
- package/es/checkout-v2/views/loading-view.d.ts +5 -0
- package/es/checkout-v2/views/loading-view.js +158 -0
- package/es/checkout-v2/views/success-view.d.ts +29 -0
- package/es/checkout-v2/views/success-view.js +614 -0
- package/es/components/phone-field.d.ts +14 -0
- package/es/components/phone-field.js +96 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +45 -6
- package/es/locales/zh.js +45 -6
- package/es/payment/form/index.js +10 -1
- package/lib/checkout-v2/checkout-v2.d.ts +2 -0
- package/lib/checkout-v2/checkout-v2.js +151 -0
- package/lib/checkout-v2/components/dialogs/checkout-dialogs.d.ts +1 -0
- package/lib/checkout-v2/components/dialogs/checkout-dialogs.js +131 -0
- package/lib/checkout-v2/components/left/billing-toggle.d.ts +6 -0
- package/lib/checkout-v2/components/left/billing-toggle.js +126 -0
- package/lib/checkout-v2/components/left/cross-sell-card.d.ts +10 -0
- package/lib/checkout-v2/components/left/cross-sell-card.js +257 -0
- package/lib/checkout-v2/components/left/product-item-card.d.ts +26 -0
- package/lib/checkout-v2/components/left/product-item-card.js +738 -0
- package/lib/checkout-v2/components/left/promotion-input.d.ts +19 -0
- package/lib/checkout-v2/components/left/promotion-input.js +220 -0
- package/lib/checkout-v2/components/left/staking-breakdown.d.ts +9 -0
- package/lib/checkout-v2/components/left/staking-breakdown.js +96 -0
- package/lib/checkout-v2/components/left/trial-info.d.ts +13 -0
- package/lib/checkout-v2/components/left/trial-info.js +82 -0
- package/lib/checkout-v2/components/right/currency-grid.d.ts +8 -0
- package/lib/checkout-v2/components/right/currency-grid.js +96 -0
- package/lib/checkout-v2/components/right/customer-info-card.d.ts +17 -0
- package/lib/checkout-v2/components/right/customer-info-card.js +246 -0
- package/lib/checkout-v2/components/right/status-feedback.d.ts +7 -0
- package/lib/checkout-v2/components/right/status-feedback.js +30 -0
- package/lib/checkout-v2/components/right/submit-button.d.ts +10 -0
- package/lib/checkout-v2/components/right/submit-button.js +35 -0
- package/lib/checkout-v2/components/right/subscription-disclaimer.d.ts +11 -0
- package/lib/checkout-v2/components/right/subscription-disclaimer.js +33 -0
- package/lib/checkout-v2/components/shared/exchange-rate-footer.d.ts +23 -0
- package/lib/checkout-v2/components/shared/exchange-rate-footer.js +282 -0
- package/lib/checkout-v2/components/shared/scenario-badge.d.ts +6 -0
- package/lib/checkout-v2/components/shared/scenario-badge.js +57 -0
- package/lib/checkout-v2/components/shared/total-display.d.ts +7 -0
- package/lib/checkout-v2/components/shared/total-display.js +154 -0
- package/lib/checkout-v2/index.d.ts +2 -0
- package/lib/checkout-v2/index.js +13 -0
- package/lib/checkout-v2/layouts/checkout-layout.d.ts +7 -0
- package/lib/checkout-v2/layouts/checkout-layout.js +308 -0
- package/lib/checkout-v2/panels/left/composite-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/left/composite-panel.js +515 -0
- package/lib/checkout-v2/panels/left/credit-topup-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/left/credit-topup-panel.js +799 -0
- package/lib/checkout-v2/panels/left/scenario-router.d.ts +1 -0
- package/lib/checkout-v2/panels/left/scenario-router.js +29 -0
- package/lib/checkout-v2/panels/right/payment-panel.d.ts +1 -0
- package/lib/checkout-v2/panels/right/payment-panel.js +906 -0
- package/lib/checkout-v2/types.d.ts +15 -0
- package/lib/checkout-v2/types.js +1 -0
- package/lib/checkout-v2/utils/format.d.ts +59 -0
- package/lib/checkout-v2/utils/format.js +158 -0
- package/lib/checkout-v2/utils/scenario-detector.d.ts +3 -0
- package/lib/checkout-v2/utils/scenario-detector.js +23 -0
- package/lib/checkout-v2/views/error-view.d.ts +7 -0
- package/lib/checkout-v2/views/error-view.js +321 -0
- package/lib/checkout-v2/views/loading-view.d.ts +5 -0
- package/lib/checkout-v2/views/loading-view.js +168 -0
- package/lib/checkout-v2/views/success-view.d.ts +29 -0
- package/lib/checkout-v2/views/success-view.js +735 -0
- package/lib/components/phone-field.d.ts +14 -0
- package/lib/components/phone-field.js +130 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +45 -6
- package/lib/locales/zh.js +45 -6
- package/lib/payment/form/index.js +10 -1
- package/package.json +4 -3
- package/src/checkout-v2/checkout-v2.tsx +155 -0
- package/src/checkout-v2/components/dialogs/checkout-dialogs.tsx +134 -0
- package/src/checkout-v2/components/left/billing-toggle.tsx +122 -0
- package/src/checkout-v2/components/left/cross-sell-card.tsx +170 -0
- package/src/checkout-v2/components/left/product-item-card.tsx +634 -0
- package/src/checkout-v2/components/left/promotion-input.tsx +207 -0
- package/src/checkout-v2/components/left/staking-breakdown.tsx +57 -0
- package/src/checkout-v2/components/left/trial-info.tsx +63 -0
- package/src/checkout-v2/components/right/currency-grid.tsx +59 -0
- package/src/checkout-v2/components/right/customer-info-card.tsx +214 -0
- package/src/checkout-v2/components/right/status-feedback.tsx +35 -0
- package/src/checkout-v2/components/right/submit-button.tsx +37 -0
- package/src/checkout-v2/components/right/subscription-disclaimer.tsx +27 -0
- package/src/checkout-v2/components/shared/exchange-rate-footer.tsx +221 -0
- package/src/checkout-v2/components/shared/scenario-badge.tsx +51 -0
- package/src/checkout-v2/components/shared/total-display.tsx +112 -0
- package/src/checkout-v2/index.ts +2 -0
- package/src/checkout-v2/layouts/checkout-layout.tsx +232 -0
- package/src/checkout-v2/panels/left/composite-panel.tsx +465 -0
- package/src/checkout-v2/panels/left/credit-topup-panel.tsx +681 -0
- package/src/checkout-v2/panels/left/scenario-router.tsx +22 -0
- package/src/checkout-v2/panels/right/payment-panel.tsx +703 -0
- package/src/checkout-v2/types.ts +18 -0
- package/src/checkout-v2/utils/format.ts +204 -0
- package/src/checkout-v2/utils/scenario-detector.ts +30 -0
- package/src/checkout-v2/views/error-view.tsx +293 -0
- package/src/checkout-v2/views/loading-view.tsx +162 -0
- package/src/checkout-v2/views/success-view.tsx +770 -0
- package/src/components/phone-field.tsx +119 -0
- package/src/index.ts +3 -0
- package/src/locales/en.tsx +45 -4
- package/src/locales/zh.tsx +43 -4
- package/src/payment/form/index.tsx +16 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = CustomerInfoCard;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
11
|
+
var _countrySelect = _interopRequireDefault(require("../../../components/country-select"));
|
|
12
|
+
var _phoneField = _interopRequireDefault(require("../../../components/phone-field"));
|
|
13
|
+
var _format = require("../../utils/format");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const fieldLabelMap = t => ({
|
|
16
|
+
customer_name: t("payment.checkout.customer.name"),
|
|
17
|
+
customer_email: t("payment.checkout.customer.email"),
|
|
18
|
+
customer_phone: t("payment.checkout.customer.phone"),
|
|
19
|
+
"billing_address.country": t("payment.checkout.billing.country"),
|
|
20
|
+
"billing_address.state": t("payment.checkout.billing.state"),
|
|
21
|
+
"billing_address.city": t("payment.checkout.billing.city"),
|
|
22
|
+
"billing_address.line1": t("payment.checkout.billing.line1"),
|
|
23
|
+
"billing_address.line2": t("payment.checkout.billing.line2"),
|
|
24
|
+
"billing_address.postal_code": t("payment.checkout.billing.postal_code")
|
|
25
|
+
});
|
|
26
|
+
function CustomerInfoCard({
|
|
27
|
+
form,
|
|
28
|
+
isLoggedIn
|
|
29
|
+
}) {
|
|
30
|
+
const {
|
|
31
|
+
t
|
|
32
|
+
} = (0, _context.useLocaleContext)();
|
|
33
|
+
const labels = fieldLabelMap(t);
|
|
34
|
+
const hasRequiredData = !!(form.values.customer_name && form.values.customer_email);
|
|
35
|
+
const [showEditForm, setShowEditForm] = (0, _react.useState)(!hasRequiredData);
|
|
36
|
+
const autoConfirmedRef = (0, _react.useRef)(false);
|
|
37
|
+
(0, _react.useEffect)(() => {
|
|
38
|
+
if (!autoConfirmedRef.current && form.values.customer_name && form.values.customer_email) {
|
|
39
|
+
autoConfirmedRef.current = true;
|
|
40
|
+
setShowEditForm(false);
|
|
41
|
+
}
|
|
42
|
+
}, [form.values.customer_name, form.values.customer_email]);
|
|
43
|
+
if (!isLoggedIn) return null;
|
|
44
|
+
if (!showEditForm) {
|
|
45
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
46
|
+
sx: {
|
|
47
|
+
mt: 2
|
|
48
|
+
},
|
|
49
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
50
|
+
direction: "row",
|
|
51
|
+
justifyContent: "space-between",
|
|
52
|
+
alignItems: "center",
|
|
53
|
+
sx: {
|
|
54
|
+
mb: 1
|
|
55
|
+
},
|
|
56
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
57
|
+
sx: {
|
|
58
|
+
fontSize: 13,
|
|
59
|
+
fontWeight: 600,
|
|
60
|
+
color: "text.secondary"
|
|
61
|
+
},
|
|
62
|
+
children: t("payment.checkout.customerInfo")
|
|
63
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
64
|
+
size: "small",
|
|
65
|
+
variant: "text",
|
|
66
|
+
onClick: () => setShowEditForm(true),
|
|
67
|
+
sx: {
|
|
68
|
+
minWidth: 0,
|
|
69
|
+
fontSize: 13,
|
|
70
|
+
fontWeight: 600,
|
|
71
|
+
p: 0
|
|
72
|
+
},
|
|
73
|
+
children: t("common.edit")
|
|
74
|
+
})]
|
|
75
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
76
|
+
spacing: 0.5,
|
|
77
|
+
sx: {
|
|
78
|
+
p: 2,
|
|
79
|
+
backgroundColor: "background.paper",
|
|
80
|
+
borderRadius: 1,
|
|
81
|
+
border: "1px solid",
|
|
82
|
+
borderColor: "divider"
|
|
83
|
+
},
|
|
84
|
+
children: [form.values.customer_name && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
85
|
+
variant: "body2",
|
|
86
|
+
sx: {
|
|
87
|
+
color: "text.primary",
|
|
88
|
+
fontWeight: 600,
|
|
89
|
+
fontSize: "0.9375rem"
|
|
90
|
+
},
|
|
91
|
+
children: form.values.customer_name
|
|
92
|
+
}), form.values.customer_email && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
93
|
+
variant: "body2",
|
|
94
|
+
sx: {
|
|
95
|
+
color: "text.secondary",
|
|
96
|
+
fontSize: "0.8125rem"
|
|
97
|
+
},
|
|
98
|
+
children: form.values.customer_email
|
|
99
|
+
}), form.fields.some(f => f.name === "customer_phone") && form.values.customer_phone && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
100
|
+
variant: "body2",
|
|
101
|
+
sx: {
|
|
102
|
+
color: "text.secondary",
|
|
103
|
+
fontSize: "0.8125rem"
|
|
104
|
+
},
|
|
105
|
+
children: form.values.customer_phone
|
|
106
|
+
}), (form.values.billing_address?.country || form.values.billing_address?.state || form.values.billing_address?.postal_code) && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
107
|
+
direction: "row",
|
|
108
|
+
alignItems: "center",
|
|
109
|
+
spacing: 0.75,
|
|
110
|
+
children: [form.values.billing_address?.country && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
111
|
+
component: "span",
|
|
112
|
+
sx: {
|
|
113
|
+
fontSize: 14,
|
|
114
|
+
lineHeight: 1
|
|
115
|
+
},
|
|
116
|
+
children: (0, _format.countryCodeToFlag)(form.values.billing_address.country)
|
|
117
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
118
|
+
variant: "body2",
|
|
119
|
+
sx: {
|
|
120
|
+
color: "text.secondary",
|
|
121
|
+
fontSize: "0.8125rem"
|
|
122
|
+
},
|
|
123
|
+
children: [form.values.billing_address?.state || "", form.values.billing_address?.postal_code ? ` [ ${t("payment.checkout.billing.postal_code")}: ${form.values.billing_address.postal_code} ]` : ""]
|
|
124
|
+
})]
|
|
125
|
+
})]
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
130
|
+
sx: {
|
|
131
|
+
mt: 2
|
|
132
|
+
},
|
|
133
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
134
|
+
direction: "row",
|
|
135
|
+
justifyContent: "space-between",
|
|
136
|
+
alignItems: "center",
|
|
137
|
+
sx: {
|
|
138
|
+
mb: 1
|
|
139
|
+
},
|
|
140
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
141
|
+
sx: {
|
|
142
|
+
fontSize: 13,
|
|
143
|
+
fontWeight: 600,
|
|
144
|
+
color: "text.secondary"
|
|
145
|
+
},
|
|
146
|
+
children: t("payment.checkout.customerInfo")
|
|
147
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
148
|
+
size: "small",
|
|
149
|
+
variant: "text",
|
|
150
|
+
onClick: () => setShowEditForm(false),
|
|
151
|
+
sx: {
|
|
152
|
+
minWidth: 0,
|
|
153
|
+
fontSize: 13,
|
|
154
|
+
fontWeight: 600,
|
|
155
|
+
p: 0
|
|
156
|
+
},
|
|
157
|
+
children: t("common.confirm")
|
|
158
|
+
})]
|
|
159
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
160
|
+
spacing: 0,
|
|
161
|
+
sx: {
|
|
162
|
+
p: 2,
|
|
163
|
+
backgroundColor: "background.paper",
|
|
164
|
+
borderRadius: 1,
|
|
165
|
+
border: "1px solid",
|
|
166
|
+
borderColor: "divider"
|
|
167
|
+
},
|
|
168
|
+
children: form.fields.filter(f => f.name !== "billing_address.country").map(field => {
|
|
169
|
+
const {
|
|
170
|
+
name
|
|
171
|
+
} = field;
|
|
172
|
+
const label = labels[name] || name;
|
|
173
|
+
const value = name.includes(".") ? name.split(".").reduce((o, k) => o?.[k], form.values) : form.values[name];
|
|
174
|
+
const isPostalCode = name === "billing_address.postal_code";
|
|
175
|
+
const isPhone = name === "customer_phone";
|
|
176
|
+
if (isPhone) {
|
|
177
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_phoneField.default, {
|
|
178
|
+
value: value || "",
|
|
179
|
+
country: form.values.billing_address?.country || "",
|
|
180
|
+
onChange: phone => form.onChange("customer_phone", phone),
|
|
181
|
+
onCountryChange: c => form.onChange("billing_address.country", c),
|
|
182
|
+
onBlur: () => form.validateField(name),
|
|
183
|
+
label,
|
|
184
|
+
error: form.errors[name]
|
|
185
|
+
}, name);
|
|
186
|
+
}
|
|
187
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
188
|
+
sx: {
|
|
189
|
+
mb: 1.5
|
|
190
|
+
},
|
|
191
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
192
|
+
sx: {
|
|
193
|
+
fontSize: 13,
|
|
194
|
+
fontWeight: 600,
|
|
195
|
+
color: "text.primary",
|
|
196
|
+
mb: 0.5
|
|
197
|
+
},
|
|
198
|
+
children: label
|
|
199
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputBase, {
|
|
200
|
+
fullWidth: true,
|
|
201
|
+
value: value || "",
|
|
202
|
+
onChange: e => form.onChange(name, e.target.value),
|
|
203
|
+
onBlur: () => form.validateField(name),
|
|
204
|
+
startAdornment: isPostalCode ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.InputAdornment, {
|
|
205
|
+
position: "start",
|
|
206
|
+
sx: {
|
|
207
|
+
mr: 0.5,
|
|
208
|
+
ml: -0.5
|
|
209
|
+
},
|
|
210
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_countrySelect.default, {
|
|
211
|
+
value: form.values.billing_address?.country || "",
|
|
212
|
+
onChange: v => form.onChange("billing_address.country", v),
|
|
213
|
+
sx: {
|
|
214
|
+
".MuiOutlinedInput-notchedOutline": {
|
|
215
|
+
borderColor: "transparent !important"
|
|
216
|
+
},
|
|
217
|
+
"& .MuiSelect-select": {
|
|
218
|
+
py: 0,
|
|
219
|
+
pr: "20px !important"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
}) : void 0,
|
|
224
|
+
sx: {
|
|
225
|
+
bgcolor: theme => theme.palette.mode === "dark" ? "rgba(255,255,255,0.06)" : "grey.50",
|
|
226
|
+
borderRadius: "8px",
|
|
227
|
+
px: 1.5,
|
|
228
|
+
py: 0.75,
|
|
229
|
+
fontSize: 14,
|
|
230
|
+
"& .MuiInputBase-input": {
|
|
231
|
+
p: 0
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}), form.errors[name] && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
235
|
+
sx: {
|
|
236
|
+
fontSize: 12,
|
|
237
|
+
color: "error.main",
|
|
238
|
+
mt: 0.25
|
|
239
|
+
},
|
|
240
|
+
children: form.errors[name]
|
|
241
|
+
})]
|
|
242
|
+
}, name);
|
|
243
|
+
})
|
|
244
|
+
})]
|
|
245
|
+
});
|
|
246
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = StatusFeedback;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
+
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function StatusFeedback({
|
|
12
|
+
status,
|
|
13
|
+
context,
|
|
14
|
+
onReset
|
|
15
|
+
}) {
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = (0, _context.useLocaleContext)();
|
|
19
|
+
const prevStatusRef = (0, _react.useRef)(status);
|
|
20
|
+
(0, _react.useEffect)(() => {
|
|
21
|
+
if (status === prevStatusRef.current) return;
|
|
22
|
+
prevStatusRef.current = status;
|
|
23
|
+
if (status === "failed" && context?.type === "error") {
|
|
24
|
+
if (context.code === "CUSTOMER_LIMITED") return;
|
|
25
|
+
_Toast.default.error(context.message || "Payment failed");
|
|
26
|
+
onReset();
|
|
27
|
+
}
|
|
28
|
+
}, [status, context, t, onReset]);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface SubmitButtonProps {
|
|
2
|
+
canSubmit: boolean;
|
|
3
|
+
isProcessing: boolean;
|
|
4
|
+
isWaitingStripe: boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
processingLabel: string;
|
|
7
|
+
onSubmit: () => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export default function SubmitButton({ canSubmit, isProcessing, isWaitingStripe, label, processingLabel, onSubmit, }: SubmitButtonProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = SubmitButton;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
function SubmitButton({
|
|
10
|
+
canSubmit,
|
|
11
|
+
isProcessing,
|
|
12
|
+
isWaitingStripe,
|
|
13
|
+
label,
|
|
14
|
+
processingLabel,
|
|
15
|
+
onSubmit
|
|
16
|
+
}) {
|
|
17
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
18
|
+
variant: "contained",
|
|
19
|
+
size: "large",
|
|
20
|
+
fullWidth: true,
|
|
21
|
+
disabled: !canSubmit || isWaitingStripe,
|
|
22
|
+
onClick: onSubmit,
|
|
23
|
+
startIcon: isProcessing ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
24
|
+
size: 20,
|
|
25
|
+
color: "inherit"
|
|
26
|
+
}) : null,
|
|
27
|
+
sx: {
|
|
28
|
+
py: 1.5,
|
|
29
|
+
fontSize: "1.3rem",
|
|
30
|
+
fontWeight: 600,
|
|
31
|
+
textTransform: "none"
|
|
32
|
+
},
|
|
33
|
+
children: isProcessing ? processingLabel : label
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface SubscriptionDisclaimerProps {
|
|
2
|
+
mode: string;
|
|
3
|
+
subscription: {
|
|
4
|
+
confirmMessage: string;
|
|
5
|
+
showStake: boolean;
|
|
6
|
+
} | null;
|
|
7
|
+
staking: string | null;
|
|
8
|
+
appName: string;
|
|
9
|
+
}
|
|
10
|
+
export default function SubscriptionDisclaimer({ mode, subscription, staking, appName }: SubscriptionDisclaimerProps): import("react").JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = SubscriptionDisclaimer;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
+
function SubscriptionDisclaimer({
|
|
11
|
+
mode,
|
|
12
|
+
subscription,
|
|
13
|
+
staking,
|
|
14
|
+
appName
|
|
15
|
+
}) {
|
|
16
|
+
const {
|
|
17
|
+
t
|
|
18
|
+
} = (0, _context.useLocaleContext)();
|
|
19
|
+
if (!["subscription", "setup"].includes(mode) || !subscription) return null;
|
|
20
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
21
|
+
sx: {
|
|
22
|
+
mt: 2.5,
|
|
23
|
+
color: "text.secondary",
|
|
24
|
+
fontSize: "0.7875rem",
|
|
25
|
+
lineHeight: "0.9625rem"
|
|
26
|
+
},
|
|
27
|
+
children: subscription.confirmMessage || (subscription.showStake && staking ? t("payment.checkout.confirm.withStake", {
|
|
28
|
+
payee: appName || "New Payment Kit"
|
|
29
|
+
}) : t("payment.checkout.confirm.withoutStake", {
|
|
30
|
+
payee: appName || "New Payment Kit"
|
|
31
|
+
}))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface ExchangeRateFooterProps {
|
|
2
|
+
hasDynamicPricing: boolean;
|
|
3
|
+
rate: {
|
|
4
|
+
value: string | null;
|
|
5
|
+
display: string | null;
|
|
6
|
+
provider: string | null;
|
|
7
|
+
providerDisplay: string | null;
|
|
8
|
+
fetchedAt: number | null;
|
|
9
|
+
status: 'loading' | 'available' | 'unavailable';
|
|
10
|
+
};
|
|
11
|
+
slippage: {
|
|
12
|
+
percent: number;
|
|
13
|
+
set: (config: {
|
|
14
|
+
mode: string;
|
|
15
|
+
percent: number;
|
|
16
|
+
base_currency?: string;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
currencySymbol: string;
|
|
20
|
+
isSubscription: boolean;
|
|
21
|
+
}
|
|
22
|
+
export default function ExchangeRateFooter({ hasDynamicPricing, rate, slippage, currencySymbol, isSubscription, }: ExchangeRateFooterProps): import("react").JSX.Element | null;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = ExchangeRateFooter;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _Tune = _interopRequireDefault(require("@mui/icons-material/Tune"));
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
12
|
+
var _slippageConfig = _interopRequireDefault(require("../../../components/slippage-config"));
|
|
13
|
+
var _format = require("../../utils/format");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const ping = (0, _material.keyframes)`
|
|
16
|
+
75%, 100% { transform: scale(2); opacity: 0; }
|
|
17
|
+
`;
|
|
18
|
+
function formatDateTime(ts) {
|
|
19
|
+
if (!ts) return "\u2014";
|
|
20
|
+
const d = new Date(ts);
|
|
21
|
+
const pad = n => String(n).padStart(2, "0");
|
|
22
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
23
|
+
}
|
|
24
|
+
function ExchangeRateFooter({
|
|
25
|
+
hasDynamicPricing,
|
|
26
|
+
rate,
|
|
27
|
+
slippage,
|
|
28
|
+
currencySymbol,
|
|
29
|
+
isSubscription
|
|
30
|
+
}) {
|
|
31
|
+
const {
|
|
32
|
+
t
|
|
33
|
+
} = (0, _context.useLocaleContext)();
|
|
34
|
+
const [dialogOpen, setDialogOpen] = (0, _react.useState)(false);
|
|
35
|
+
const [pendingConfig, setPendingConfig] = (0, _react.useState)(null);
|
|
36
|
+
const [submitting, setSubmitting] = (0, _react.useState)(false);
|
|
37
|
+
const [localSlippage, setLocalSlippage] = (0, _react.useState)(slippage?.percent ?? 0.5);
|
|
38
|
+
(0, _react.useEffect)(() => {
|
|
39
|
+
setLocalSlippage(slippage?.percent ?? 0.5);
|
|
40
|
+
}, [slippage?.percent]);
|
|
41
|
+
if (!hasDynamicPricing || !rate.value || rate.status === "unavailable") return null;
|
|
42
|
+
const rateDisplay = rate.display || `$${Number(rate.value).toFixed(2)}`;
|
|
43
|
+
const showSlippage = isSubscription && typeof slippage?.set === "function";
|
|
44
|
+
const handleOpenDialog = () => {
|
|
45
|
+
setPendingConfig({
|
|
46
|
+
mode: "percent",
|
|
47
|
+
percent: localSlippage
|
|
48
|
+
});
|
|
49
|
+
setDialogOpen(true);
|
|
50
|
+
};
|
|
51
|
+
const handleCloseDialog = () => {
|
|
52
|
+
setDialogOpen(false);
|
|
53
|
+
setPendingConfig(null);
|
|
54
|
+
};
|
|
55
|
+
const handleSlippageChange = value => {
|
|
56
|
+
setPendingConfig(prev => prev ? {
|
|
57
|
+
...prev,
|
|
58
|
+
percent: value
|
|
59
|
+
} : {
|
|
60
|
+
mode: "percent",
|
|
61
|
+
percent: value
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const handleConfigChange = config => {
|
|
65
|
+
setPendingConfig(config);
|
|
66
|
+
};
|
|
67
|
+
const handleSubmit = async () => {
|
|
68
|
+
if (!pendingConfig || !slippage?.set) return;
|
|
69
|
+
setSubmitting(true);
|
|
70
|
+
try {
|
|
71
|
+
setLocalSlippage(pendingConfig.percent);
|
|
72
|
+
await slippage.set({
|
|
73
|
+
...pendingConfig,
|
|
74
|
+
base_currency: "USD"
|
|
75
|
+
});
|
|
76
|
+
setDialogOpen(false);
|
|
77
|
+
setPendingConfig(null);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
setLocalSlippage(slippage?.percent ?? 0.5);
|
|
80
|
+
console.error("Failed to update slippage", err);
|
|
81
|
+
} finally {
|
|
82
|
+
setSubmitting(false);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const labelSx = {
|
|
86
|
+
fontSize: 11,
|
|
87
|
+
fontWeight: 700,
|
|
88
|
+
color: "primary.main",
|
|
89
|
+
letterSpacing: "0.02em"
|
|
90
|
+
};
|
|
91
|
+
const providerName = rate.providerDisplay || rate.provider || "\u2014";
|
|
92
|
+
const updatedAt = formatDateTime(rate.fetchedAt);
|
|
93
|
+
const fullRate = `$${rate.value}`;
|
|
94
|
+
const tooltipSx = _format.whiteTooltipSx;
|
|
95
|
+
const rowSx = {
|
|
96
|
+
fontSize: 12,
|
|
97
|
+
color: "text.secondary",
|
|
98
|
+
lineHeight: 1.4
|
|
99
|
+
};
|
|
100
|
+
const valSx = {
|
|
101
|
+
fontSize: 12,
|
|
102
|
+
fontWeight: 600,
|
|
103
|
+
color: "text.primary",
|
|
104
|
+
lineHeight: 1.4
|
|
105
|
+
};
|
|
106
|
+
const tooltipContent = /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
107
|
+
spacing: 0.75,
|
|
108
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
109
|
+
sx: {
|
|
110
|
+
fontSize: 13,
|
|
111
|
+
fontWeight: 700,
|
|
112
|
+
color: "text.primary",
|
|
113
|
+
mb: 0.25
|
|
114
|
+
},
|
|
115
|
+
children: ["1 ", currencySymbol, " = ", fullRate]
|
|
116
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
117
|
+
sx: {
|
|
118
|
+
borderTop: "1px solid",
|
|
119
|
+
borderColor: "divider",
|
|
120
|
+
pt: 0.75
|
|
121
|
+
},
|
|
122
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
123
|
+
spacing: 0.5,
|
|
124
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
125
|
+
direction: "row",
|
|
126
|
+
justifyContent: "space-between",
|
|
127
|
+
spacing: 2,
|
|
128
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
129
|
+
sx: rowSx,
|
|
130
|
+
children: t("payment.checkout.quote.detailProvider")
|
|
131
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
132
|
+
sx: valSx,
|
|
133
|
+
children: providerName
|
|
134
|
+
})]
|
|
135
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
136
|
+
direction: "row",
|
|
137
|
+
justifyContent: "space-between",
|
|
138
|
+
spacing: 2,
|
|
139
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
140
|
+
sx: rowSx,
|
|
141
|
+
children: t("payment.checkout.quote.detailUpdatedAt")
|
|
142
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
143
|
+
sx: valSx,
|
|
144
|
+
children: updatedAt
|
|
145
|
+
})]
|
|
146
|
+
})]
|
|
147
|
+
})
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
const slippageTooltip = t("payment.checkout.quote.slippage.tooltip");
|
|
151
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
152
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
153
|
+
sx: {
|
|
154
|
+
width: "100%",
|
|
155
|
+
pt: 3,
|
|
156
|
+
pb: 1,
|
|
157
|
+
borderTop: "1px solid",
|
|
158
|
+
borderColor: "divider"
|
|
159
|
+
},
|
|
160
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
161
|
+
in: true,
|
|
162
|
+
timeout: 300,
|
|
163
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
164
|
+
direction: "row",
|
|
165
|
+
sx: {
|
|
166
|
+
alignItems: "center",
|
|
167
|
+
justifyContent: "space-between"
|
|
168
|
+
},
|
|
169
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
170
|
+
title: tooltipContent,
|
|
171
|
+
placement: "top",
|
|
172
|
+
arrow: true,
|
|
173
|
+
slotProps: {
|
|
174
|
+
popper: {
|
|
175
|
+
sx: tooltipSx
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
179
|
+
direction: "row",
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
spacing: 1,
|
|
182
|
+
sx: {
|
|
183
|
+
cursor: "default"
|
|
184
|
+
},
|
|
185
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
186
|
+
sx: {
|
|
187
|
+
position: "relative",
|
|
188
|
+
width: 8,
|
|
189
|
+
height: 8,
|
|
190
|
+
flexShrink: 0
|
|
191
|
+
},
|
|
192
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
193
|
+
sx: {
|
|
194
|
+
position: "absolute",
|
|
195
|
+
inset: 0,
|
|
196
|
+
borderRadius: "50%",
|
|
197
|
+
bgcolor: "#60a5fa",
|
|
198
|
+
opacity: 0.6,
|
|
199
|
+
animation: `${ping} 1s cubic-bezier(0, 0, 0.2, 1) infinite`
|
|
200
|
+
}
|
|
201
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
202
|
+
sx: {
|
|
203
|
+
position: "relative",
|
|
204
|
+
width: 8,
|
|
205
|
+
height: 8,
|
|
206
|
+
borderRadius: "50%",
|
|
207
|
+
bgcolor: "primary.main"
|
|
208
|
+
}
|
|
209
|
+
})]
|
|
210
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
211
|
+
sx: labelSx,
|
|
212
|
+
children: ["1 ", currencySymbol, " \u2248 ", rateDisplay]
|
|
213
|
+
})]
|
|
214
|
+
})
|
|
215
|
+
}), showSlippage && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
216
|
+
title: slippageTooltip,
|
|
217
|
+
placement: "top",
|
|
218
|
+
arrow: true,
|
|
219
|
+
slotProps: {
|
|
220
|
+
popper: {
|
|
221
|
+
sx: _format.whiteTooltipSx
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
225
|
+
direction: "row",
|
|
226
|
+
alignItems: "center",
|
|
227
|
+
spacing: 0.75,
|
|
228
|
+
onClick: handleOpenDialog,
|
|
229
|
+
sx: {
|
|
230
|
+
cursor: "pointer",
|
|
231
|
+
"&:hover": {
|
|
232
|
+
opacity: 1
|
|
233
|
+
},
|
|
234
|
+
"&:hover .tune-icon": {
|
|
235
|
+
transform: "rotate(90deg)"
|
|
236
|
+
},
|
|
237
|
+
transition: "opacity 0.2s"
|
|
238
|
+
},
|
|
239
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_Tune.default, {
|
|
240
|
+
className: "tune-icon",
|
|
241
|
+
sx: {
|
|
242
|
+
fontSize: 16,
|
|
243
|
+
color: "primary.main",
|
|
244
|
+
transition: "transform 0.5s"
|
|
245
|
+
}
|
|
246
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
247
|
+
sx: labelSx,
|
|
248
|
+
children: [t("payment.checkout.quote.detailSlippage"), " ", localSlippage, "%"]
|
|
249
|
+
})]
|
|
250
|
+
})
|
|
251
|
+
})]
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
255
|
+
open: dialogOpen,
|
|
256
|
+
onClose: handleCloseDialog,
|
|
257
|
+
maxWidth: "sm",
|
|
258
|
+
fullWidth: true,
|
|
259
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
260
|
+
children: t("payment.checkout.quote.slippage.title")
|
|
261
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.DialogContent, {
|
|
262
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_slippageConfig.default, {
|
|
263
|
+
value: pendingConfig?.percent ?? localSlippage,
|
|
264
|
+
onChange: handleSlippageChange,
|
|
265
|
+
config: pendingConfig || {
|
|
266
|
+
mode: "percent",
|
|
267
|
+
percent: localSlippage
|
|
268
|
+
},
|
|
269
|
+
onConfigChange: handleConfigChange,
|
|
270
|
+
exchangeRate: rate.value ? String(rate.value) : null,
|
|
271
|
+
baseCurrency: "USD",
|
|
272
|
+
disabled: submitting,
|
|
273
|
+
sx: {
|
|
274
|
+
mt: 1
|
|
275
|
+
},
|
|
276
|
+
onCancel: handleCloseDialog,
|
|
277
|
+
onSave: handleSubmit
|
|
278
|
+
})
|
|
279
|
+
})]
|
|
280
|
+
})]
|
|
281
|
+
});
|
|
282
|
+
}
|