@blocklet/payment-react 1.18.56 → 1.19.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.d.ts +1 -15
- package/es/checkout/donate.js +301 -189
- package/es/checkout/form.d.ts +1 -15
- package/es/checkout/form.js +5 -13
- package/es/checkout/table.js +3 -3
- package/es/components/blockchain/gas.d.ts +1 -5
- package/es/components/blockchain/gas.js +10 -2
- package/es/components/blockchain/tx.d.ts +1 -8
- package/es/components/blockchain/tx.js +29 -10
- package/es/components/confirm.d.ts +1 -10
- package/es/components/confirm.js +4 -10
- package/es/components/country-select.d.ts +3 -2
- package/es/components/country-select.js +375 -352
- package/es/components/date-range-picker.d.ts +13 -0
- package/es/components/date-range-picker.js +279 -0
- package/es/components/input.d.ts +14 -20
- package/es/components/input.js +51 -44
- package/es/components/label.d.ts +7 -0
- package/es/components/label.js +49 -0
- package/es/components/lazy-loader.js +1 -2
- package/es/components/link.d.ts +2 -9
- package/es/components/link.js +9 -6
- package/es/components/livemode.d.ts +2 -8
- package/es/components/livemode.js +1 -5
- package/es/components/loading-button.d.ts +6 -1
- package/es/components/loading-button.js +56 -66
- package/es/components/over-due-invoice-payment.d.ts +0 -18
- package/es/components/over-due-invoice-payment.js +138 -95
- package/es/components/payment-beneficiaries.d.ts +2 -7
- package/es/components/payment-beneficiaries.js +86 -40
- package/es/components/pricing-item.d.ts +0 -5
- package/es/components/pricing-item.js +1 -4
- package/es/components/pricing-table.d.ts +2 -10
- package/es/components/pricing-table.js +8 -7
- package/es/components/resume-subscription.d.ts +0 -10
- package/es/components/resume-subscription.js +42 -21
- package/es/components/truncated-text.d.ts +2 -9
- package/es/components/truncated-text.js +0 -5
- package/es/contexts/donate.d.ts +0 -7
- package/es/contexts/donate.js +10 -8
- package/es/contexts/payment.d.ts +1 -4
- package/es/contexts/payment.js +7 -2
- package/es/history/credit/grants-list.d.ts +14 -0
- package/es/history/credit/grants-list.js +215 -0
- package/es/history/credit/transactions-list.d.ts +13 -0
- package/es/history/credit/transactions-list.js +255 -0
- package/es/history/invoice/list.d.ts +2 -18
- package/es/history/invoice/list.js +172 -74
- package/es/history/payment/list.js +115 -38
- package/es/hooks/keyboard.d.ts +1 -1
- package/es/hooks/keyboard.js +2 -4
- package/es/index.d.ts +5 -1
- package/es/index.js +10 -1
- package/es/libs/cached-request.js +2 -4
- package/es/libs/phone-validator.js +1 -2
- package/es/libs/util.d.ts +2 -0
- package/es/libs/util.js +14 -4
- package/es/libs/validator.js +2 -4
- package/es/locales/en.js +20 -2
- package/es/locales/zh.js +20 -2
- package/es/payment/amount.d.ts +2 -7
- package/es/payment/amount.js +1 -5
- package/es/payment/donation-form.d.ts +2 -10
- package/es/payment/donation-form.js +196 -160
- package/es/payment/error.d.ts +2 -8
- package/es/payment/error.js +40 -20
- package/es/payment/footer.d.ts +2 -3
- package/es/payment/footer.js +19 -6
- package/es/payment/form/addon.js +14 -4
- package/es/payment/form/address.d.ts +2 -9
- package/es/payment/form/address.js +3 -6
- package/es/payment/form/currency.js +45 -25
- package/es/payment/form/index.d.ts +2 -8
- package/es/payment/form/index.js +151 -71
- package/es/payment/form/phone.js +2 -4
- package/es/payment/form/stripe/form.d.ts +2 -8
- package/es/payment/form/stripe/form.js +1 -3
- package/es/payment/header.js +38 -16
- package/es/payment/index.d.ts +2 -9
- package/es/payment/index.js +23 -17
- package/es/payment/product-card.d.ts +2 -11
- package/es/payment/product-card.js +84 -50
- package/es/payment/product-donation.js +175 -114
- package/es/payment/product-item.d.ts +9 -9
- package/es/payment/product-item.js +320 -145
- package/es/payment/product-skeleton.js +2 -2
- package/es/payment/skeleton/donation.js +27 -7
- package/es/payment/skeleton/overview.js +22 -2
- package/es/payment/skeleton/payment.js +33 -5
- package/es/payment/success.d.ts +2 -9
- package/es/payment/success.js +41 -14
- package/es/payment/summary.d.ts +4 -17
- package/es/payment/summary.js +193 -111
- package/es/theme/index.d.ts +0 -5
- package/es/theme/index.js +2 -5
- package/es/theme/typography.d.ts +2 -2
- package/lib/checkout/donate.d.ts +1 -15
- package/lib/checkout/donate.js +75 -54
- package/lib/checkout/form.d.ts +1 -15
- package/lib/checkout/form.js +7 -15
- package/lib/checkout/table.js +4 -4
- package/lib/components/blockchain/gas.d.ts +1 -5
- package/lib/components/blockchain/gas.js +3 -2
- package/lib/components/blockchain/tx.d.ts +1 -8
- package/lib/components/blockchain/tx.js +15 -10
- package/lib/components/confirm.d.ts +1 -10
- package/lib/components/confirm.js +5 -11
- package/lib/components/country-select.d.ts +3 -2
- package/lib/components/country-select.js +23 -22
- package/lib/components/date-range-picker.d.ts +13 -0
- package/lib/components/date-range-picker.js +329 -0
- package/lib/components/input.d.ts +14 -20
- package/lib/components/input.js +28 -27
- package/lib/components/label.d.ts +7 -0
- package/lib/components/label.js +60 -0
- package/lib/components/lazy-loader.js +1 -1
- package/lib/components/link.d.ts +2 -9
- package/lib/components/link.js +3 -8
- package/lib/components/livemode.d.ts +2 -8
- package/lib/components/livemode.js +3 -7
- package/lib/components/loading-button.d.ts +6 -1
- package/lib/components/loading-button.js +9 -17
- package/lib/components/over-due-invoice-payment.d.ts +0 -18
- package/lib/components/over-due-invoice-payment.js +31 -33
- package/lib/components/payment-beneficiaries.d.ts +2 -7
- package/lib/components/payment-beneficiaries.js +12 -11
- package/lib/components/pricing-item.d.ts +0 -5
- package/lib/components/pricing-item.js +2 -5
- package/lib/components/pricing-table.d.ts +2 -10
- package/lib/components/pricing-table.js +5 -11
- package/lib/components/resume-subscription.d.ts +0 -10
- package/lib/components/resume-subscription.js +16 -16
- package/lib/components/table.js +1 -1
- package/lib/components/truncated-text.d.ts +2 -9
- package/lib/components/truncated-text.js +1 -6
- package/lib/contexts/donate.d.ts +0 -7
- package/lib/contexts/donate.js +4 -7
- package/lib/contexts/payment.d.ts +1 -4
- package/lib/contexts/payment.js +4 -7
- package/lib/history/credit/grants-list.d.ts +14 -0
- package/lib/history/credit/grants-list.js +277 -0
- package/lib/history/credit/transactions-list.d.ts +13 -0
- package/lib/history/credit/transactions-list.js +301 -0
- package/lib/history/invoice/list.d.ts +2 -18
- package/lib/history/invoice/list.js +73 -37
- package/lib/history/payment/list.js +30 -16
- package/lib/hooks/keyboard.d.ts +1 -1
- package/lib/hooks/mobile.js +1 -1
- package/lib/hooks/subscription.js +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +41 -2
- package/lib/libs/api.js +1 -1
- package/lib/libs/dayjs.js +1 -1
- package/lib/libs/phone-validator.js +0 -2
- package/lib/libs/theme.js +1 -1
- package/lib/libs/util.d.ts +2 -0
- package/lib/libs/util.js +15 -1
- package/lib/libs/validator.js +1 -1
- package/lib/locales/en.js +21 -3
- package/lib/locales/index.js +1 -1
- package/lib/locales/zh.js +21 -3
- package/lib/payment/amount.d.ts +2 -7
- package/lib/payment/amount.js +2 -6
- package/lib/payment/donation-form.d.ts +2 -10
- package/lib/payment/donation-form.js +33 -38
- package/lib/payment/error.d.ts +2 -8
- package/lib/payment/error.js +11 -13
- package/lib/payment/footer.d.ts +2 -3
- package/lib/payment/footer.js +5 -5
- package/lib/payment/form/addon.js +5 -3
- package/lib/payment/form/address.d.ts +2 -9
- package/lib/payment/form/address.js +5 -8
- package/lib/payment/form/currency.js +3 -3
- package/lib/payment/form/index.d.ts +2 -8
- package/lib/payment/form/index.js +64 -21
- package/lib/payment/form/phone.js +1 -1
- package/lib/payment/form/stripe/form.d.ts +2 -8
- package/lib/payment/form/stripe/form.js +3 -6
- package/lib/payment/header.js +8 -4
- package/lib/payment/index.d.ts +2 -9
- package/lib/payment/index.js +27 -18
- package/lib/payment/product-card.d.ts +2 -11
- package/lib/payment/product-card.js +13 -20
- package/lib/payment/product-donation.js +71 -66
- package/lib/payment/product-item.d.ts +9 -9
- package/lib/payment/product-item.js +168 -29
- package/lib/payment/product-skeleton.js +2 -2
- package/lib/payment/skeleton/donation.js +8 -4
- package/lib/payment/skeleton/overview.js +6 -2
- package/lib/payment/skeleton/payment.js +9 -3
- package/lib/payment/success.d.ts +2 -9
- package/lib/payment/success.js +12 -15
- package/lib/payment/summary.d.ts +4 -17
- package/lib/payment/summary.js +53 -45
- package/lib/theme/index.d.ts +0 -5
- package/lib/theme/index.js +2 -5
- package/lib/theme/typography.d.ts +2 -2
- package/package.json +40 -40
- package/src/checkout/donate.tsx +103 -35
- package/src/checkout/form.tsx +5 -14
- package/src/checkout/table.tsx +3 -3
- package/src/components/blockchain/gas.tsx +5 -3
- package/src/components/blockchain/tx.tsx +19 -11
- package/src/components/confirm.tsx +4 -11
- package/src/components/country-select.tsx +391 -378
- package/src/components/date-range-picker.tsx +310 -0
- package/src/components/input.tsx +61 -46
- package/src/components/label.tsx +58 -0
- package/src/components/link.tsx +9 -7
- package/src/components/livemode.tsx +2 -6
- package/src/components/loading-button.tsx +63 -76
- package/src/components/over-due-invoice-payment.tsx +43 -28
- package/src/components/payment-beneficiaries.tsx +33 -14
- package/src/components/pricing-item.tsx +1 -4
- package/src/components/pricing-table.tsx +8 -8
- package/src/components/resume-subscription.tsx +20 -14
- package/src/components/table.tsx +2 -2
- package/src/components/truncated-text.tsx +0 -6
- package/src/contexts/donate.tsx +6 -7
- package/src/contexts/payment.tsx +7 -3
- package/src/history/credit/grants-list.tsx +276 -0
- package/src/history/credit/transactions-list.tsx +317 -0
- package/src/history/invoice/list.tsx +92 -36
- package/src/history/payment/list.tsx +53 -16
- package/src/hooks/keyboard.ts +1 -1
- package/src/index.ts +9 -0
- package/src/libs/util.ts +14 -0
- package/src/locales/en.tsx +20 -0
- package/src/locales/zh.tsx +19 -0
- package/src/payment/amount.tsx +1 -6
- package/src/payment/donation-form.tsx +47 -29
- package/src/payment/error.tsx +16 -8
- package/src/payment/footer.tsx +11 -3
- package/src/payment/form/addon.tsx +6 -1
- package/src/payment/form/address.tsx +3 -7
- package/src/payment/form/currency.tsx +12 -2
- package/src/payment/form/index.tsx +121 -45
- package/src/payment/form/stripe/form.tsx +1 -5
- package/src/payment/header.tsx +14 -2
- package/src/payment/index.tsx +27 -22
- package/src/payment/product-card.tsx +41 -18
- package/src/payment/product-donation.tsx +85 -47
- package/src/payment/product-item.tsx +198 -28
- package/src/payment/product-skeleton.tsx +3 -2
- package/src/payment/skeleton/donation.tsx +12 -2
- package/src/payment/skeleton/overview.tsx +12 -2
- package/src/payment/skeleton/payment.tsx +16 -3
- package/src/payment/success.tsx +26 -15
- package/src/payment/summary.tsx +87 -44
- package/src/theme/index.tsx +5 -8
- package/src/theme/typography.ts +2 -2
|
@@ -8,7 +8,7 @@ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
|
8
8
|
import Toast from '@arcblock/ux/lib/Toast';
|
|
9
9
|
import type { Paginated, TInvoiceExpanded, TSubscription } from '@blocklet/payment-types';
|
|
10
10
|
import { OpenInNewOutlined } from '@mui/icons-material';
|
|
11
|
-
import { Box, Button, CircularProgress, Stack, Typography, Tooltip } from '@mui/material';
|
|
11
|
+
import { Box, Button, CircularProgress, Stack, Typography, Tooltip, Avatar } from '@mui/material';
|
|
12
12
|
import { styled } from '@mui/system';
|
|
13
13
|
import { useInfiniteScroll, useRequest, useSetState } from 'ahooks';
|
|
14
14
|
import React, { useEffect, useRef, useState } from 'react';
|
|
@@ -207,6 +207,23 @@ const InvoiceTable = React.memo((props: Props & { onPay: (invoiceId: string) =>
|
|
|
207
207
|
},
|
|
208
208
|
},
|
|
209
209
|
},
|
|
210
|
+
{
|
|
211
|
+
label: t('common.paymentMethod'),
|
|
212
|
+
name: 'paymentMethod',
|
|
213
|
+
options: {
|
|
214
|
+
customBodyRenderLite: (_: string, index: number) => {
|
|
215
|
+
const invoice = data?.list[index] as TInvoiceExpanded;
|
|
216
|
+
return (
|
|
217
|
+
<Typography
|
|
218
|
+
sx={{ display: 'flex', alignItems: 'center', whiteSpace: 'nowrap' }}
|
|
219
|
+
onClick={(e) => handleLinkClick(e, invoice)}>
|
|
220
|
+
<Avatar src={invoice.paymentMethod.logo} sx={{ width: 18, height: 18, mr: 1 }} />
|
|
221
|
+
{invoice.paymentMethod.name}
|
|
222
|
+
</Typography>
|
|
223
|
+
);
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
210
227
|
{
|
|
211
228
|
label: t('common.type'),
|
|
212
229
|
name: 'billing_reason',
|
|
@@ -469,14 +486,22 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
469
486
|
if (data && data.list.length === 0) {
|
|
470
487
|
if (data.subscription && ['active', 'trialing'].includes(data.subscription.status)) {
|
|
471
488
|
return (
|
|
472
|
-
<Typography
|
|
489
|
+
<Typography
|
|
490
|
+
sx={{
|
|
491
|
+
color: 'text.secondary',
|
|
492
|
+
my: 0.5,
|
|
493
|
+
}}>
|
|
473
494
|
{t('payment.customer.invoice.next', { date: formatToDatetime(data.subscription.current_period_end * 1000) })}
|
|
474
495
|
</Typography>
|
|
475
496
|
);
|
|
476
497
|
}
|
|
477
498
|
|
|
478
499
|
return (
|
|
479
|
-
<Typography
|
|
500
|
+
<Typography
|
|
501
|
+
sx={{
|
|
502
|
+
color: 'text.secondary',
|
|
503
|
+
my: 0.5,
|
|
504
|
+
}}>
|
|
480
505
|
{t('payment.customer.invoice.empty')}
|
|
481
506
|
</Typography>
|
|
482
507
|
);
|
|
@@ -502,21 +527,32 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
502
527
|
<Stack
|
|
503
528
|
key={invoice.id}
|
|
504
529
|
direction="row"
|
|
505
|
-
sx={{
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
530
|
+
sx={{
|
|
531
|
+
gap: {
|
|
532
|
+
xs: 0.5,
|
|
533
|
+
sm: 1.5,
|
|
534
|
+
md: 3,
|
|
535
|
+
},
|
|
536
|
+
|
|
537
|
+
alignItems: 'center',
|
|
538
|
+
flexWrap: 'nowrap',
|
|
539
|
+
my: 1,
|
|
540
|
+
}}>
|
|
541
|
+
<Box
|
|
542
|
+
sx={{
|
|
543
|
+
flex: 2,
|
|
544
|
+
}}>
|
|
514
545
|
<a
|
|
515
546
|
href={link.url}
|
|
516
547
|
target={link.external ? '_blank' : target}
|
|
517
548
|
rel="noreferrer"
|
|
518
549
|
onClick={(e) => handleLinkClick(e, link)}>
|
|
519
|
-
<Stack
|
|
550
|
+
<Stack
|
|
551
|
+
direction="row"
|
|
552
|
+
spacing={0.5}
|
|
553
|
+
sx={{
|
|
554
|
+
alignItems: 'center',
|
|
555
|
+
}}>
|
|
520
556
|
<Typography component="span">{invoice.number}</Typography>
|
|
521
557
|
{link.external && (
|
|
522
558
|
<OpenInNewOutlined
|
|
@@ -530,25 +566,39 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
530
566
|
</Stack>
|
|
531
567
|
</a>
|
|
532
568
|
</Box>
|
|
533
|
-
<Box
|
|
569
|
+
<Box
|
|
570
|
+
sx={{
|
|
571
|
+
flex: 1,
|
|
572
|
+
textAlign: 'right',
|
|
573
|
+
}}>
|
|
534
574
|
<Typography sx={isVoid ? { textDecoration: 'line-through' } : {}}>
|
|
535
575
|
{formatBNStr(invoice.total, invoice.paymentCurrency.decimal)}
|
|
536
576
|
{invoice.paymentCurrency.symbol}
|
|
537
577
|
</Typography>
|
|
538
578
|
</Box>
|
|
539
|
-
<Box
|
|
579
|
+
<Box
|
|
580
|
+
sx={{
|
|
581
|
+
flex: 1,
|
|
582
|
+
textAlign: 'right',
|
|
583
|
+
}}>
|
|
540
584
|
<Typography>{formatToDate(invoice.created_at, locale, 'HH:mm:ss')}</Typography>
|
|
541
585
|
</Box>
|
|
542
586
|
{!action && (
|
|
543
587
|
<Box
|
|
544
|
-
flex={2}
|
|
545
588
|
className="invoice-description"
|
|
546
|
-
|
|
547
|
-
|
|
589
|
+
sx={{
|
|
590
|
+
flex: 2,
|
|
591
|
+
textAlign: 'right',
|
|
592
|
+
display: { xs: 'none', lg: 'inline-flex' },
|
|
593
|
+
}}>
|
|
548
594
|
<Typography>{invoice.description || invoice.id}</Typography>
|
|
549
595
|
</Box>
|
|
550
596
|
)}
|
|
551
|
-
<Box
|
|
597
|
+
<Box
|
|
598
|
+
sx={{
|
|
599
|
+
flex: 1,
|
|
600
|
+
textAlign: 'right',
|
|
601
|
+
}}>
|
|
552
602
|
{action ? (
|
|
553
603
|
connect ? (
|
|
554
604
|
<Button
|
|
@@ -594,7 +644,10 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
594
644
|
</Button>
|
|
595
645
|
)}
|
|
596
646
|
{!hasMore && data.count > size && (
|
|
597
|
-
<Typography
|
|
647
|
+
<Typography
|
|
648
|
+
sx={{
|
|
649
|
+
color: 'text.secondary',
|
|
650
|
+
}}>
|
|
598
651
|
{t('common.noMore', { resource: t('payment.customer.invoices') })}
|
|
599
652
|
</Typography>
|
|
600
653
|
)}
|
|
@@ -603,7 +656,25 @@ const InvoiceList = React.memo((props: Props & { onPay: (invoiceId: string) => v
|
|
|
603
656
|
);
|
|
604
657
|
});
|
|
605
658
|
|
|
606
|
-
export default function CustomerInvoiceList(
|
|
659
|
+
export default function CustomerInvoiceList(rawProps: Props) {
|
|
660
|
+
const props = Object.assign(
|
|
661
|
+
{
|
|
662
|
+
customer_id: '',
|
|
663
|
+
subscription_id: '',
|
|
664
|
+
currency_id: '',
|
|
665
|
+
include_staking: false,
|
|
666
|
+
include_recovered_from: false,
|
|
667
|
+
status: 'open,paid,uncollectible',
|
|
668
|
+
pageSize: 10,
|
|
669
|
+
target: '_self',
|
|
670
|
+
action: '',
|
|
671
|
+
type: 'list',
|
|
672
|
+
onTableDataChange: () => {},
|
|
673
|
+
relatedSubscription: false,
|
|
674
|
+
},
|
|
675
|
+
rawProps
|
|
676
|
+
);
|
|
677
|
+
// eslint-disable-next-line react/prop-types
|
|
607
678
|
const { action, type } = props;
|
|
608
679
|
const { t, locale } = useLocaleContext();
|
|
609
680
|
const { connect } = usePaymentContext();
|
|
@@ -649,21 +720,6 @@ export default function CustomerInvoiceList(props: Props) {
|
|
|
649
720
|
return <InvoiceList {...props} onPay={onPay} />;
|
|
650
721
|
}
|
|
651
722
|
|
|
652
|
-
CustomerInvoiceList.defaultProps = {
|
|
653
|
-
customer_id: '',
|
|
654
|
-
subscription_id: '',
|
|
655
|
-
currency_id: '',
|
|
656
|
-
include_staking: false,
|
|
657
|
-
include_recovered_from: false,
|
|
658
|
-
status: 'open,paid,uncollectible',
|
|
659
|
-
pageSize: 10,
|
|
660
|
-
target: '_self',
|
|
661
|
-
action: '',
|
|
662
|
-
type: 'list',
|
|
663
|
-
onTableDataChange: () => {},
|
|
664
|
-
relatedSubscription: false,
|
|
665
|
-
};
|
|
666
|
-
|
|
667
723
|
const Root = styled(Stack)`
|
|
668
724
|
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
669
725
|
svg.MuiSvgIcon-root {
|
|
@@ -53,7 +53,14 @@ export default function CustomerPaymentList({ customer_id }: Props) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
if (data && data.list.length === 0) {
|
|
56
|
-
return
|
|
56
|
+
return (
|
|
57
|
+
<Typography
|
|
58
|
+
sx={{
|
|
59
|
+
color: 'text.secondary',
|
|
60
|
+
}}>
|
|
61
|
+
{t('payment.customer.payment.empty')}
|
|
62
|
+
</Typography>
|
|
63
|
+
);
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
const hasMore = data && data.list.length < data.count;
|
|
@@ -61,7 +68,12 @@ export default function CustomerPaymentList({ customer_id }: Props) {
|
|
|
61
68
|
const grouped = groupByDate(data.list);
|
|
62
69
|
|
|
63
70
|
return (
|
|
64
|
-
<Stack
|
|
71
|
+
<Stack
|
|
72
|
+
direction="column"
|
|
73
|
+
sx={{
|
|
74
|
+
gap: 1,
|
|
75
|
+
mt: 1,
|
|
76
|
+
}}>
|
|
65
77
|
{Object.entries(grouped).map(([date, payments]) => (
|
|
66
78
|
<Box key={date}>
|
|
67
79
|
<Typography sx={{ fontWeight: 'bold', color: 'text.secondary', mt: 2, mb: 1 }}>{date}</Typography>
|
|
@@ -72,29 +84,51 @@ export default function CustomerPaymentList({ customer_id }: Props) {
|
|
|
72
84
|
xs: 'column',
|
|
73
85
|
sm: 'row',
|
|
74
86
|
}}
|
|
75
|
-
sx={{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
sx={{
|
|
88
|
+
gap: {
|
|
89
|
+
xs: 0.5,
|
|
90
|
+
sm: 1.5,
|
|
91
|
+
md: 3,
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
flexWrap: 'nowrap',
|
|
95
|
+
my: 1,
|
|
96
|
+
}}>
|
|
97
|
+
<Box
|
|
98
|
+
sx={{
|
|
99
|
+
flex: 3,
|
|
100
|
+
}}>
|
|
83
101
|
<Typography>{formatToDate(item.created_at)}</Typography>
|
|
84
102
|
</Box>
|
|
85
|
-
<Box
|
|
86
|
-
|
|
103
|
+
<Box
|
|
104
|
+
sx={{
|
|
105
|
+
flex: 2,
|
|
106
|
+
}}>
|
|
107
|
+
<Typography
|
|
108
|
+
sx={{
|
|
109
|
+
textAlign: 'right',
|
|
110
|
+
}}>
|
|
87
111
|
{formatBNStr(item.amount_received, item.paymentCurrency.decimal)}
|
|
88
112
|
{item.paymentCurrency.symbol}
|
|
89
113
|
</Typography>
|
|
90
114
|
</Box>
|
|
91
|
-
<Box
|
|
115
|
+
<Box
|
|
116
|
+
sx={{
|
|
117
|
+
flex: 3,
|
|
118
|
+
}}>
|
|
92
119
|
<Status label={item.status} color={getPaymentIntentStatusColor(item.status)} />
|
|
93
120
|
</Box>
|
|
94
|
-
<Box
|
|
121
|
+
<Box
|
|
122
|
+
sx={{
|
|
123
|
+
flex: 3,
|
|
124
|
+
}}>
|
|
95
125
|
<Typography>{item.description || '-'}</Typography>
|
|
96
126
|
</Box>
|
|
97
|
-
<Box
|
|
127
|
+
<Box
|
|
128
|
+
sx={{
|
|
129
|
+
flex: 3,
|
|
130
|
+
minWidth: '220px',
|
|
131
|
+
}}>
|
|
98
132
|
{(item.payment_details?.arcblock?.tx_hash ||
|
|
99
133
|
item.payment_details?.ethereum?.tx_hash ||
|
|
100
134
|
item.payment_details?.base?.tx_hash) && (
|
|
@@ -114,7 +148,10 @@ export default function CustomerPaymentList({ customer_id }: Props) {
|
|
|
114
148
|
</Button>
|
|
115
149
|
)}
|
|
116
150
|
{!hasMore && data.count > pageSize && (
|
|
117
|
-
<Typography
|
|
151
|
+
<Typography
|
|
152
|
+
sx={{
|
|
153
|
+
color: 'text.secondary',
|
|
154
|
+
}}>
|
|
118
155
|
{t('common.noMore', { resource: t('payment.customer.payments') })}
|
|
119
156
|
</Typography>
|
|
120
157
|
)}
|
package/src/hooks/keyboard.ts
CHANGED
|
@@ -14,7 +14,7 @@ type TabNavigationOptions<T> = {
|
|
|
14
14
|
/** a selector to find navigable elements */
|
|
15
15
|
selector?: string;
|
|
16
16
|
/** an element container reference, limiting the query DOM range to improve performance */
|
|
17
|
-
containerRef?: RefObject<HTMLElement>;
|
|
17
|
+
containerRef?: RefObject<HTMLElement | null>;
|
|
18
18
|
/** the type of the current value, can be 'index' or 'value' */
|
|
19
19
|
valueType?: 'index' | 'value';
|
|
20
20
|
};
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import TxGas from './components/blockchain/gas';
|
|
|
5
5
|
import TxLink from './components/blockchain/tx';
|
|
6
6
|
import ConfirmDialog from './components/confirm';
|
|
7
7
|
import FormInput from './components/input';
|
|
8
|
+
import FormLabel from './components/label';
|
|
8
9
|
import Livemode from './components/livemode';
|
|
9
10
|
import PricingTable from './components/pricing-table';
|
|
10
11
|
import Table from './components/table';
|
|
@@ -13,6 +14,8 @@ import Status from './components/status';
|
|
|
13
14
|
import Switch from './components/switch-button';
|
|
14
15
|
import CustomerInvoiceList from './history/invoice/list';
|
|
15
16
|
import CustomerPaymentList from './history/payment/list';
|
|
17
|
+
import CreditGrantsList, { StatusChip as CreditStatusChip } from './history/credit/grants-list';
|
|
18
|
+
import CreditTransactionsList from './history/credit/transactions-list';
|
|
16
19
|
import api from './libs/api';
|
|
17
20
|
import dayjs from './libs/dayjs';
|
|
18
21
|
import Amount from './payment/amount';
|
|
@@ -32,6 +35,7 @@ import OverdueInvoicePayment from './components/over-due-invoice-payment';
|
|
|
32
35
|
import PaymentBeneficiaries from './components/payment-beneficiaries';
|
|
33
36
|
import LoadingButton from './components/loading-button';
|
|
34
37
|
import ResumeSubscription from './components/resume-subscription';
|
|
38
|
+
import DateRangePicker from './components/date-range-picker';
|
|
35
39
|
|
|
36
40
|
export { PaymentThemeProvider } from './theme';
|
|
37
41
|
|
|
@@ -55,6 +59,7 @@ export {
|
|
|
55
59
|
api,
|
|
56
60
|
dayjs,
|
|
57
61
|
FormInput,
|
|
62
|
+
FormLabel,
|
|
58
63
|
PhoneInput,
|
|
59
64
|
AddressForm,
|
|
60
65
|
StripeForm,
|
|
@@ -86,4 +91,8 @@ export {
|
|
|
86
91
|
LoadingButton,
|
|
87
92
|
DonateDetails,
|
|
88
93
|
ResumeSubscription,
|
|
94
|
+
CreditGrantsList,
|
|
95
|
+
CreditTransactionsList,
|
|
96
|
+
DateRangePicker,
|
|
97
|
+
CreditStatusChip,
|
|
89
98
|
};
|
package/src/libs/util.ts
CHANGED
|
@@ -1283,3 +1283,17 @@ export function getTokenBalanceLink(method: TPaymentMethod, address: string) {
|
|
|
1283
1283
|
}
|
|
1284
1284
|
return '';
|
|
1285
1285
|
}
|
|
1286
|
+
|
|
1287
|
+
export function isCreditMetered(price: TPrice): boolean {
|
|
1288
|
+
return !!(price.type === 'recurring' && price.recurring?.usage_type === 'metered' && price.recurring?.meter_id);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
export function showStaking(method: TPaymentMethod, currency: TPaymentCurrency, noStake: boolean) {
|
|
1292
|
+
if (noStake) {
|
|
1293
|
+
return false;
|
|
1294
|
+
}
|
|
1295
|
+
if (method.type === 'arcblock') {
|
|
1296
|
+
return currency.type !== 'credit';
|
|
1297
|
+
}
|
|
1298
|
+
return true;
|
|
1299
|
+
}
|
package/src/locales/en.tsx
CHANGED
|
@@ -30,6 +30,10 @@ export default flat({
|
|
|
30
30
|
remove: 'Remove',
|
|
31
31
|
removed: 'Resource removed',
|
|
32
32
|
confirm: 'Confirm',
|
|
33
|
+
clear: 'Clear',
|
|
34
|
+
selectTimeRange: 'Select time range',
|
|
35
|
+
startDate: 'Start date',
|
|
36
|
+
endDate: 'End date',
|
|
33
37
|
upload: 'Upload',
|
|
34
38
|
change: 'Change',
|
|
35
39
|
cancel: 'Cancel',
|
|
@@ -103,6 +107,7 @@ export default flat({
|
|
|
103
107
|
confirm: 'Confirm',
|
|
104
108
|
cancel: 'Cancel',
|
|
105
109
|
},
|
|
110
|
+
paymentMethod: 'Payment Method',
|
|
106
111
|
},
|
|
107
112
|
payment: {
|
|
108
113
|
checkout: {
|
|
@@ -209,6 +214,11 @@ export default flat({
|
|
|
209
214
|
add: 'Add to order',
|
|
210
215
|
remove: 'Remove from order',
|
|
211
216
|
},
|
|
217
|
+
credit: {
|
|
218
|
+
oneTimeInfo: 'You will receive {amount} {symbol} credits after payment',
|
|
219
|
+
recurringInfo: 'You will receive {amount} {symbol} credits {period}',
|
|
220
|
+
expiresIn: 'credits have a validity period of {duration} {unit}',
|
|
221
|
+
},
|
|
212
222
|
expired: {
|
|
213
223
|
title: 'Expired Link',
|
|
214
224
|
description:
|
|
@@ -241,6 +251,16 @@ export default flat({
|
|
|
241
251
|
amount: 'Amount',
|
|
242
252
|
failed: 'Account changed, please pay manually.',
|
|
243
253
|
balanceLink: 'View Balance',
|
|
254
|
+
credit: {
|
|
255
|
+
title: 'Confirm Credit Payment',
|
|
256
|
+
availableAmount: 'Available Credit: {amount}',
|
|
257
|
+
confirmMessage: 'You will use {amount} credits to subscribe to this service.',
|
|
258
|
+
meteringSubscriptionMessage:
|
|
259
|
+
'This subscription service will deduct credits in real-time based on actual usage. You currently have {available} credits available. Confirm to continue?',
|
|
260
|
+
insufficientTitle: 'Insufficient Credit',
|
|
261
|
+
insufficientMessage:
|
|
262
|
+
'This subscription service will deduct credits in real-time based on actual usage. You currently have insufficient credits. Please top up your credits first.',
|
|
263
|
+
},
|
|
244
264
|
},
|
|
245
265
|
},
|
|
246
266
|
customer: {
|
package/src/locales/zh.tsx
CHANGED
|
@@ -33,6 +33,10 @@ export default flat({
|
|
|
33
33
|
change: '更换',
|
|
34
34
|
confirm: '确认',
|
|
35
35
|
cancel: '取消',
|
|
36
|
+
clear: '清空',
|
|
37
|
+
selectTimeRange: '选择时间范围',
|
|
38
|
+
startDate: '开始日期',
|
|
39
|
+
endDate: '结束日期',
|
|
36
40
|
close: '关闭',
|
|
37
41
|
back: '返回',
|
|
38
42
|
every: '每',
|
|
@@ -103,6 +107,7 @@ export default flat({
|
|
|
103
107
|
confirm: '确认',
|
|
104
108
|
cancel: '取消',
|
|
105
109
|
},
|
|
110
|
+
paymentMethod: '支付方式',
|
|
106
111
|
},
|
|
107
112
|
payment: {
|
|
108
113
|
checkout: {
|
|
@@ -215,6 +220,11 @@ export default flat({
|
|
|
215
220
|
add: '添加到订单',
|
|
216
221
|
remove: '从订单移除',
|
|
217
222
|
},
|
|
223
|
+
credit: {
|
|
224
|
+
oneTimeInfo: '付款完成后您将获得 {amount} {symbol} 额度',
|
|
225
|
+
recurringInfo: '您将{period}获得 {amount} {symbol} 额度',
|
|
226
|
+
expiresIn: '额度有效期为 {duration} {unit}',
|
|
227
|
+
},
|
|
218
228
|
emptyItems: {
|
|
219
229
|
title: '没有任何购买项目',
|
|
220
230
|
description: '可能这个付款链接没有正确配置',
|
|
@@ -236,6 +246,15 @@ export default flat({
|
|
|
236
246
|
amount: '支付金额',
|
|
237
247
|
failed: '账户发生变化,无法自动完成支付,请手动支付。',
|
|
238
248
|
balanceLink: '查看余额',
|
|
249
|
+
credit: {
|
|
250
|
+
title: '确认额度支付',
|
|
251
|
+
availableAmount: '可用额度:{amount}',
|
|
252
|
+
confirmMessage: '您将使用 {amount} 额度来订阅此服务。',
|
|
253
|
+
meteringSubscriptionMessage:
|
|
254
|
+
'此订阅服务将根据实际使用情况实时扣除额度。您当前可用额度为 {available},确认是否继续?',
|
|
255
|
+
insufficientTitle: '额度不足',
|
|
256
|
+
insufficientMessage: '此订阅服务将根据实际使用情况实时扣除额度。您当前可用额度不足,请先充值额度。',
|
|
257
|
+
},
|
|
239
258
|
},
|
|
240
259
|
},
|
|
241
260
|
customer: {
|
package/src/payment/amount.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import type { TypographyProps } from '@mui/material';
|
|
|
3
3
|
|
|
4
4
|
type Props = { amount: string } & TypographyProps;
|
|
5
5
|
|
|
6
|
-
export default function PaymentAmount({ amount, sx }: Props) {
|
|
6
|
+
export default function PaymentAmount({ amount, sx = {} }: Props) {
|
|
7
7
|
return (
|
|
8
8
|
<Typography
|
|
9
9
|
component="div"
|
|
@@ -19,8 +19,3 @@ export default function PaymentAmount({ amount, sx }: Props) {
|
|
|
19
19
|
</Typography>
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
PaymentAmount.defaultProps = {
|
|
24
|
-
// eslint-disable-next-line react/default-props-match-prop-types
|
|
25
|
-
sx: {},
|
|
26
|
-
};
|
|
@@ -52,25 +52,19 @@ type Props = CheckoutContext &
|
|
|
52
52
|
id: string;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
PaymentInner.defaultProps = {
|
|
56
|
-
completed: false,
|
|
57
|
-
showCheckoutSummary: true,
|
|
58
|
-
formRender: {},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
55
|
function PaymentInner({
|
|
62
56
|
checkoutSession,
|
|
63
57
|
paymentMethods,
|
|
64
58
|
paymentLink,
|
|
65
59
|
paymentIntent,
|
|
66
60
|
customer,
|
|
67
|
-
completed,
|
|
61
|
+
completed = false,
|
|
68
62
|
mode,
|
|
69
63
|
onPaid,
|
|
70
64
|
onError,
|
|
71
65
|
onChange,
|
|
72
66
|
action,
|
|
73
|
-
formRender,
|
|
67
|
+
formRender = {},
|
|
74
68
|
benefits,
|
|
75
69
|
}: MainProps) {
|
|
76
70
|
const { t } = useLocaleContext();
|
|
@@ -227,7 +221,14 @@ function PaymentInner({
|
|
|
227
221
|
},
|
|
228
222
|
}}
|
|
229
223
|
/>
|
|
230
|
-
<Stack
|
|
224
|
+
<Stack
|
|
225
|
+
direction="row"
|
|
226
|
+
sx={{
|
|
227
|
+
justifyContent: 'flex-end',
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
flexWrap: 'wrap',
|
|
230
|
+
gap: 1,
|
|
231
|
+
}}>
|
|
231
232
|
<Button
|
|
232
233
|
variant="outlined"
|
|
233
234
|
size="large"
|
|
@@ -244,7 +245,13 @@ function PaymentInner({
|
|
|
244
245
|
)}
|
|
245
246
|
|
|
246
247
|
<Stack sx={{ display: benefitsState.open ? 'none' : 'block' }}>
|
|
247
|
-
<Stack
|
|
248
|
+
<Stack
|
|
249
|
+
direction="row"
|
|
250
|
+
sx={{
|
|
251
|
+
justifyContent: 'space-between',
|
|
252
|
+
alignItems: 'center',
|
|
253
|
+
mb: 2,
|
|
254
|
+
}}>
|
|
248
255
|
<Typography
|
|
249
256
|
title={t('payment.checkout.orderSummary')}
|
|
250
257
|
sx={{
|
|
@@ -311,7 +318,14 @@ function PaymentInner({
|
|
|
311
318
|
},
|
|
312
319
|
}}
|
|
313
320
|
/>
|
|
314
|
-
<Stack
|
|
321
|
+
<Stack
|
|
322
|
+
direction="row"
|
|
323
|
+
sx={{
|
|
324
|
+
justifyContent: 'space-between',
|
|
325
|
+
alignItems: 'center',
|
|
326
|
+
flexWrap: 'wrap',
|
|
327
|
+
gap: 1,
|
|
328
|
+
}}>
|
|
315
329
|
{benefits &&
|
|
316
330
|
benefits.length > 0 &&
|
|
317
331
|
(benefitsState.open ? (
|
|
@@ -331,18 +345,20 @@ function PaymentInner({
|
|
|
331
345
|
</Typography>
|
|
332
346
|
) : (
|
|
333
347
|
<Box
|
|
334
|
-
display="flex"
|
|
335
|
-
gap={0.5}
|
|
336
|
-
alignItems="center"
|
|
337
348
|
onClick={() => setBenefitsState({ open: true })}
|
|
338
349
|
sx={{
|
|
350
|
+
display: 'flex',
|
|
351
|
+
gap: 0.5,
|
|
352
|
+
alignItems: 'center',
|
|
339
353
|
color: 'text.secondary',
|
|
340
354
|
cursor: 'pointer',
|
|
355
|
+
|
|
341
356
|
'& .benefits-arrow': {
|
|
342
357
|
opacity: 0,
|
|
343
358
|
transform: 'translateX(-4px)',
|
|
344
359
|
transition: 'all 0.2s',
|
|
345
360
|
},
|
|
361
|
+
|
|
346
362
|
'&:hover': {
|
|
347
363
|
color: 'text.primary',
|
|
348
364
|
'& .benefits-arrow': {
|
|
@@ -358,13 +374,15 @@ function PaymentInner({
|
|
|
358
374
|
))}
|
|
359
375
|
{benefitsState.open ? null : (
|
|
360
376
|
<Box
|
|
361
|
-
display="flex"
|
|
362
|
-
gap={2}
|
|
363
377
|
sx={{
|
|
378
|
+
display: 'flex',
|
|
379
|
+
gap: 2,
|
|
380
|
+
|
|
364
381
|
flex: {
|
|
365
382
|
xs: 1,
|
|
366
383
|
md: 'auto',
|
|
367
384
|
},
|
|
385
|
+
|
|
368
386
|
justifyContent: 'flex-end',
|
|
369
387
|
whiteSpace: 'nowrap',
|
|
370
388
|
}}>
|
|
@@ -408,21 +426,14 @@ function PaymentInner({
|
|
|
408
426
|
);
|
|
409
427
|
}
|
|
410
428
|
|
|
411
|
-
DonationForm.defaultProps = {
|
|
412
|
-
completed: false,
|
|
413
|
-
error: null,
|
|
414
|
-
showCheckoutSummary: true,
|
|
415
|
-
formRender: {},
|
|
416
|
-
};
|
|
417
|
-
|
|
418
429
|
export default function DonationForm({
|
|
419
430
|
checkoutSession,
|
|
420
431
|
paymentMethods,
|
|
421
432
|
paymentIntent,
|
|
422
433
|
paymentLink,
|
|
423
434
|
customer,
|
|
424
|
-
completed,
|
|
425
|
-
error,
|
|
435
|
+
completed = false,
|
|
436
|
+
error = null,
|
|
426
437
|
mode,
|
|
427
438
|
onPaid,
|
|
428
439
|
onError,
|
|
@@ -430,7 +441,7 @@ export default function DonationForm({
|
|
|
430
441
|
goBack,
|
|
431
442
|
action,
|
|
432
443
|
showCheckoutSummary = true,
|
|
433
|
-
formRender,
|
|
444
|
+
formRender = {},
|
|
434
445
|
id,
|
|
435
446
|
}: Props) {
|
|
436
447
|
const { t } = useLocaleContext();
|
|
@@ -473,7 +484,14 @@ export default function DonationForm({
|
|
|
473
484
|
const footer = (
|
|
474
485
|
<>
|
|
475
486
|
<Divider sx={{ mt: { xs: '16px', md: '-24px' }, mb: { xs: '16px', md: '-16px' } }} />
|
|
476
|
-
<Stack
|
|
487
|
+
<Stack
|
|
488
|
+
direction="row"
|
|
489
|
+
sx={{
|
|
490
|
+
justifyContent: 'flex-end',
|
|
491
|
+
alignItems: 'center',
|
|
492
|
+
flexWrap: 'wrap',
|
|
493
|
+
gap: 1,
|
|
494
|
+
}}>
|
|
477
495
|
<Button variant="outlined" size="large" onClick={formRender?.onCancel}>
|
|
478
496
|
{t('common.cancel')}
|
|
479
497
|
</Button>
|
|
@@ -540,9 +558,9 @@ export default function DonationForm({
|
|
|
540
558
|
|
|
541
559
|
return (
|
|
542
560
|
<Stack
|
|
543
|
-
display="flex"
|
|
544
|
-
flexDirection="column"
|
|
545
561
|
sx={{
|
|
562
|
+
display: 'flex',
|
|
563
|
+
flexDirection: 'column',
|
|
546
564
|
height: mode === 'standalone' ? '100vh' : 'auto',
|
|
547
565
|
overflow: isMobileSafariEnv ? 'visible' : 'hidden',
|
|
548
566
|
}}>
|