@blocklet/payment-react 1.15.4 → 1.15.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.
- package/es/checkout/donate.d.ts +1 -1
- package/es/checkout/donate.js +13 -7
- package/es/checkout/table.js +55 -36
- package/es/components/pricing-table.js +255 -210
- package/es/contexts/payment.js +6 -3
- package/es/history/invoice/list.d.ts +2 -0
- package/es/history/invoice/list.js +34 -4
- package/es/libs/util.js +2 -1
- package/es/payment/index.js +0 -3
- package/es/payment/product-card.js +2 -2
- package/lib/checkout/donate.d.ts +1 -1
- package/lib/checkout/donate.js +18 -13
- package/lib/checkout/table.js +12 -1
- package/lib/components/pricing-table.js +41 -2
- package/lib/contexts/payment.js +12 -5
- package/lib/history/invoice/list.d.ts +2 -0
- package/lib/history/invoice/list.js +32 -4
- package/lib/libs/util.js +2 -1
- package/lib/payment/index.js +0 -3
- package/lib/payment/product-card.js +1 -2
- package/package.json +6 -6
- package/src/checkout/donate.tsx +14 -14
- package/src/checkout/table.tsx +15 -1
- package/src/components/pricing-table.tsx +43 -1
- package/src/contexts/payment.tsx +7 -3
- package/src/history/invoice/list.tsx +37 -1
- package/src/libs/util.ts +2 -1
- package/src/payment/index.tsx +0 -3
- package/src/payment/product-card.tsx +3 -3
|
@@ -64,6 +64,7 @@ type Props = {
|
|
|
64
64
|
target?: string;
|
|
65
65
|
action?: string;
|
|
66
66
|
type?: 'list' | 'table';
|
|
67
|
+
onTableDataChange?: Function;
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
const getInvoiceLink = (invoice: TInvoiceExpanded, action?: string) => {
|
|
@@ -97,6 +98,7 @@ const InvoiceTable = React.memo((props: Props & { onPay: (invoiceId: string) =>
|
|
|
97
98
|
subscription_id,
|
|
98
99
|
include_staking,
|
|
99
100
|
include_recovered_from,
|
|
101
|
+
onTableDataChange,
|
|
100
102
|
} = props;
|
|
101
103
|
const listKey = 'invoice-table';
|
|
102
104
|
const { t, locale } = useLocaleContext();
|
|
@@ -105,7 +107,11 @@ const InvoiceTable = React.memo((props: Props & { onPay: (invoiceId: string) =>
|
|
|
105
107
|
pageSize: pageSize || 10,
|
|
106
108
|
page: 1,
|
|
107
109
|
});
|
|
108
|
-
const {
|
|
110
|
+
const {
|
|
111
|
+
loading,
|
|
112
|
+
data = { list: [], count: 0 },
|
|
113
|
+
refresh,
|
|
114
|
+
} = useRequest(
|
|
109
115
|
() =>
|
|
110
116
|
fetchData({
|
|
111
117
|
...search,
|
|
@@ -121,6 +127,26 @@ const InvoiceTable = React.memo((props: Props & { onPay: (invoiceId: string) =>
|
|
|
121
127
|
refreshDeps: [search],
|
|
122
128
|
}
|
|
123
129
|
);
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (onTableDataChange) {
|
|
132
|
+
onTableDataChange(data);
|
|
133
|
+
}
|
|
134
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
135
|
+
}, [data]);
|
|
136
|
+
|
|
137
|
+
const subscription = useSubscription('events');
|
|
138
|
+
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (subscription && customer_id) {
|
|
141
|
+
subscription.on('invoice.paid', ({ response }: { response: TInvoiceExpanded }) => {
|
|
142
|
+
if (response.customer_id === customer_id) {
|
|
143
|
+
Toast.success(t('payment.customer.invoice.paySuccess'));
|
|
144
|
+
refresh();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
149
|
+
}, [subscription]);
|
|
124
150
|
|
|
125
151
|
const columns = [
|
|
126
152
|
{
|
|
@@ -284,6 +310,7 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
284
310
|
target,
|
|
285
311
|
action,
|
|
286
312
|
onPay,
|
|
313
|
+
onTableDataChange,
|
|
287
314
|
} = props;
|
|
288
315
|
const size = pageSize || 10;
|
|
289
316
|
|
|
@@ -310,11 +337,19 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
310
337
|
}
|
|
311
338
|
);
|
|
312
339
|
|
|
340
|
+
useEffect(() => {
|
|
341
|
+
if (onTableDataChange) {
|
|
342
|
+
onTableDataChange(data);
|
|
343
|
+
}
|
|
344
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
345
|
+
}, [data]);
|
|
346
|
+
|
|
313
347
|
// Listen to invoice.paid event and refresh data
|
|
314
348
|
useEffect(() => {
|
|
315
349
|
if (subscription && customer_id) {
|
|
316
350
|
subscription.on('invoice.paid', async ({ response }: { response: TInvoiceExpanded }) => {
|
|
317
351
|
if (response.customer_id === customer_id) {
|
|
352
|
+
Toast.success(t('payment.customer.invoice.paySuccess'));
|
|
318
353
|
await reloadAsync();
|
|
319
354
|
}
|
|
320
355
|
});
|
|
@@ -497,6 +532,7 @@ CustomerInvoiceList.defaultProps = {
|
|
|
497
532
|
target: '_self',
|
|
498
533
|
action: '',
|
|
499
534
|
type: 'list',
|
|
535
|
+
onTableDataChange: () => {},
|
|
500
536
|
};
|
|
501
537
|
|
|
502
538
|
const Root = styled(Stack)`
|
package/src/libs/util.ts
CHANGED
|
@@ -1089,5 +1089,6 @@ export function getCustomerAvatar(
|
|
|
1089
1089
|
updated_at: string | number | undefined,
|
|
1090
1090
|
imageSize: number = 48
|
|
1091
1091
|
): string {
|
|
1092
|
-
|
|
1092
|
+
const updated = typeof updated_at === 'number' ? updated_at : dayjs(updated_at).unix();
|
|
1093
|
+
return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || dayjs().unix()}`;
|
|
1093
1094
|
}
|
package/src/payment/index.tsx
CHANGED
|
@@ -308,9 +308,6 @@ export default function Payment({
|
|
|
308
308
|
if (checkoutSession) {
|
|
309
309
|
if (livemode !== checkoutSession.livemode) {
|
|
310
310
|
setLivemode(checkoutSession.livemode);
|
|
311
|
-
setTimeout(() => {
|
|
312
|
-
refresh();
|
|
313
|
-
}, 10);
|
|
314
311
|
}
|
|
315
312
|
}
|
|
316
313
|
}, [checkoutSession, livemode, setLivemode, refresh]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Avatar, Stack, Typography } from '@mui/material';
|
|
1
|
+
import { Avatar, Box, Stack, Typography } from '@mui/material';
|
|
2
2
|
import type { LiteralUnion } from 'type-fest';
|
|
3
3
|
|
|
4
4
|
type Props = {
|
|
@@ -47,9 +47,9 @@ export default function ProductCard({ size, variant, name, logo, description, ex
|
|
|
47
47
|
</Typography>
|
|
48
48
|
)}
|
|
49
49
|
{extra && (
|
|
50
|
-
<
|
|
50
|
+
<Box sx={{ fontSize: '0.85rem' }} color="text.lighter">
|
|
51
51
|
{extra}
|
|
52
|
-
</
|
|
52
|
+
</Box>
|
|
53
53
|
)}
|
|
54
54
|
</Stack>
|
|
55
55
|
</Stack>
|