@blocklet/payment-react 1.17.12 → 1.18.1
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/donate.js +40 -10
- package/es/checkout/form.d.ts +2 -1
- package/es/checkout/form.js +32 -45
- package/es/components/payment-beneficiaries.d.ts +24 -0
- package/es/components/payment-beneficiaries.js +70 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +13 -1
- package/es/locales/zh.js +13 -1
- package/es/payment/donation-form.d.ts +24 -0
- package/es/payment/donation-form.js +603 -0
- package/es/payment/error.d.ts +1 -1
- package/es/payment/error.js +11 -1
- package/es/payment/form/index.d.ts +9 -3
- package/es/payment/form/index.js +39 -4
- package/es/payment/product-donation.js +98 -57
- package/es/payment/skeleton/donation.d.ts +1 -0
- package/es/payment/skeleton/donation.js +30 -0
- package/es/theme/index.js +3 -0
- package/es/types/index.d.ts +2 -0
- package/lib/checkout/donate.js +76 -10
- package/lib/checkout/form.d.ts +2 -1
- package/lib/checkout/form.js +39 -49
- package/lib/components/payment-beneficiaries.d.ts +24 -0
- package/lib/components/payment-beneficiaries.js +113 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +13 -1
- package/lib/locales/zh.js +13 -1
- package/lib/payment/donation-form.d.ts +24 -0
- package/lib/payment/donation-form.js +644 -0
- package/lib/payment/error.d.ts +1 -1
- package/lib/payment/error.js +2 -2
- package/lib/payment/form/index.d.ts +9 -3
- package/lib/payment/form/index.js +35 -2
- package/lib/payment/product-donation.js +140 -73
- package/lib/payment/skeleton/donation.d.ts +1 -0
- package/lib/payment/skeleton/donation.js +66 -0
- package/lib/theme/index.js +3 -0
- package/lib/types/index.d.ts +2 -0
- package/package.json +3 -3
- package/src/checkout/donate.tsx +54 -11
- package/src/checkout/form.tsx +17 -31
- package/src/components/payment-beneficiaries.tsx +97 -0
- package/src/index.ts +2 -0
- package/src/locales/en.tsx +12 -0
- package/src/locales/zh.tsx +12 -0
- package/src/payment/donation-form.tsx +646 -0
- package/src/payment/error.tsx +13 -4
- package/src/payment/form/index.tsx +46 -4
- package/src/payment/product-donation.tsx +91 -40
- package/src/payment/skeleton/donation.tsx +35 -0
- package/src/theme/index.tsx +3 -0
- package/src/types/index.ts +2 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
2
|
+
import { Avatar, Box, Stack, Typography } from '@mui/material';
|
|
3
|
+
import { BN, fromUnitToToken } from '@ocap/util';
|
|
4
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
|
+
|
|
6
|
+
export interface TBeneficiary {
|
|
7
|
+
name: string;
|
|
8
|
+
address: string;
|
|
9
|
+
avatar?: string;
|
|
10
|
+
percent: number;
|
|
11
|
+
amount?: string;
|
|
12
|
+
url?: string;
|
|
13
|
+
type?: 'user' | 'dapp';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface BenefitsProps {
|
|
17
|
+
data: TBeneficiary[];
|
|
18
|
+
currency: {
|
|
19
|
+
symbol: string;
|
|
20
|
+
decimal: number;
|
|
21
|
+
};
|
|
22
|
+
totalAmount?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
PaymentBeneficiaries.defaultProps = {
|
|
26
|
+
totalAmount: '0',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default function PaymentBeneficiaries({ data, currency, totalAmount }: BenefitsProps) {
|
|
30
|
+
const { t } = useLocaleContext();
|
|
31
|
+
return (
|
|
32
|
+
<Stack spacing={2}>
|
|
33
|
+
<Typography variant="subtitle2" color="text.secondary">
|
|
34
|
+
{t('benefits.title', { count: data.length })}
|
|
35
|
+
</Typography>
|
|
36
|
+
|
|
37
|
+
{data.map((item) => {
|
|
38
|
+
const amount =
|
|
39
|
+
item.amount ||
|
|
40
|
+
(totalAmount
|
|
41
|
+
? new BN(totalAmount)
|
|
42
|
+
.mul(new BN(Number(item.percent)))
|
|
43
|
+
.div(new BN(100))
|
|
44
|
+
.toString()
|
|
45
|
+
: '0');
|
|
46
|
+
return (
|
|
47
|
+
<Stack
|
|
48
|
+
key={item.address}
|
|
49
|
+
direction={{ xs: 'column', sm: 'row' }}
|
|
50
|
+
alignItems="center"
|
|
51
|
+
justifyContent="space-between"
|
|
52
|
+
sx={{
|
|
53
|
+
px: 0.5,
|
|
54
|
+
borderRadius: 1,
|
|
55
|
+
bgcolor: 'background.paper',
|
|
56
|
+
'&:hover': {
|
|
57
|
+
bgcolor: 'action.hover',
|
|
58
|
+
},
|
|
59
|
+
}}>
|
|
60
|
+
<Stack direction="row" spacing={1.5} alignItems="center" sx={{ width: { xs: '100%', sm: 'auto' } }}>
|
|
61
|
+
<Avatar src={item.avatar} alt={item.name} sx={{ width: 32, height: 32 }} variant="square" />
|
|
62
|
+
<Box>
|
|
63
|
+
<Typography
|
|
64
|
+
variant="subtitle2"
|
|
65
|
+
onClick={() => {
|
|
66
|
+
if (item.url) {
|
|
67
|
+
window.open(item.url, '_blank');
|
|
68
|
+
}
|
|
69
|
+
}}
|
|
70
|
+
sx={{
|
|
71
|
+
cursor: item.url ? 'pointer' : 'default',
|
|
72
|
+
'&:hover': {
|
|
73
|
+
color: item.url ? 'text.link' : 'inherit',
|
|
74
|
+
},
|
|
75
|
+
}}>
|
|
76
|
+
{item.name}
|
|
77
|
+
</Typography>
|
|
78
|
+
<Typography variant="caption" color="text.secondary" sx={{ cursor: 'pointer' }}>
|
|
79
|
+
{item.address}
|
|
80
|
+
</Typography>
|
|
81
|
+
</Box>
|
|
82
|
+
</Stack>
|
|
83
|
+
|
|
84
|
+
<Stack alignItems="flex-end" sx={{ width: { xs: '100%', sm: 'auto' }, mt: { xs: 1, sm: 0 } }}>
|
|
85
|
+
<Typography variant="subtitle2">
|
|
86
|
+
{fromUnitToToken(amount, currency.decimal)} {currency.symbol}
|
|
87
|
+
</Typography>
|
|
88
|
+
<Typography variant="caption" color="text.secondary">
|
|
89
|
+
{Number(item.percent)}%
|
|
90
|
+
</Typography>
|
|
91
|
+
</Stack>
|
|
92
|
+
</Stack>
|
|
93
|
+
);
|
|
94
|
+
})}
|
|
95
|
+
</Stack>
|
|
96
|
+
);
|
|
97
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import TruncatedText from './components/truncated-text';
|
|
|
29
29
|
import Link from './components/link';
|
|
30
30
|
import { createLazyComponent } from './components/lazy-loader';
|
|
31
31
|
import OverdueInvoicePayment from './components/over-due-invoice-payment';
|
|
32
|
+
import PaymentBeneficiaries from './components/payment-beneficiaries';
|
|
32
33
|
|
|
33
34
|
export { PaymentThemeProvider } from './theme';
|
|
34
35
|
|
|
@@ -75,4 +76,5 @@ export {
|
|
|
75
76
|
TruncatedText,
|
|
76
77
|
Link,
|
|
77
78
|
OverdueInvoicePayment,
|
|
79
|
+
PaymentBeneficiaries,
|
|
78
80
|
};
|
package/src/locales/en.tsx
CHANGED
|
@@ -33,6 +33,8 @@ export default flat({
|
|
|
33
33
|
upload: 'Upload',
|
|
34
34
|
change: 'Change',
|
|
35
35
|
cancel: 'Cancel',
|
|
36
|
+
close: 'Close',
|
|
37
|
+
back: 'Back',
|
|
36
38
|
every: 'every',
|
|
37
39
|
per: 'per {interval}',
|
|
38
40
|
slash: '/ {interval}',
|
|
@@ -129,6 +131,13 @@ export default flat({
|
|
|
129
131
|
select: 'Select Amount',
|
|
130
132
|
summary: '{total} supporters {totalAmount} {symbol}',
|
|
131
133
|
empty: 'No supporters yet',
|
|
134
|
+
gaveTips: '{count} people gave tips',
|
|
135
|
+
tipAmount: 'Tip Amount',
|
|
136
|
+
benefits: {
|
|
137
|
+
one: '{name} will receive all tips',
|
|
138
|
+
multiple: 'Tips will be distributed to {count} beneficiaries',
|
|
139
|
+
view: 'Click to view details',
|
|
140
|
+
},
|
|
132
141
|
},
|
|
133
142
|
cardPay: '{action} with card',
|
|
134
143
|
empty: 'No thing to pay',
|
|
@@ -363,4 +372,7 @@ export default flat({
|
|
|
363
372
|
empty: {
|
|
364
373
|
records: 'No matching records found',
|
|
365
374
|
},
|
|
375
|
+
benefits: {
|
|
376
|
+
title: '{count} Beneficiaries',
|
|
377
|
+
},
|
|
366
378
|
});
|
package/src/locales/zh.tsx
CHANGED
|
@@ -33,6 +33,8 @@ export default flat({
|
|
|
33
33
|
change: '更换',
|
|
34
34
|
confirm: '确认',
|
|
35
35
|
cancel: '取消',
|
|
36
|
+
close: '关闭',
|
|
37
|
+
back: '返回',
|
|
36
38
|
every: '每',
|
|
37
39
|
per: '每{interval}',
|
|
38
40
|
slash: '每{interval}',
|
|
@@ -128,6 +130,13 @@ export default flat({
|
|
|
128
130
|
select: '选择金额',
|
|
129
131
|
summary: '共有 {total} 人支持 {totalAmount} {symbol}',
|
|
130
132
|
empty: '❤️ 支持一下',
|
|
133
|
+
gaveTips: '已有 {count} 人打赏',
|
|
134
|
+
tipAmount: '打赏金额',
|
|
135
|
+
benefits: {
|
|
136
|
+
one: '{name} 将获得全部打赏',
|
|
137
|
+
multiple: '打赏将按比例分配给 {count} 位受益人',
|
|
138
|
+
view: '点击查看详情',
|
|
139
|
+
},
|
|
131
140
|
},
|
|
132
141
|
cardPay: '使用卡片{action}',
|
|
133
142
|
empty: '没有可支付的项目',
|
|
@@ -353,4 +362,7 @@ export default flat({
|
|
|
353
362
|
empty: {
|
|
354
363
|
records: '没有找到匹配的记录',
|
|
355
364
|
},
|
|
365
|
+
benefits: {
|
|
366
|
+
title: '{count} 位受益人',
|
|
367
|
+
},
|
|
356
368
|
});
|