@blocklet/payment-react 1.23.5 → 1.23.6

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.
@@ -3,7 +3,7 @@ import { Stack, Typography, TextField, Card } from "@mui/material";
3
3
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
4
4
  import { useState } from "react";
5
5
  import ProductCard from "../../payment/product-card.js";
6
- import { formatPrice, formatNumber } from "../../libs/util.js";
6
+ import { formatPrice, formatNumber, formatCreditForCheckout } from "../../libs/util.js";
7
7
  export default function AutoTopupProductCard({
8
8
  product,
9
9
  price,
@@ -14,7 +14,7 @@ export default function AutoTopupProductCard({
14
14
  minQuantity = 1,
15
15
  creditCurrency
16
16
  }) {
17
- const { t } = useLocaleContext();
17
+ const { t, locale } = useLocaleContext();
18
18
  const [localQuantity, setLocalQuantity] = useState(quantity);
19
19
  const localQuantityNum = Number(localQuantity) || 0;
20
20
  const handleQuantityChange = (newQuantity) => {
@@ -69,8 +69,11 @@ export default function AutoTopupProductCard({
69
69
  {
70
70
  name: product?.name || "",
71
71
  description: t("payment.autoTopup.creditsIncluded", {
72
- name: creditCurrency?.name,
73
- num: formatNumber(creditUnitAmount * localQuantityNum)
72
+ num: formatCreditForCheckout(
73
+ formatNumber(creditUnitAmount * localQuantityNum),
74
+ creditCurrency?.symbol || "",
75
+ locale
76
+ )
74
77
  }),
75
78
  logo: product?.images?.[0],
76
79
  size: 40
package/es/locales/en.js CHANGED
@@ -339,7 +339,7 @@ export default flat({
339
339
  thresholdDescription: "Credits remaining to trigger auto top-up",
340
340
  thresholdMinError: "Threshold must be greater than 0",
341
341
  thresholdFormatError: "Please enter a valid number",
342
- creditsIncluded: "{num} {name} included",
342
+ creditsIncluded: "{num} included",
343
343
  purchaseBelow: "Purchase this package",
344
344
  perPackage: "per package",
345
345
  quantity: "Quantity",
package/es/locales/zh.js CHANGED
@@ -343,7 +343,7 @@ export default flat({
343
343
  thresholdDescription: "\u89E6\u53D1\u81EA\u52A8\u5145\u503C\u7684\u5269\u4F59\u989D\u5EA6",
344
344
  thresholdMinError: "\u9608\u503C\u5FC5\u987B\u5927\u4E8E0",
345
345
  thresholdFormatError: "\u8BF7\u8F93\u5165\u6709\u6548\u6570\u5B57",
346
- creditsIncluded: "\u5305\u542B {num} {name}",
346
+ creditsIncluded: "\u5305\u542B {num}",
347
347
  purchaseBelow: "\u8D2D\u4E70\u6B64\u5957\u9910",
348
348
  perPackage: "\u6BCF\u5305",
349
349
  quantity: "\u6570\u91CF",
@@ -22,7 +22,8 @@ function AutoTopupProductCard({
22
22
  creditCurrency
23
23
  }) {
24
24
  const {
25
- t
25
+ t,
26
+ locale
26
27
  } = (0, _context.useLocaleContext)();
27
28
  const [localQuantity, setLocalQuantity] = (0, _react.useState)(quantity);
28
29
  const localQuantityNum = Number(localQuantity) || 0;
@@ -75,8 +76,7 @@ function AutoTopupProductCard({
75
76
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_productCard.default, {
76
77
  name: product?.name || "",
77
78
  description: t("payment.autoTopup.creditsIncluded", {
78
- name: creditCurrency?.name,
79
- num: (0, _util.formatNumber)(creditUnitAmount * localQuantityNum)
79
+ num: (0, _util.formatCreditForCheckout)((0, _util.formatNumber)(creditUnitAmount * localQuantityNum), creditCurrency?.symbol || "", locale)
80
80
  }),
81
81
  logo: product?.images?.[0],
82
82
  size: 40
package/lib/locales/en.js CHANGED
@@ -346,7 +346,7 @@ module.exports = (0, _flat.default)({
346
346
  thresholdDescription: "Credits remaining to trigger auto top-up",
347
347
  thresholdMinError: "Threshold must be greater than 0",
348
348
  thresholdFormatError: "Please enter a valid number",
349
- creditsIncluded: "{num} {name} included",
349
+ creditsIncluded: "{num} included",
350
350
  purchaseBelow: "Purchase this package",
351
351
  perPackage: "per package",
352
352
  quantity: "Quantity",
package/lib/locales/zh.js CHANGED
@@ -350,7 +350,7 @@ module.exports = (0, _flat.default)({
350
350
  thresholdDescription: "\u89E6\u53D1\u81EA\u52A8\u5145\u503C\u7684\u5269\u4F59\u989D\u5EA6",
351
351
  thresholdMinError: "\u9608\u503C\u5FC5\u987B\u5927\u4E8E0",
352
352
  thresholdFormatError: "\u8BF7\u8F93\u5165\u6709\u6548\u6570\u5B57",
353
- creditsIncluded: "\u5305\u542B {num} {name}",
353
+ creditsIncluded: "\u5305\u542B {num}",
354
354
  purchaseBelow: "\u8D2D\u4E70\u6B64\u5957\u9910",
355
355
  perPackage: "\u6BCF\u5305",
356
356
  quantity: "\u6570\u91CF",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.23.5",
3
+ "version": "1.23.6",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -96,7 +96,7 @@
96
96
  "@babel/core": "^7.27.4",
97
97
  "@babel/preset-env": "^7.27.2",
98
98
  "@babel/preset-react": "^7.27.1",
99
- "@blocklet/payment-types": "1.23.5",
99
+ "@blocklet/payment-types": "1.23.6",
100
100
  "@storybook/addon-essentials": "^7.6.20",
101
101
  "@storybook/addon-interactions": "^7.6.20",
102
102
  "@storybook/addon-links": "^7.6.20",
@@ -127,5 +127,5 @@
127
127
  "vite-plugin-babel": "^1.3.1",
128
128
  "vite-plugin-node-polyfills": "^0.23.0"
129
129
  },
130
- "gitHead": "486456ed522207cc4efa54cd14b1f65c6433d179"
130
+ "gitHead": "0026a41a10475159d72ade801561d6cbce0008fe"
131
131
  }
@@ -4,7 +4,7 @@ import { useState } from 'react';
4
4
 
5
5
  import type { TPaymentCurrency } from '@blocklet/payment-types';
6
6
  import ProductCard from '../../payment/product-card';
7
- import { formatPrice, formatNumber } from '../../libs/util';
7
+ import { formatPrice, formatNumber, formatCreditForCheckout } from '../../libs/util';
8
8
 
9
9
  interface AutoTopupProductCardProps {
10
10
  product: any;
@@ -27,7 +27,7 @@ export default function AutoTopupProductCard({
27
27
  minQuantity = 1,
28
28
  creditCurrency,
29
29
  }: AutoTopupProductCardProps) {
30
- const { t } = useLocaleContext();
30
+ const { t, locale } = useLocaleContext();
31
31
  const [localQuantity, setLocalQuantity] = useState<number | undefined>(quantity);
32
32
  const localQuantityNum = Number(localQuantity) || 0;
33
33
 
@@ -79,8 +79,11 @@ export default function AutoTopupProductCard({
79
79
  <ProductCard
80
80
  name={product?.name || ''}
81
81
  description={t('payment.autoTopup.creditsIncluded', {
82
- name: creditCurrency?.name,
83
- num: formatNumber(creditUnitAmount * localQuantityNum),
82
+ num: formatCreditForCheckout(
83
+ formatNumber(creditUnitAmount * localQuantityNum),
84
+ creditCurrency?.symbol || '',
85
+ locale
86
+ ),
84
87
  })}
85
88
  logo={product?.images?.[0] as string}
86
89
  size={40}
@@ -355,7 +355,7 @@ export default flat({
355
355
  thresholdDescription: 'Credits remaining to trigger auto top-up',
356
356
  thresholdMinError: 'Threshold must be greater than 0',
357
357
  thresholdFormatError: 'Please enter a valid number',
358
- creditsIncluded: '{num} {name} included',
358
+ creditsIncluded: '{num} included',
359
359
  purchaseBelow: 'Purchase this package',
360
360
  perPackage: 'per package',
361
361
  quantity: 'Quantity',
@@ -351,7 +351,7 @@ export default flat({
351
351
  thresholdDescription: '触发自动充值的剩余额度',
352
352
  thresholdMinError: '阈值必须大于0',
353
353
  thresholdFormatError: '请输入有效数字',
354
- creditsIncluded: '包含 {num} {name}',
354
+ creditsIncluded: '包含 {num}',
355
355
  purchaseBelow: '购买此套餐',
356
356
  perPackage: '每包',
357
357
  quantity: '数量',