@blocklet/payment-react 1.16.3 → 1.16.5

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.
@@ -0,0 +1,38 @@
1
+ /// <reference types="react" />
2
+ import type { Invoice, PaymentCurrency, PaymentMethod, Subscription } from '@blocklet/payment-types';
3
+ type DialogProps = {
4
+ open?: boolean;
5
+ onClose?: () => void;
6
+ title?: string;
7
+ };
8
+ type Props = {
9
+ subscriptionId: string;
10
+ mode?: 'default' | 'custom';
11
+ onPaid?: (subscriptionId: string, currencyId: string) => void;
12
+ dialogProps?: DialogProps;
13
+ children?: (handlePay: (item: SummaryItem) => void, data: {
14
+ subscription: Subscription;
15
+ summary: {
16
+ [key: string]: SummaryItem;
17
+ };
18
+ invoices: Invoice[];
19
+ subscriptionUrl: string;
20
+ }) => React.ReactNode;
21
+ };
22
+ type SummaryItem = {
23
+ amount: string;
24
+ currency: PaymentCurrency;
25
+ method: PaymentMethod;
26
+ };
27
+ declare function OverdueInvoicePayment({ subscriptionId, mode, dialogProps, children, onPaid, }: Props): import("react").JSX.Element;
28
+ declare namespace OverdueInvoicePayment {
29
+ var defaultProps: {
30
+ mode: string;
31
+ onPaid: () => void;
32
+ dialogProps: {
33
+ open: boolean;
34
+ };
35
+ children: null;
36
+ };
37
+ }
38
+ export default OverdueInvoicePayment;
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
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 _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
12
+ var _ufo = require("ufo");
13
+ var _ahooks = require("ahooks");
14
+ var _ux = require("@arcblock/ux");
15
+ var _payment = require("../contexts/payment");
16
+ var _util = require("../libs/util");
17
+ var _subscription = require("../hooks/subscription");
18
+ var _api = _interopRequireDefault(require("../libs/api"));
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+ const fetchOverdueInvoices = async subscriptionId => {
21
+ const res = await _api.default.get(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
22
+ return res.data;
23
+ };
24
+ function OverdueInvoicePayment({
25
+ subscriptionId,
26
+ mode = "default",
27
+ dialogProps = {},
28
+ children,
29
+ onPaid = () => {}
30
+ }) {
31
+ const {
32
+ t
33
+ } = (0, _context.useLocaleContext)();
34
+ const {
35
+ connect
36
+ } = (0, _payment.usePaymentContext)();
37
+ const [selectCurrencyId, setSelectCurrencyId] = (0, _react.useState)("");
38
+ const [payLoading, setPayLoading] = (0, _react.useState)(false);
39
+ const [dialogOpen, setDialogOpen] = (0, _react.useState)(dialogProps.open || false);
40
+ const [processedCurrencies, setProcessedCurrencies] = (0, _react.useState)({});
41
+ const {
42
+ data = {
43
+ subscription: {},
44
+ summary: {},
45
+ invoices: []
46
+ },
47
+ error,
48
+ loading,
49
+ runAsync: refresh
50
+ } = (0, _ahooks.useRequest)(() => fetchOverdueInvoices(subscriptionId));
51
+ const subscriptionUrl = (0, _ufo.joinURL)((0, _util.getPrefix)(), `/customer/subscription/${subscriptionId}`);
52
+ const summaryList = (0, _react.useMemo)(() => {
53
+ if (!data?.summary) {
54
+ return [];
55
+ }
56
+ return Object.values(data.summary);
57
+ }, [data?.summary]);
58
+ const subscription = (0, _subscription.useSubscription)("events");
59
+ (0, _react.useEffect)(() => {
60
+ if (subscription) {
61
+ subscription.on("invoice.paid", ({
62
+ response
63
+ }) => {
64
+ const uniqueKey = `${response.subscription_id}-${response.currency_id}`;
65
+ if (response.subscription_id === subscriptionId && !processedCurrencies[uniqueKey]) {
66
+ _Toast.default.success(t("payment.customer.invoice.paySuccess"));
67
+ setPayLoading(false);
68
+ setProcessedCurrencies({
69
+ ...processedCurrencies,
70
+ [uniqueKey]: 1
71
+ });
72
+ refresh().then(res => {
73
+ if (res.invoices?.length === 0) {
74
+ setDialogOpen(false);
75
+ onPaid(subscriptionId, response.currency_id);
76
+ }
77
+ });
78
+ }
79
+ });
80
+ }
81
+ }, [subscription]);
82
+ const handlePay = item => {
83
+ const {
84
+ currency,
85
+ method
86
+ } = item;
87
+ if (method.type === "stripe") {
88
+ _Toast.default.error(t("payment.subscription.overdue.notSupport"));
89
+ return;
90
+ }
91
+ if (payLoading) {
92
+ return;
93
+ }
94
+ setSelectCurrencyId(currency.id);
95
+ setPayLoading(true);
96
+ if (method.type === "arcblock" || method.type === "ethereum") {
97
+ connect.open({
98
+ containerEl: void 0,
99
+ saveConnect: false,
100
+ action: "collect-batch",
101
+ prefix: (0, _ufo.joinURL)("/api/did"),
102
+ extraParams: {
103
+ currencyId: currency.id,
104
+ subscriptionId
105
+ },
106
+ onSuccess: () => {
107
+ connect.close();
108
+ },
109
+ onClose: () => {
110
+ connect.close();
111
+ setPayLoading(false);
112
+ },
113
+ onError: err => {
114
+ _Toast.default.error((0, _util.formatError)(err));
115
+ setPayLoading(false);
116
+ }
117
+ });
118
+ }
119
+ };
120
+ if (loading) {
121
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {});
122
+ }
123
+ const renderPayButton = (item, props) => {
124
+ const isPayLoading = payLoading && item.currency.id === selectCurrencyId;
125
+ if (item.method.type === "stripe") {
126
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
127
+ variant: "contained",
128
+ color: "primary",
129
+ onClick: () => window.open(subscriptionUrl, "_blank"),
130
+ ...props,
131
+ children: t("payment.subscription.overdue.viewNow")
132
+ });
133
+ }
134
+ return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Button, {
135
+ variant: "contained",
136
+ color: "primary",
137
+ onClick: () => handlePay(item),
138
+ ...props,
139
+ disabled: isPayLoading,
140
+ children: [isPayLoading && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {
141
+ size: 14,
142
+ sx: {
143
+ mr: 1,
144
+ color: "text.lighter"
145
+ }
146
+ }), t("payment.subscription.overdue.payNow")]
147
+ });
148
+ };
149
+ if (mode === "custom" && children && typeof children === "function") {
150
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
151
+ children: children(handlePay, {
152
+ subscription: data?.subscription,
153
+ subscriptionUrl,
154
+ summary: data?.summary,
155
+ invoices: data?.invoices
156
+ })
157
+ });
158
+ }
159
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_ux.Dialog, {
160
+ open: dialogOpen,
161
+ onClose: () => setDialogOpen(false),
162
+ title: dialogProps.title || t("payment.subscription.overdue.pastDue"),
163
+ PaperProps: {
164
+ style: {
165
+ minHeight: "auto"
166
+ }
167
+ },
168
+ children: error ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Alert, {
169
+ severity: "error",
170
+ children: error.message
171
+ }) : /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
172
+ gap: 1,
173
+ children: [summaryList.length === 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
174
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Alert, {
175
+ severity: "success",
176
+ children: t("payment.subscription.overdue.empty", {
177
+ // @ts-ignore
178
+ name: data?.subscription?.description
179
+ })
180
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
181
+ direction: "row",
182
+ justifyContent: "flex-end",
183
+ mt: 2,
184
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
185
+ variant: "outlined",
186
+ color: "primary",
187
+ onClick: () => setDialogOpen(false),
188
+ sx: {
189
+ width: "fit-content"
190
+ },
191
+ children: t("common.know")
192
+ })
193
+ })]
194
+ }), summaryList.length === 1 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
195
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
196
+ color: "text.secondary",
197
+ variant: "body1",
198
+ children: [t("payment.subscription.overdue.title", {
199
+ // @ts-ignore
200
+ name: data?.subscription?.description,
201
+ count: data?.invoices?.length,
202
+ total: (0, _util.formatAmount)(summaryList[0]?.amount, summaryList[0]?.currency?.decimal),
203
+ symbol: summaryList[0]?.currency?.symbol
204
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)("br", {}), t("payment.subscription.overdue.description"), /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
205
+ href: subscriptionUrl,
206
+ target: "_blank",
207
+ rel: "noreferrer",
208
+ style: {
209
+ color: "var(--foregrounds-fg-interactive, 0086FF)"
210
+ },
211
+ children: t("payment.subscription.overdue.view")
212
+ })]
213
+ }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
214
+ direction: "row",
215
+ justifyContent: "flex-end",
216
+ gap: 2,
217
+ mt: 2,
218
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
219
+ variant: "outlined",
220
+ color: "primary",
221
+ onClick: () => setDialogOpen(false),
222
+ children: t("common.cancel")
223
+ }), renderPayButton(summaryList[0])]
224
+ })]
225
+ }), summaryList.length > 1 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
226
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
227
+ color: "text.secondary",
228
+ variant: "body1",
229
+ children: [t("payment.subscription.overdue.simpleTitle", {
230
+ // @ts-ignore
231
+ name: data?.subscription?.description,
232
+ count: data?.invoices?.length
233
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)("br", {}), t("payment.subscription.overdue.description"), /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
234
+ href: subscriptionUrl,
235
+ target: "_blank",
236
+ rel: "noreferrer",
237
+ style: {
238
+ color: "var(--foregrounds-fg-interactive, 0086FF)"
239
+ },
240
+ children: t("payment.subscription.overdue.view")
241
+ })]
242
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
243
+ color: "text.secondary",
244
+ variant: "body1",
245
+ children: t("payment.subscription.overdue.list")
246
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
247
+ children: summaryList.map(item => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
248
+ direction: "row",
249
+ justifyContent: "space-between",
250
+ alignItems: "center",
251
+ sx: {
252
+ py: 1,
253
+ px: 0.5,
254
+ borderBottom: "1px solid var(--foregrounds-fg-border, #E0E0E0)",
255
+ "&:hover": {
256
+ background: "var(--backgrounds-bg-highlight, #eff6ff)"
257
+ },
258
+ mt: 0
259
+ },
260
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
261
+ children: t("payment.subscription.overdue.total", {
262
+ total: (0, _util.formatAmount)(item?.amount, item?.currency?.decimal),
263
+ currency: item?.currency?.symbol
264
+ })
265
+ }), renderPayButton(item, {
266
+ variant: "text",
267
+ sx: {
268
+ color: "text.link"
269
+ }
270
+ })]
271
+ }, item?.currency?.id))
272
+ })]
273
+ })]
274
+ })
275
+ });
276
+ }
277
+ OverdueInvoicePayment.defaultProps = {
278
+ mode: "default",
279
+ onPaid: () => {},
280
+ dialogProps: {
281
+ open: true
282
+ },
283
+ children: null
284
+ };
285
+ module.exports = OverdueInvoicePayment;
@@ -184,13 +184,13 @@ function PricingTable({
184
184
  @media (min-width: ${({
185
185
  theme
186
186
  }) => theme.breakpoints.values.md}px) {
187
- .price-table-wrap:has(> div:nth-child(1)) {
187
+ .price-table-wrap:has(> div:nth-of-type(1)) {
188
188
  max-width: 360px !important;
189
189
  }
190
- .price-table-wrap:has(> div:nth-child(2)) {
190
+ .price-table-wrap:has(> div:nth-of-type(2)) {
191
191
  max-width: 780px !important;
192
192
  }
193
- .price-table-wrap:has(> div:nth-child(3)) {
193
+ .price-table-wrap:has(> div:nth-of-type(3)) {
194
194
  max-width: 1200px !important;
195
195
  }
196
196
  }
@@ -507,8 +507,6 @@ function Subscribe({
507
507
  loading: state.loading === x.price_id && !state.loaded,
508
508
  disabled: x.is_disabled,
509
509
  onClick: () => handleSelect(x.price_id),
510
- loadingPosition: "end",
511
- endIcon: null,
512
510
  children: action
513
511
  });
514
512
  }
@@ -120,6 +120,8 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
120
120
  border-bottom: none;
121
121
  padding-top: 12px;
122
122
  padding-bottom: 12px;
123
+ padding-left: 16px;
124
+ padding-right: 16px;
123
125
  &:first-of-type {
124
126
  padding-left: 20px;
125
127
  }
package/lib/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import CountrySelect from './components/country-select';
28
28
  import TruncatedText from './components/truncated-text';
29
29
  import Link from './components/link';
30
30
  import { createLazyComponent } from './components/lazy-loader';
31
+ import OverdueInvoicePayment from './components/over-due-invoice-payment';
31
32
  export { PaymentThemeProvider } from './theme';
32
33
  export * from './libs/util';
33
34
  export * from './libs/connect';
@@ -38,4 +39,4 @@ export * from './hooks/mobile';
38
39
  export * from './hooks/table';
39
40
  export * from './hooks/scroll';
40
41
  export { translations, createTranslator } from './locales';
41
- export { createLazyComponent, api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, };
42
+ export { createLazyComponent, api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, };
package/lib/index.js CHANGED
@@ -34,6 +34,7 @@ var _exportNames = {
34
34
  TruncatedText: true,
35
35
  Link: true,
36
36
  createLazyComponent: true,
37
+ OverdueInvoicePayment: true,
37
38
  PaymentThemeProvider: true,
38
39
  translations: true,
39
40
  createTranslator: true
@@ -116,6 +117,12 @@ Object.defineProperty(exports, "Livemode", {
116
117
  return _livemode.default;
117
118
  }
118
119
  });
120
+ Object.defineProperty(exports, "OverdueInvoicePayment", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _overDueInvoicePayment.default;
124
+ }
125
+ });
119
126
  Object.defineProperty(exports, "Payment", {
120
127
  enumerable: true,
121
128
  get: function () {
@@ -266,6 +273,7 @@ var _countrySelect = _interopRequireDefault(require("./components/country-select
266
273
  var _truncatedText = _interopRequireDefault(require("./components/truncated-text"));
267
274
  var _link = _interopRequireDefault(require("./components/link"));
268
275
  var _lazyLoader = require("./components/lazy-loader");
276
+ var _overDueInvoicePayment = _interopRequireDefault(require("./components/over-due-invoice-payment"));
269
277
  var _theme = require("./theme");
270
278
  var _util = require("./libs/util");
271
279
  Object.keys(_util).forEach(function (key) {
package/lib/locales/en.js CHANGED
@@ -97,7 +97,8 @@ module.exports = (0, _flat.default)({
97
97
  amountPrecisionLimit: "Amount decimal places must be less than or equal to {precision}",
98
98
  saveAsDefaultPriceSuccess: "Set default price successfully",
99
99
  stakeAmount: "Stake Amount",
100
- slashStakeAmount: "Slash Stake Amount"
100
+ slashStakeAmount: "Slash Stake Amount",
101
+ know: "I know"
101
102
  },
102
103
  payment: {
103
104
  checkout: {
@@ -323,6 +324,21 @@ module.exports = (0, _flat.default)({
323
324
  recharge: "Add funds",
324
325
  rechargeForSubscription: "Add funds for subscription"
325
326
  }
327
+ },
328
+ subscription: {
329
+ overdue: {
330
+ simpleTitle: "There are {count} due invoices for your subscription {name}, you need to pay them to activate your subscription or before making new purchases.",
331
+ title: "There are {count} due invoices for your subscription {name}, the total due amount is {total} {symbol}, you need to pay them to activate your subscription or before making new purchases.",
332
+ payNow: "Pay Now",
333
+ notSupport: "This payment method is not supported",
334
+ total: "Total {total} {currency}",
335
+ view: "View Subscription Details",
336
+ viewNow: "View Now",
337
+ pastDue: "Past Due Invoices",
338
+ description: "If you have any questions, you can choose ",
339
+ list: "Past Due Invoices:",
340
+ empty: "There are no overdue invoices for your subscription {name}."
341
+ }
326
342
  }
327
343
  },
328
344
  refund: {
package/lib/locales/zh.js CHANGED
@@ -97,7 +97,8 @@ module.exports = (0, _flat.default)({
97
97
  amountPrecisionLimit: "\u91D1\u989D\u5C0F\u6570\u4F4D\u6570\u5FC5\u987B\u5728 {precision} \u4F4D\u4EE5\u5185",
98
98
  saveAsDefaultPriceSuccess: "\u8BBE\u7F6E\u9ED8\u8BA4\u4EF7\u683C\u6210\u529F",
99
99
  stakeAmount: "\u8D28\u62BC\u91D1\u989D",
100
- slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D"
100
+ slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D",
101
+ know: "\u6211\u77E5\u9053\u4E86"
101
102
  },
102
103
  payment: {
103
104
  checkout: {
@@ -323,6 +324,21 @@ module.exports = (0, _flat.default)({
323
324
  recharge: "\u5145\u503C",
324
325
  rechargeForSubscription: "\u8BA2\u9605\u5145\u503C"
325
326
  }
327
+ },
328
+ subscription: {
329
+ overdue: {
330
+ title: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5171\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u603B\u8BA1 {total} {symbol}\uFF0C\u60A8\u9700\u8981\u652F\u4ED8\u8FD9\u4E9B\u8D26\u5355\u4EE5\u6FC0\u6D3B\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u5728\u8FDB\u884C\u65B0\u7684\u8D2D\u4E70\u4E4B\u524D\u5B8C\u6210\u652F\u4ED8\u3002",
331
+ simpleTitle: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5171\u6709 {count} \u5F20\u6B20\u8D39\u8D26\u5355\uFF0C\u60A8\u9700\u8981\u652F\u4ED8\u8FD9\u4E9B\u8D26\u5355\u4EE5\u6FC0\u6D3B\u60A8\u7684\u8BA2\u9605\uFF0C\u6216\u5728\u8FDB\u884C\u65B0\u7684\u8D2D\u4E70\u4E4B\u524D\u5B8C\u6210\u652F\u4ED8\u3002",
332
+ payNow: "\u7ACB\u5373\u652F\u4ED8",
333
+ notSupport: "\u6682\u4E0D\u652F\u6301\u8BE5\u652F\u4ED8\u65B9\u5F0F",
334
+ total: "\u603B\u8BA1 {total} {currency}",
335
+ view: "\u67E5\u770B\u8BA2\u9605\u8BE6\u60C5",
336
+ pastDue: "\u6B20\u8D39\u8D26\u5355",
337
+ viewNow: "\u7ACB\u5373\u67E5\u770B",
338
+ description: "\u5982\u679C\u60A8\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u53EF\u4EE5\u9009\u62E9 ",
339
+ list: "\u6B20\u8D39\u8D26\u5355\uFF1A",
340
+ empty: "\u60A8\u7684\u3010{name}\u3011\u8BA2\u9605\u5F53\u524D\u6CA1\u6709\u6B20\u8D39\u8D26\u5355"
341
+ }
326
342
  }
327
343
  },
328
344
  refund: {
@@ -219,6 +219,7 @@ function PaymentSummary({
219
219
  children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
220
220
  size: "small",
221
221
  loadingPosition: "end",
222
+ endIcon: null,
222
223
  color: "error",
223
224
  variant: "text",
224
225
  loading: state.loading,
@@ -263,6 +264,7 @@ function PaymentSummary({
263
264
  }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
264
265
  size: "small",
265
266
  loadingPosition: "end",
267
+ endIcon: null,
266
268
  color: crossSellBehavior === "required" ? "info" : "info",
267
269
  variant: crossSellBehavior === "required" ? "text" : "text",
268
270
  loading: state.loading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.16.3",
3
+ "version": "1.16.5",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -53,15 +53,15 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@arcblock/did-connect": "^2.10.67",
57
- "@arcblock/ux": "^2.10.67",
58
- "@arcblock/ws": "^1.18.147",
59
- "@blocklet/ui-react": "^2.10.67",
56
+ "@arcblock/did-connect": "^2.10.74",
57
+ "@arcblock/ux": "^2.10.74",
58
+ "@arcblock/ws": "^1.18.150",
59
+ "@blocklet/ui-react": "^2.10.74",
60
60
  "@mui/icons-material": "^5.16.6",
61
61
  "@mui/lab": "^5.0.0-alpha.173",
62
62
  "@mui/material": "^5.16.6",
63
63
  "@mui/system": "^5.16.6",
64
- "@ocap/util": "^1.18.147",
64
+ "@ocap/util": "^1.18.150",
65
65
  "@stripe/react-stripe-js": "^2.7.3",
66
66
  "@stripe/stripe-js": "^2.4.0",
67
67
  "@vitejs/plugin-legacy": "^5.4.1",
@@ -92,7 +92,7 @@
92
92
  "@babel/core": "^7.25.2",
93
93
  "@babel/preset-env": "^7.25.2",
94
94
  "@babel/preset-react": "^7.24.7",
95
- "@blocklet/payment-types": "1.16.3",
95
+ "@blocklet/payment-types": "1.16.5",
96
96
  "@storybook/addon-essentials": "^7.6.20",
97
97
  "@storybook/addon-interactions": "^7.6.20",
98
98
  "@storybook/addon-links": "^7.6.20",
@@ -122,5 +122,5 @@
122
122
  "vite-plugin-babel": "^1.2.0",
123
123
  "vite-plugin-node-polyfills": "^0.21.0"
124
124
  },
125
- "gitHead": "6accc56a51e4ea0906e65f69dc5f41eaa82685fb"
125
+ "gitHead": "74e38987168230f01af52d1aff14bfa6a18c0578"
126
126
  }
@@ -52,7 +52,12 @@ function CheckoutTableInner({ id, mode, onPaid, onError, onChange, extraParams,
52
52
 
53
53
  const handleSelect = (priceId: string, currencyId: string) => {
54
54
  api
55
- .post(`/api/pricing-tables/${data.id}/checkout/${priceId}?${mergeExtraParams(extraParams)}`)
55
+ .post(
56
+ `/api/pricing-tables/${data.id}/checkout/${priceId}?${mergeExtraParams({
57
+ ...extraParams,
58
+ currencyId,
59
+ })}`
60
+ )
56
61
  .then((res) => {
57
62
  if (mode === 'standalone') {
58
63
  let { url } = res.data;
@@ -1,6 +1,4 @@
1
- /* eslint-disable react/prop-types */
2
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
- import React, { useMemo } from 'react';
1
+ import { useMemo, forwardRef } from 'react';
4
2
  import { Box, MenuItem, Select, SxProps, Typography } from '@mui/material';
5
3
  import { useFormContext } from 'react-hook-form';
6
4
  import { CountryIso2, FlagEmoji, defaultCountries, parseCountry } from 'react-international-phone';
@@ -12,11 +10,7 @@ export type CountrySelectProps = {
12
10
  sx?: SxProps;
13
11
  };
14
12
 
15
- CountrySelect.defaultProps = {
16
- sx: {},
17
- };
18
-
19
- export default function CountrySelect({ value, onChange, name, sx }: CountrySelectProps) {
13
+ const CountrySelect = forwardRef<HTMLDivElement, CountrySelectProps>(({ value, onChange, name, sx }, ref) => {
20
14
  const { setValue } = useFormContext();
21
15
  const countryDetail = useMemo(() => {
22
16
  const item = defaultCountries.find((v) => v[1] === value);
@@ -30,6 +24,7 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
30
24
 
31
25
  return (
32
26
  <Select
27
+ ref={ref}
33
28
  MenuProps={{
34
29
  style: {
35
30
  height: '300px',
@@ -46,7 +41,6 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
46
41
  }}
47
42
  sx={{
48
43
  width: '100%',
49
- // Remove default outline (display only on focus)
50
44
  fieldset: {
51
45
  display: 'none',
52
46
  },
@@ -55,7 +49,6 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
55
49
  display: 'block',
56
50
  },
57
51
  },
58
- // Update default spacing
59
52
  '.MuiSelect-select': {
60
53
  padding: '8px',
61
54
  paddingRight: '24px !important',
@@ -64,7 +57,7 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
64
57
  right: 0,
65
58
  },
66
59
  '.MuiMenuItem-root': {
67
- justifyContent: 'flex-start', // 确保内容左对齐
60
+ justifyContent: 'flex-start',
68
61
  },
69
62
  ...sx,
70
63
  }}
@@ -90,4 +83,9 @@ export default function CountrySelect({ value, onChange, name, sx }: CountrySele
90
83
  })}
91
84
  </Select>
92
85
  );
93
- }
86
+ });
87
+
88
+ CountrySelect.defaultProps = {
89
+ sx: {},
90
+ };
91
+ export default CountrySelect;