payment-kit 1.19.0 → 1.19.2
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/api/src/crons/index.ts +8 -0
- package/api/src/index.ts +4 -0
- package/api/src/libs/credit-grant.ts +146 -0
- package/api/src/libs/env.ts +1 -0
- package/api/src/libs/invoice.ts +4 -3
- package/api/src/libs/notification/template/base.ts +388 -2
- package/api/src/libs/notification/template/customer-credit-grant-granted.ts +149 -0
- package/api/src/libs/notification/template/customer-credit-grant-low-balance.ts +151 -0
- package/api/src/libs/notification/template/customer-credit-insufficient.ts +254 -0
- package/api/src/libs/notification/template/subscription-canceled.ts +193 -202
- package/api/src/libs/notification/template/subscription-refund-succeeded.ts +215 -237
- package/api/src/libs/notification/template/subscription-renewed.ts +130 -200
- package/api/src/libs/notification/template/subscription-succeeded.ts +100 -202
- package/api/src/libs/notification/template/subscription-trial-start.ts +142 -188
- package/api/src/libs/notification/template/subscription-trial-will-end.ts +146 -174
- package/api/src/libs/notification/template/subscription-upgraded.ts +96 -192
- package/api/src/libs/notification/template/subscription-will-canceled.ts +94 -135
- package/api/src/libs/notification/template/subscription-will-renew.ts +220 -245
- package/api/src/libs/payment.ts +69 -0
- package/api/src/libs/queue/index.ts +3 -2
- package/api/src/libs/session.ts +8 -0
- package/api/src/libs/subscription.ts +74 -3
- package/api/src/libs/util.ts +3 -1
- package/api/src/libs/ws.ts +23 -1
- package/api/src/locales/en.ts +33 -0
- package/api/src/locales/zh.ts +31 -0
- package/api/src/queues/credit-consume.ts +728 -0
- package/api/src/queues/credit-grant.ts +572 -0
- package/api/src/queues/notification.ts +173 -128
- package/api/src/queues/payment.ts +210 -122
- package/api/src/queues/subscription.ts +179 -0
- package/api/src/routes/checkout-sessions.ts +157 -9
- package/api/src/routes/connect/shared.ts +3 -2
- package/api/src/routes/credit-grants.ts +241 -0
- package/api/src/routes/credit-transactions.ts +208 -0
- package/api/src/routes/customers.ts +34 -5
- package/api/src/routes/index.ts +8 -0
- package/api/src/routes/meter-events.ts +347 -0
- package/api/src/routes/meters.ts +219 -0
- package/api/src/routes/payment-currencies.ts +20 -2
- package/api/src/routes/payment-links.ts +1 -1
- package/api/src/routes/payment-methods.ts +14 -2
- package/api/src/routes/prices.ts +43 -0
- package/api/src/routes/pricing-table.ts +13 -7
- package/api/src/routes/products.ts +63 -4
- package/api/src/routes/settings.ts +1 -1
- package/api/src/routes/subscriptions.ts +4 -0
- package/api/src/routes/webhook-endpoints.ts +0 -3
- package/api/src/store/migrations/20250610-billing-credit.ts +43 -0
- package/api/src/store/models/credit-grant.ts +486 -0
- package/api/src/store/models/credit-transaction.ts +268 -0
- package/api/src/store/models/customer.ts +8 -0
- package/api/src/store/models/index.ts +52 -1
- package/api/src/store/models/meter-event.ts +423 -0
- package/api/src/store/models/meter.ts +176 -0
- package/api/src/store/models/payment-currency.ts +66 -14
- package/api/src/store/models/price.ts +6 -0
- package/api/src/store/models/product.ts +2 -2
- package/api/src/store/models/subscription.ts +24 -0
- package/api/src/store/models/types.ts +28 -2
- package/api/tests/libs/subscription.spec.ts +53 -0
- package/blocklet.yml +9 -1
- package/package.json +4 -4
- package/scripts/sdk.js +233 -1
- package/src/app.tsx +10 -0
- package/src/components/collapse.tsx +11 -1
- package/src/components/conditional-section.tsx +87 -0
- package/src/components/customer/credit-grant-item-list.tsx +99 -0
- package/src/components/customer/credit-overview.tsx +246 -0
- package/src/components/customer/form.tsx +7 -3
- package/src/components/invoice/list.tsx +19 -1
- package/src/components/metadata/form.tsx +287 -91
- package/src/components/meter/actions.tsx +101 -0
- package/src/components/meter/add-usage-dialog.tsx +239 -0
- package/src/components/meter/events-list.tsx +657 -0
- package/src/components/meter/form.tsx +245 -0
- package/src/components/meter/products.tsx +264 -0
- package/src/components/meter/usage-guide.tsx +174 -0
- package/src/components/payment-currency/form.tsx +2 -0
- package/src/components/payment-intent/list.tsx +19 -1
- package/src/components/payment-link/item.tsx +2 -2
- package/src/components/payment-link/preview.tsx +1 -1
- package/src/components/payment-link/product-select.tsx +52 -12
- package/src/components/payment-method/arcblock.tsx +2 -0
- package/src/components/payment-method/base.tsx +2 -0
- package/src/components/payment-method/bitcoin.tsx +2 -0
- package/src/components/payment-method/ethereum.tsx +2 -0
- package/src/components/payment-method/stripe.tsx +2 -0
- package/src/components/payouts/list.tsx +19 -1
- package/src/components/payouts/portal/list.tsx +6 -11
- package/src/components/price/currency-select.tsx +56 -32
- package/src/components/price/form.tsx +912 -407
- package/src/components/pricing-table/preview.tsx +1 -1
- package/src/components/product/add-price.tsx +9 -7
- package/src/components/product/create.tsx +7 -4
- package/src/components/product/edit-price.tsx +21 -12
- package/src/components/product/features.tsx +17 -7
- package/src/components/product/form.tsx +100 -90
- package/src/components/refund/list.tsx +19 -1
- package/src/components/section/header.tsx +5 -18
- package/src/components/subscription/items/index.tsx +1 -1
- package/src/components/subscription/metrics.tsx +37 -5
- package/src/components/subscription/portal/actions.tsx +2 -1
- package/src/contexts/products.tsx +26 -9
- package/src/hooks/subscription.ts +34 -0
- package/src/libs/meter-utils.ts +196 -0
- package/src/libs/util.ts +4 -0
- package/src/locales/en.tsx +389 -5
- package/src/locales/zh.tsx +368 -1
- package/src/pages/admin/billing/index.tsx +61 -33
- package/src/pages/admin/billing/invoices/detail.tsx +1 -1
- package/src/pages/admin/billing/meters/create.tsx +60 -0
- package/src/pages/admin/billing/meters/detail.tsx +435 -0
- package/src/pages/admin/billing/meters/index.tsx +210 -0
- package/src/pages/admin/billing/meters/meter-event.tsx +346 -0
- package/src/pages/admin/billing/subscriptions/detail.tsx +47 -14
- package/src/pages/admin/customers/customers/credit-grant/detail.tsx +391 -0
- package/src/pages/admin/customers/customers/detail.tsx +14 -10
- package/src/pages/admin/customers/index.tsx +5 -0
- package/src/pages/admin/developers/events/detail.tsx +1 -1
- package/src/pages/admin/developers/index.tsx +1 -1
- package/src/pages/admin/payments/intents/detail.tsx +1 -1
- package/src/pages/admin/payments/payouts/detail.tsx +1 -1
- package/src/pages/admin/payments/refunds/detail.tsx +1 -1
- package/src/pages/admin/products/index.tsx +3 -2
- package/src/pages/admin/products/links/detail.tsx +1 -1
- package/src/pages/admin/products/prices/actions.tsx +16 -4
- package/src/pages/admin/products/prices/detail.tsx +30 -3
- package/src/pages/admin/products/prices/list.tsx +8 -1
- package/src/pages/admin/products/pricing-tables/detail.tsx +1 -1
- package/src/pages/admin/products/products/create.tsx +233 -57
- package/src/pages/admin/products/products/detail.tsx +2 -1
- package/src/pages/admin/settings/payment-methods/index.tsx +3 -0
- package/src/pages/customer/credit-grant/detail.tsx +308 -0
- package/src/pages/customer/index.tsx +44 -9
- package/src/pages/customer/recharge/account.tsx +5 -5
- package/src/pages/customer/subscription/change-payment.tsx +4 -2
- package/src/pages/customer/subscription/detail.tsx +48 -14
- package/src/pages/customer/subscription/embed.tsx +1 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* eslint-disable react/no-unstable-nested-components */
|
|
2
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import { formatPrice, Table, usePaymentContext } from '@blocklet/payment-react';
|
|
4
|
+
import type { TLineItemExpanded, TPaymentCurrency, TPriceExpanded } from '@blocklet/payment-types';
|
|
5
|
+
import { Avatar, Stack, Typography, Box } from '@mui/material';
|
|
6
|
+
import { useNavigate } from 'react-router-dom';
|
|
7
|
+
import Copyable from '../copyable';
|
|
8
|
+
|
|
9
|
+
type CreditGrantItemListProps = {
|
|
10
|
+
data: TLineItemExpanded[];
|
|
11
|
+
currency: TPaymentCurrency;
|
|
12
|
+
mode?: 'dashboard' | 'portal';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default function CreditGrantItemList({ data, currency, mode = 'portal' }: CreditGrantItemListProps) {
|
|
16
|
+
const { t } = useLocaleContext();
|
|
17
|
+
const navigate = useNavigate();
|
|
18
|
+
const { session } = usePaymentContext();
|
|
19
|
+
const isAdmin = mode === 'dashboard' && ['owner', 'admin'].includes(session?.user?.role || '');
|
|
20
|
+
|
|
21
|
+
const viewProduct = (price: TPriceExpanded) => {
|
|
22
|
+
if (!isAdmin) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
navigate(`/admin/products/${price.product_id}?price_id=${price.id}¤cy_id=${price.currency_id}`);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const columns = [
|
|
29
|
+
{
|
|
30
|
+
label: t('admin.subscription.product'),
|
|
31
|
+
name: 'product_id',
|
|
32
|
+
options: {
|
|
33
|
+
customBodyRenderLite: (_: string, index: number) => {
|
|
34
|
+
const item = data[index] as TLineItemExpanded;
|
|
35
|
+
return (
|
|
36
|
+
<Stack direction="row" spacing={1} onClick={() => viewProduct(item.price)}>
|
|
37
|
+
<Avatar
|
|
38
|
+
src={item.price?.product?.images?.[0]}
|
|
39
|
+
alt={item.price?.product?.name}
|
|
40
|
+
variant="square"
|
|
41
|
+
sx={{ borderRadius: 1 }}
|
|
42
|
+
/>
|
|
43
|
+
<Stack direction="column" spacing={0.5}>
|
|
44
|
+
<Typography
|
|
45
|
+
variant="body2"
|
|
46
|
+
sx={{
|
|
47
|
+
fontWeight: 500,
|
|
48
|
+
}}>
|
|
49
|
+
{item.price?.product?.name}
|
|
50
|
+
</Typography>
|
|
51
|
+
<Typography
|
|
52
|
+
variant="body2"
|
|
53
|
+
sx={{
|
|
54
|
+
color: 'text.secondary',
|
|
55
|
+
}}>
|
|
56
|
+
{formatPrice(item.price, currency, item.price?.product?.unit_label || '')}
|
|
57
|
+
</Typography>
|
|
58
|
+
</Stack>
|
|
59
|
+
</Stack>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: t('common.id'),
|
|
66
|
+
name: 'id',
|
|
67
|
+
options: {
|
|
68
|
+
customBodyRenderLite: (_: string, index: number) => {
|
|
69
|
+
const item = data[index] as TLineItemExpanded;
|
|
70
|
+
return (
|
|
71
|
+
<Box onClick={() => viewProduct(item.price)}>
|
|
72
|
+
<Copyable text={item.id} />
|
|
73
|
+
</Box>
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
].filter(Boolean);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Table
|
|
82
|
+
data={data}
|
|
83
|
+
columns={columns}
|
|
84
|
+
loading={false}
|
|
85
|
+
footer={false}
|
|
86
|
+
toolbar={false}
|
|
87
|
+
components={{
|
|
88
|
+
TableToolbar: () => null,
|
|
89
|
+
TableFooter: () => null,
|
|
90
|
+
}}
|
|
91
|
+
options={{
|
|
92
|
+
count: data.length,
|
|
93
|
+
page: 0,
|
|
94
|
+
rowsPerPage: 100,
|
|
95
|
+
}}
|
|
96
|
+
emptyNodeText={t('admin.customer.creditGrants.noApplicableProducts')}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { formatBNStr, CreditGrantsList, CreditTransactionsList, api } from '@blocklet/payment-react';
|
|
2
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import { Avatar, Box, Card, CardContent, Stack, Typography, Tabs, Tab } from '@mui/material';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import type { TPaymentCurrency } from '@blocklet/payment-types';
|
|
6
|
+
import { useRequest } from 'ahooks';
|
|
7
|
+
import { useConditionalSection } from '../conditional-section';
|
|
8
|
+
|
|
9
|
+
enum CreditTab {
|
|
10
|
+
OVERVIEW = 'overview',
|
|
11
|
+
GRANTS = 'grants',
|
|
12
|
+
TRANSACTIONS = 'transactions',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface CreditOverviewProps {
|
|
16
|
+
customerId: string;
|
|
17
|
+
settings: any;
|
|
18
|
+
mode?: 'portal' | 'dashboard';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const fetchCreditSummary = async (customerId: string) => {
|
|
22
|
+
try {
|
|
23
|
+
const [grantsResponse, pendingAmountResponse] = await Promise.all([
|
|
24
|
+
api.get(`/api/credit-grants/summary?customer_id=${customerId}`),
|
|
25
|
+
api.get(`/api/meter-events/pending-amount?customer_id=${customerId}`),
|
|
26
|
+
// api.get(`/api/credit-transactions/summary?customer_id=${customerId}`),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
grants: grantsResponse.data,
|
|
31
|
+
// transactions: transactionsResponse.data,
|
|
32
|
+
pendingAmount: pendingAmountResponse.data,
|
|
33
|
+
};
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Failed to fetch credit summary:', error);
|
|
36
|
+
return {
|
|
37
|
+
grants: null,
|
|
38
|
+
transactions: null,
|
|
39
|
+
pendingAmount: null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default function CreditOverview({ customerId, settings, mode = 'portal' }: CreditOverviewProps) {
|
|
45
|
+
const { t } = useLocaleContext();
|
|
46
|
+
const [creditTab, setCreditTab] = useState<CreditTab>(CreditTab.OVERVIEW);
|
|
47
|
+
const conditionalSection = useConditionalSection();
|
|
48
|
+
|
|
49
|
+
const creditCurrencies = useMemo(() => {
|
|
50
|
+
return (
|
|
51
|
+
settings?.paymentMethods
|
|
52
|
+
?.filter((method: any) => method.type === 'arcblock')
|
|
53
|
+
?.flatMap((method: any) => method.payment_currencies)
|
|
54
|
+
?.filter((currency: TPaymentCurrency) => {
|
|
55
|
+
return currency.type === 'credit';
|
|
56
|
+
}) || []
|
|
57
|
+
);
|
|
58
|
+
}, [settings]);
|
|
59
|
+
|
|
60
|
+
const { data: creditSummary } = useRequest(fetchCreditSummary, {
|
|
61
|
+
defaultParams: [customerId],
|
|
62
|
+
refreshDeps: [creditTab === CreditTab.OVERVIEW],
|
|
63
|
+
onSuccess: (data) => {
|
|
64
|
+
if (creditTab === CreditTab.OVERVIEW) {
|
|
65
|
+
const filteredCurrencies = creditCurrencies.filter((currency: TPaymentCurrency) => {
|
|
66
|
+
return data.grants?.[currency.id];
|
|
67
|
+
});
|
|
68
|
+
conditionalSection?.hideRender(filteredCurrencies.length === 0);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// 渲染信用概览卡片
|
|
74
|
+
const renderCreditOverviewCard = (currency: any) => {
|
|
75
|
+
const method = settings?.paymentMethods?.find((m: any) => m.id === currency.payment_method_id);
|
|
76
|
+
if (method?.type !== 'arcblock') {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const currencyId = currency.id as string;
|
|
81
|
+
const grantData = creditSummary?.grants?.[currencyId];
|
|
82
|
+
const pendingAmount = creditSummary?.pendingAmount?.[currencyId] || '0';
|
|
83
|
+
|
|
84
|
+
if (!grantData) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const totalAmount = grantData.totalAmount || '0';
|
|
89
|
+
const remainingAmount = grantData.remainingAmount || '0';
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Card
|
|
93
|
+
key={currency.id}
|
|
94
|
+
sx={{
|
|
95
|
+
height: '100%',
|
|
96
|
+
display: 'flex',
|
|
97
|
+
flexDirection: 'column',
|
|
98
|
+
border: '1px solid',
|
|
99
|
+
borderColor: 'divider',
|
|
100
|
+
boxShadow: 1,
|
|
101
|
+
borderRadius: 1,
|
|
102
|
+
}}>
|
|
103
|
+
<CardContent sx={{ flexGrow: 1 }}>
|
|
104
|
+
<Stack spacing={2}>
|
|
105
|
+
{/* 货币信息 */}
|
|
106
|
+
<Stack
|
|
107
|
+
direction="row"
|
|
108
|
+
spacing={1}
|
|
109
|
+
sx={{
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
}}>
|
|
112
|
+
<Avatar src={currency.logo} alt={currency.symbol} sx={{ width: 24, height: 24 }} />
|
|
113
|
+
<Typography variant="h6" component="div">
|
|
114
|
+
{currency.name}
|
|
115
|
+
</Typography>
|
|
116
|
+
</Stack>
|
|
117
|
+
|
|
118
|
+
{/* 可用额度 / 总额度 */}
|
|
119
|
+
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
120
|
+
<Typography
|
|
121
|
+
variant="body2"
|
|
122
|
+
gutterBottom
|
|
123
|
+
sx={{
|
|
124
|
+
color: 'text.secondary',
|
|
125
|
+
}}>
|
|
126
|
+
{t('admin.customer.creditGrants.creditBalance')}
|
|
127
|
+
</Typography>
|
|
128
|
+
<Typography variant="h5" component="div" sx={{ fontWeight: 'normal' }}>
|
|
129
|
+
{totalAmount === '0' && remainingAmount === '0' ? (
|
|
130
|
+
<>0 {currency.symbol}</>
|
|
131
|
+
) : (
|
|
132
|
+
<>
|
|
133
|
+
{formatBNStr(remainingAmount, currency.decimal, 6, true)} /{' '}
|
|
134
|
+
{formatBNStr(totalAmount, currency.decimal, 6, true)} {currency.symbol}
|
|
135
|
+
</>
|
|
136
|
+
)}
|
|
137
|
+
</Typography>
|
|
138
|
+
</Box>
|
|
139
|
+
|
|
140
|
+
{/* 欠费额度 */}
|
|
141
|
+
{pendingAmount !== '0' && (
|
|
142
|
+
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
143
|
+
<Typography
|
|
144
|
+
variant="body2"
|
|
145
|
+
gutterBottom
|
|
146
|
+
sx={{
|
|
147
|
+
color: 'text.secondary',
|
|
148
|
+
}}>
|
|
149
|
+
{t('admin.customer.creditGrants.pendingAmount')}
|
|
150
|
+
</Typography>
|
|
151
|
+
<Typography
|
|
152
|
+
variant="body1"
|
|
153
|
+
sx={{
|
|
154
|
+
color: 'error.main',
|
|
155
|
+
}}>
|
|
156
|
+
{formatBNStr(pendingAmount, currency.decimal, 6, true)} {currency.symbol}
|
|
157
|
+
</Typography>
|
|
158
|
+
</Box>
|
|
159
|
+
)}
|
|
160
|
+
</Stack>
|
|
161
|
+
</CardContent>
|
|
162
|
+
</Card>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const filteredCreditCurrencies = useMemo(() => {
|
|
167
|
+
return creditCurrencies.filter((currency: TPaymentCurrency) => {
|
|
168
|
+
return creditSummary?.grants?.[currency.id];
|
|
169
|
+
});
|
|
170
|
+
}, [creditCurrencies, creditSummary?.grants]);
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<Stack sx={{ width: '100%' }}>
|
|
174
|
+
<Tabs
|
|
175
|
+
value={creditTab}
|
|
176
|
+
onChange={(_, newValue) => setCreditTab(newValue as CreditTab)}
|
|
177
|
+
// sx={{ borderBottom: 1, borderColor: 'divider', }}
|
|
178
|
+
sx={{
|
|
179
|
+
flex: '1 0 auto',
|
|
180
|
+
maxWidth: '100%',
|
|
181
|
+
fontSize: 14,
|
|
182
|
+
borderBottom: 1,
|
|
183
|
+
borderColor: 'divider',
|
|
184
|
+
'.Mui-selected': {
|
|
185
|
+
fontSize: '14px !important',
|
|
186
|
+
color: 'primary.main',
|
|
187
|
+
},
|
|
188
|
+
}}>
|
|
189
|
+
<Tab label={t('admin.creditGrants.overview')} value={CreditTab.OVERVIEW} />
|
|
190
|
+
<Tab label={t('admin.creditGrants.title')} value={CreditTab.GRANTS} />
|
|
191
|
+
<Tab label={t('admin.creditTransactions.title')} value={CreditTab.TRANSACTIONS} />
|
|
192
|
+
</Tabs>
|
|
193
|
+
{/* 概览标签页 */}
|
|
194
|
+
{creditTab === CreditTab.OVERVIEW && (
|
|
195
|
+
<Box sx={{ width: '100%', mt: 1 }} key={creditTab}>
|
|
196
|
+
<Box
|
|
197
|
+
sx={{
|
|
198
|
+
display: 'grid',
|
|
199
|
+
gridTemplateColumns: {
|
|
200
|
+
xs: 'repeat(1, 1fr)',
|
|
201
|
+
md: 'repeat(2, 1fr)',
|
|
202
|
+
},
|
|
203
|
+
gap: 2,
|
|
204
|
+
'@container (max-width: 600px)': {
|
|
205
|
+
gridTemplateColumns: 'repeat(1, 1fr)',
|
|
206
|
+
},
|
|
207
|
+
}}>
|
|
208
|
+
{filteredCreditCurrencies.map(renderCreditOverviewCard)}
|
|
209
|
+
</Box>
|
|
210
|
+
|
|
211
|
+
{filteredCreditCurrencies.length === 0 && (
|
|
212
|
+
<Box
|
|
213
|
+
sx={{
|
|
214
|
+
display: 'flex',
|
|
215
|
+
flexDirection: 'column',
|
|
216
|
+
alignItems: 'center',
|
|
217
|
+
justifyContent: 'center',
|
|
218
|
+
py: 8,
|
|
219
|
+
textAlign: 'center',
|
|
220
|
+
}}>
|
|
221
|
+
<Typography
|
|
222
|
+
variant="h6"
|
|
223
|
+
gutterBottom
|
|
224
|
+
sx={{
|
|
225
|
+
color: 'text.secondary',
|
|
226
|
+
}}>
|
|
227
|
+
{t('admin.customer.creditGrants.noGrants')}
|
|
228
|
+
</Typography>
|
|
229
|
+
<Typography
|
|
230
|
+
variant="body2"
|
|
231
|
+
sx={{
|
|
232
|
+
color: 'text.secondary',
|
|
233
|
+
}}>
|
|
234
|
+
{t('admin.customer.creditGrants.noGrantsDescription')}
|
|
235
|
+
</Typography>
|
|
236
|
+
</Box>
|
|
237
|
+
)}
|
|
238
|
+
</Box>
|
|
239
|
+
)}
|
|
240
|
+
{creditTab === CreditTab.GRANTS && <CreditGrantsList customer_id={customerId} mode={mode} key={creditTab} />}
|
|
241
|
+
{creditTab === CreditTab.TRANSACTIONS && (
|
|
242
|
+
<CreditTransactionsList customer_id={customerId} mode={mode} key={creditTab} />
|
|
243
|
+
)}
|
|
244
|
+
</Stack>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
validatePhoneNumber,
|
|
9
9
|
getPhoneUtil,
|
|
10
10
|
validatePostalCode,
|
|
11
|
+
FormLabel,
|
|
11
12
|
} from '@blocklet/payment-react';
|
|
12
|
-
import {
|
|
13
|
+
import { Stack } from '@mui/material';
|
|
13
14
|
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
|
14
15
|
import isEmail from 'validator/es/lib/isEmail';
|
|
15
16
|
import { useMount } from 'ahooks';
|
|
@@ -81,13 +82,16 @@ export default function CustomerForm() {
|
|
|
81
82
|
},
|
|
82
83
|
}}
|
|
83
84
|
/>
|
|
84
|
-
|
|
85
85
|
<FormLabel className="base-label">{t('payment.checkout.billing.required')}</FormLabel>
|
|
86
86
|
<Controller
|
|
87
87
|
name="address.country"
|
|
88
88
|
control={control}
|
|
89
89
|
render={({ field }) => (
|
|
90
|
-
<CountrySelect
|
|
90
|
+
<CountrySelect
|
|
91
|
+
{...field}
|
|
92
|
+
ref={field.ref as unknown as React.RefObject<HTMLDivElement | null>}
|
|
93
|
+
sx={{ pl: '6px' }}
|
|
94
|
+
/>
|
|
91
95
|
)}
|
|
92
96
|
/>
|
|
93
97
|
<FormInput
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getTxLink,
|
|
13
13
|
} from '@blocklet/payment-react';
|
|
14
14
|
import type { TInvoiceExpanded } from '@blocklet/payment-types';
|
|
15
|
-
import { CircularProgress, Typography } from '@mui/material';
|
|
15
|
+
import { Avatar, CircularProgress, Typography } from '@mui/material';
|
|
16
16
|
import { useLocalStorageState } from 'ahooks';
|
|
17
17
|
import { useEffect, useState } from 'react';
|
|
18
18
|
import { Link } from 'react-router-dom';
|
|
@@ -176,6 +176,24 @@ export default function InvoiceList({
|
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
},
|
|
179
|
+
{
|
|
180
|
+
label: t('common.paymentMethod'),
|
|
181
|
+
name: 'paymentMethod',
|
|
182
|
+
width: 120,
|
|
183
|
+
options: {
|
|
184
|
+
customBodyRenderLite: (_: string, index: number) => {
|
|
185
|
+
const invoice = data?.list[index] as TInvoiceExpanded;
|
|
186
|
+
return (
|
|
187
|
+
<InvoiceLink invoice={invoice}>
|
|
188
|
+
<Typography sx={{ display: 'flex', alignItems: 'center', whiteSpace: 'nowrap' }}>
|
|
189
|
+
<Avatar src={invoice.paymentMethod.logo} sx={{ width: 18, height: 18, mr: 1 }} />
|
|
190
|
+
{invoice.paymentMethod.name}
|
|
191
|
+
</Typography>
|
|
192
|
+
</InvoiceLink>
|
|
193
|
+
);
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
179
197
|
{
|
|
180
198
|
label: t('common.status'),
|
|
181
199
|
name: 'status',
|