payment-kit 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.
Files changed (214) hide show
  1. package/.eslintrc.js +6 -0
  2. package/api/src/crons/index.ts +8 -0
  3. package/api/src/index.ts +4 -0
  4. package/api/src/libs/credit-grant.ts +146 -0
  5. package/api/src/libs/env.ts +1 -0
  6. package/api/src/libs/invoice.ts +4 -3
  7. package/api/src/libs/notification/template/base.ts +388 -2
  8. package/api/src/libs/notification/template/customer-credit-grant-granted.ts +149 -0
  9. package/api/src/libs/notification/template/customer-credit-grant-low-balance.ts +151 -0
  10. package/api/src/libs/notification/template/customer-credit-insufficient.ts +254 -0
  11. package/api/src/libs/notification/template/subscription-canceled.ts +193 -202
  12. package/api/src/libs/notification/template/subscription-refund-succeeded.ts +215 -237
  13. package/api/src/libs/notification/template/subscription-renewed.ts +130 -200
  14. package/api/src/libs/notification/template/subscription-succeeded.ts +100 -202
  15. package/api/src/libs/notification/template/subscription-trial-start.ts +142 -188
  16. package/api/src/libs/notification/template/subscription-trial-will-end.ts +146 -174
  17. package/api/src/libs/notification/template/subscription-upgraded.ts +96 -192
  18. package/api/src/libs/notification/template/subscription-will-canceled.ts +94 -135
  19. package/api/src/libs/notification/template/subscription-will-renew.ts +220 -245
  20. package/api/src/libs/payment.ts +69 -0
  21. package/api/src/libs/queue/index.ts +3 -2
  22. package/api/src/libs/session.ts +8 -0
  23. package/api/src/libs/subscription.ts +74 -3
  24. package/api/src/libs/ws.ts +23 -1
  25. package/api/src/locales/en.ts +33 -0
  26. package/api/src/locales/zh.ts +31 -0
  27. package/api/src/queues/credit-consume.ts +715 -0
  28. package/api/src/queues/credit-grant.ts +572 -0
  29. package/api/src/queues/notification.ts +173 -128
  30. package/api/src/queues/payment.ts +210 -122
  31. package/api/src/queues/subscription.ts +179 -0
  32. package/api/src/routes/checkout-sessions.ts +157 -9
  33. package/api/src/routes/connect/shared.ts +3 -2
  34. package/api/src/routes/credit-grants.ts +241 -0
  35. package/api/src/routes/credit-transactions.ts +208 -0
  36. package/api/src/routes/index.ts +8 -0
  37. package/api/src/routes/meter-events.ts +347 -0
  38. package/api/src/routes/meters.ts +219 -0
  39. package/api/src/routes/payment-currencies.ts +14 -2
  40. package/api/src/routes/payment-links.ts +1 -1
  41. package/api/src/routes/payment-methods.ts +14 -2
  42. package/api/src/routes/prices.ts +43 -0
  43. package/api/src/routes/pricing-table.ts +13 -7
  44. package/api/src/routes/products.ts +63 -4
  45. package/api/src/routes/settings.ts +1 -1
  46. package/api/src/routes/subscriptions.ts +4 -0
  47. package/api/src/store/migrations/20250610-billing-credit.ts +43 -0
  48. package/api/src/store/models/credit-grant.ts +486 -0
  49. package/api/src/store/models/credit-transaction.ts +268 -0
  50. package/api/src/store/models/customer.ts +8 -0
  51. package/api/src/store/models/index.ts +52 -1
  52. package/api/src/store/models/meter-event.ts +423 -0
  53. package/api/src/store/models/meter.ts +176 -0
  54. package/api/src/store/models/payment-currency.ts +66 -14
  55. package/api/src/store/models/price.ts +6 -0
  56. package/api/src/store/models/product.ts +2 -2
  57. package/api/src/store/models/subscription.ts +24 -0
  58. package/api/src/store/models/types.ts +28 -2
  59. package/api/tests/libs/subscription.spec.ts +53 -0
  60. package/blocklet.yml +9 -1
  61. package/package.json +57 -58
  62. package/scripts/sdk.js +233 -1
  63. package/src/app.tsx +10 -0
  64. package/src/components/actions.tsx +22 -9
  65. package/src/components/balance-list.tsx +40 -12
  66. package/src/components/collapse.tsx +33 -15
  67. package/src/components/copyable.tsx +8 -7
  68. package/src/components/currency.tsx +15 -7
  69. package/src/components/customer/actions.tsx +1 -5
  70. package/src/components/customer/credit-grant-item-list.tsx +99 -0
  71. package/src/components/customer/credit-overview.tsx +233 -0
  72. package/src/components/customer/form.tsx +7 -2
  73. package/src/components/customer/link.tsx +4 -12
  74. package/src/components/customer/notification-preference.tsx +18 -9
  75. package/src/components/customer/overdraft-protection.tsx +112 -41
  76. package/src/components/drawer-form.tsx +42 -18
  77. package/src/components/error.tsx +1 -5
  78. package/src/components/event/list.tsx +9 -10
  79. package/src/components/filter-toolbar.tsx +20 -19
  80. package/src/components/info-card.tsx +32 -18
  81. package/src/components/info-metric.tsx +16 -6
  82. package/src/components/info-row-group.tsx +1 -7
  83. package/src/components/info-row.tsx +30 -24
  84. package/src/components/invoice/action.tsx +1 -7
  85. package/src/components/invoice/list.tsx +34 -26
  86. package/src/components/invoice/recharge.tsx +5 -7
  87. package/src/components/invoice/table.tsx +17 -12
  88. package/src/components/layout/user.tsx +1 -1
  89. package/src/components/metadata/form.tsx +290 -94
  90. package/src/components/metadata/list.tsx +11 -3
  91. package/src/components/meter/actions.tsx +101 -0
  92. package/src/components/meter/add-usage-dialog.tsx +239 -0
  93. package/src/components/meter/events-list.tsx +657 -0
  94. package/src/components/meter/form.tsx +245 -0
  95. package/src/components/meter/products.tsx +264 -0
  96. package/src/components/meter/usage-guide.tsx +174 -0
  97. package/src/components/passport/actions.tsx +9 -4
  98. package/src/components/payment-currency/add.tsx +16 -3
  99. package/src/components/payment-currency/form.tsx +14 -6
  100. package/src/components/payment-intent/actions.tsx +24 -16
  101. package/src/components/payment-intent/list.tsx +30 -9
  102. package/src/components/payment-link/actions.tsx +1 -5
  103. package/src/components/payment-link/after-pay.tsx +4 -2
  104. package/src/components/payment-link/before-pay.tsx +14 -4
  105. package/src/components/payment-link/item.tsx +27 -6
  106. package/src/components/payment-link/preview.tsx +9 -9
  107. package/src/components/payment-link/product-select.tsx +69 -15
  108. package/src/components/payment-method/arcblock.tsx +8 -1
  109. package/src/components/payment-method/base.tsx +8 -1
  110. package/src/components/payment-method/bitcoin.tsx +8 -1
  111. package/src/components/payment-method/ethereum.tsx +8 -1
  112. package/src/components/payment-method/evm-rpc-input.tsx +11 -7
  113. package/src/components/payment-method/form.tsx +2 -7
  114. package/src/components/payment-method/stripe.tsx +2 -0
  115. package/src/components/payouts/actions.tsx +1 -5
  116. package/src/components/payouts/list.tsx +30 -10
  117. package/src/components/payouts/portal/list.tsx +11 -9
  118. package/src/components/price/currency-select.tsx +63 -32
  119. package/src/components/price/form.tsx +895 -370
  120. package/src/components/price/upsell-select.tsx +10 -2
  121. package/src/components/price/upsell.tsx +7 -2
  122. package/src/components/pricing-table/actions.tsx +1 -5
  123. package/src/components/pricing-table/customer-settings.tsx +5 -1
  124. package/src/components/pricing-table/payment-settings.tsx +14 -4
  125. package/src/components/pricing-table/preview.tsx +9 -9
  126. package/src/components/pricing-table/price-item.tsx +6 -1
  127. package/src/components/pricing-table/product-item.tsx +6 -1
  128. package/src/components/pricing-table/product-settings.tsx +17 -4
  129. package/src/components/product/actions.tsx +1 -5
  130. package/src/components/product/add-price.tsx +9 -7
  131. package/src/components/product/create.tsx +8 -9
  132. package/src/components/product/cross-sell-select.tsx +5 -1
  133. package/src/components/product/cross-sell.tsx +7 -2
  134. package/src/components/product/edit-price.tsx +21 -12
  135. package/src/components/product/features.tsx +26 -6
  136. package/src/components/product/form.tsx +115 -72
  137. package/src/components/progress-bar.tsx +1 -1
  138. package/src/components/refund/actions.tsx +1 -7
  139. package/src/components/refund/list.tsx +31 -18
  140. package/src/components/section/header.tsx +12 -14
  141. package/src/components/subscription/actions/cancel.tsx +22 -5
  142. package/src/components/subscription/actions/index.tsx +9 -10
  143. package/src/components/subscription/actions/pause.tsx +32 -6
  144. package/src/components/subscription/actions/slash-stake.tsx +5 -3
  145. package/src/components/subscription/description.tsx +12 -8
  146. package/src/components/subscription/items/index.tsx +31 -16
  147. package/src/components/subscription/items/usage-records.tsx +19 -5
  148. package/src/components/subscription/list.tsx +5 -7
  149. package/src/components/subscription/metrics.tsx +62 -15
  150. package/src/components/subscription/portal/actions.tsx +78 -71
  151. package/src/components/subscription/portal/cancel.tsx +10 -3
  152. package/src/components/subscription/portal/list.tsx +48 -26
  153. package/src/components/uploader.tsx +5 -13
  154. package/src/components/webhook/attempts.tsx +51 -16
  155. package/src/components/webhook/request-info.tsx +8 -6
  156. package/src/contexts/products.tsx +27 -10
  157. package/src/hooks/subscription.ts +34 -0
  158. package/src/libs/meter-utils.ts +196 -0
  159. package/src/libs/util.ts +4 -0
  160. package/src/locales/en.tsx +385 -4
  161. package/src/locales/zh.tsx +364 -0
  162. package/src/pages/admin/billing/index.tsx +61 -33
  163. package/src/pages/admin/billing/invoices/detail.tsx +49 -13
  164. package/src/pages/admin/billing/meters/create.tsx +60 -0
  165. package/src/pages/admin/billing/meters/detail.tsx +435 -0
  166. package/src/pages/admin/billing/meters/index.tsx +210 -0
  167. package/src/pages/admin/billing/meters/meter-event.tsx +346 -0
  168. package/src/pages/admin/billing/subscriptions/detail.tsx +90 -25
  169. package/src/pages/admin/customers/customers/credit-grant/detail.tsx +391 -0
  170. package/src/pages/admin/customers/customers/detail.tsx +67 -14
  171. package/src/pages/admin/customers/customers/index.tsx +6 -1
  172. package/src/pages/admin/customers/index.tsx +5 -0
  173. package/src/pages/admin/developers/events/detail.tsx +37 -11
  174. package/src/pages/admin/developers/index.tsx +1 -1
  175. package/src/pages/admin/developers/webhooks/detail.tsx +41 -11
  176. package/src/pages/admin/index.tsx +15 -2
  177. package/src/pages/admin/overview.tsx +107 -19
  178. package/src/pages/admin/payments/intents/detail.tsx +58 -14
  179. package/src/pages/admin/payments/payouts/detail.tsx +63 -15
  180. package/src/pages/admin/payments/refunds/detail.tsx +58 -14
  181. package/src/pages/admin/products/index.tsx +11 -4
  182. package/src/pages/admin/products/links/create.tsx +22 -4
  183. package/src/pages/admin/products/links/detail.tsx +43 -14
  184. package/src/pages/admin/products/passports/index.tsx +23 -4
  185. package/src/pages/admin/products/prices/actions.tsx +16 -9
  186. package/src/pages/admin/products/prices/detail.tsx +73 -14
  187. package/src/pages/admin/products/prices/list.tsx +15 -3
  188. package/src/pages/admin/products/pricing-tables/create.tsx +45 -12
  189. package/src/pages/admin/products/pricing-tables/detail.tsx +45 -14
  190. package/src/pages/admin/products/products/create.tsx +233 -54
  191. package/src/pages/admin/products/products/detail.tsx +74 -18
  192. package/src/pages/admin/settings/index.tsx +8 -1
  193. package/src/pages/admin/settings/payment-methods/index.tsx +87 -19
  194. package/src/pages/admin/settings/vault-config/edit-form.tsx +42 -28
  195. package/src/pages/admin/settings/vault-config/index.tsx +57 -10
  196. package/src/pages/customer/credit-grant/detail.tsx +308 -0
  197. package/src/pages/customer/index.tsx +76 -17
  198. package/src/pages/customer/invoice/detail.tsx +63 -14
  199. package/src/pages/customer/invoice/past-due.tsx +11 -3
  200. package/src/pages/customer/payout/detail.tsx +56 -13
  201. package/src/pages/customer/recharge/account.tsx +78 -18
  202. package/src/pages/customer/recharge/subscription.tsx +86 -25
  203. package/src/pages/customer/refund/list.tsx +60 -24
  204. package/src/pages/customer/subscription/change-payment.tsx +17 -6
  205. package/src/pages/customer/subscription/change-plan.tsx +34 -7
  206. package/src/pages/customer/subscription/detail.tsx +134 -34
  207. package/src/pages/customer/subscription/embed.tsx +25 -5
  208. package/src/pages/home.tsx +26 -4
  209. package/src/pages/integrations/donations/edit-form.tsx +25 -9
  210. package/src/pages/integrations/donations/index.tsx +26 -9
  211. package/src/pages/integrations/donations/preview.tsx +59 -15
  212. package/src/pages/integrations/index.tsx +10 -1
  213. package/src/pages/integrations/overview.tsx +78 -17
  214. package/vite.config.ts +60 -30
@@ -2,8 +2,8 @@
2
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
3
  import { FormInput } from '@blocklet/payment-react';
4
4
  import type { InferFormType, TProduct } from '@blocklet/payment-types';
5
- import { Box, Stack, Typography } from '@mui/material';
6
- import { useFormContext, useWatch } from 'react-hook-form';
5
+ import { Box, Stack, Typography, FormLabel, Select, MenuItem } from '@mui/material';
6
+ import { useFormContext, useWatch, Controller } from 'react-hook-form';
7
7
 
8
8
  import Collapse from '../collapse';
9
9
  import MetadataForm from '../metadata/form';
@@ -19,10 +19,11 @@ type Props = {
19
19
  simple?: boolean;
20
20
  };
21
21
 
22
- export default function ProductForm(props: Props) {
22
+ export default function ProductForm({ simple = false }: Props) {
23
23
  const { t } = useLocaleContext();
24
24
  const { control, setValue, formState } = useFormContext();
25
25
  const images = useWatch({ control, name: 'images' });
26
+ const productType = useWatch({ control, name: 'type' }) ?? '';
26
27
 
27
28
  const onUploaded = (result: any) => {
28
29
  if (result.url) {
@@ -34,77 +35,119 @@ export default function ProductForm(props: Props) {
34
35
  };
35
36
 
36
37
  return (
37
- <Stack spacing={2} mb={3} direction="row" alignItems="flex-start">
38
- <Stack spacing={2} flex={2} alignItems="flex-start">
39
- <FormInput
40
- name="name"
41
- rules={{
42
- required: t('admin.product.name.required'),
43
- maxLength: {
44
- value: 64,
45
- message: t('common.maxLength', { len: 64 }),
46
- },
47
- }}
48
- label={t('admin.product.name.label')}
49
- placeholder={t('admin.product.name.placeholder')}
50
- error={!!formState.errors.name}
51
- helperText={formState.errors.name?.message as string}
52
- autoFocus
53
- inputProps={{ maxLength: 64 }}
54
- />
55
- <FormInput
56
- name="description"
57
- rules={{
58
- required: t('admin.product.description.required'),
59
- maxLength: {
60
- value: 250,
61
- message: t('common.maxLength', { len: 250 }),
62
- },
63
- }}
64
- label={t('admin.product.description.label')}
65
- placeholder={t('admin.product.description.placeholder')}
66
- error={!!formState.errors.description}
67
- helperText={formState.errors.description?.message as string}
68
- multiline
69
- minRows={2}
70
- maxRows={4}
71
- inputProps={{ maxLength: 250 }}
72
- />
73
- <Collapse trigger={t('admin.product.additional')}>
74
- <Stack spacing={2} alignItems="flex-start">
75
- <FormInput
76
- name="statement_descriptor"
77
- label={t('admin.product.statement_descriptor.label')}
78
- rules={{
79
- maxLength: { value: 22, message: t('common.maxLength', { len: 22 }) },
80
- pattern: {
81
- value: /^(?=.*[A-Za-z])[^\u4e00-\u9fa5<>"’\\]*$/,
82
- message: t('common.latinOnly'),
83
- },
84
- }}
85
- />
86
- <FormInput
87
- name="unit_label"
88
- label={t('admin.product.unit_label.label')}
89
- rules={{
90
- maxLength: { value: 12, message: t('common.maxLength', { len: 12 }) },
91
- }}
92
- />
93
- {!props.simple && <ProductFeatures />}
94
- {!props.simple && <MetadataForm title={t('common.metadata.label')} />}
95
- </Stack>
96
- </Collapse>
97
- </Stack>
98
- <Box flex={1}>
99
- <Stack direction="column">
100
- <Typography mb={1}>{t('admin.product.image.label')}</Typography>
38
+ <Stack
39
+ spacing={3}
40
+ sx={{
41
+ mb: 3,
42
+ }}>
43
+ <Controller
44
+ name="type"
45
+ control={control}
46
+ rules={{ required: true }}
47
+ render={({ field }) => (
48
+ <Box sx={{ width: '100%' }}>
49
+ <FormLabel sx={{ color: 'text.primary' }}>{t('admin.product.type.label')}</FormLabel>
50
+ <Select {...field} fullWidth size="small">
51
+ <MenuItem value="good">{t('admin.product.type.good')}</MenuItem>
52
+ <MenuItem value="service">{t('admin.product.type.service')}</MenuItem>
53
+ <MenuItem value="credit">{t('admin.product.type.credit')}</MenuItem>
54
+ </Select>
55
+ </Box>
56
+ )}
57
+ />
58
+ <Stack
59
+ direction="row"
60
+ sx={{
61
+ alignItems: 'flex-start',
62
+ flex: 1,
63
+ gap: 2,
64
+ }}>
65
+ <Stack sx={{ flex: 1, gap: 2 }}>
66
+ <FormInput
67
+ name="name"
68
+ rules={{
69
+ required: t('admin.product.name.required'),
70
+ maxLength: {
71
+ value: 64,
72
+ message: t('common.maxLength', { len: 64 }),
73
+ },
74
+ }}
75
+ label={t('admin.product.name.label')}
76
+ required
77
+ placeholder={
78
+ productType === 'credit' ? t('admin.creditProduct.name.placeholder') : t('admin.product.name.placeholder')
79
+ }
80
+ error={!!formState.errors.name}
81
+ helperText={formState.errors.name?.message as string}
82
+ autoFocus
83
+ inputProps={{ maxLength: 64 }}
84
+ />
85
+
86
+ <FormInput
87
+ name="description"
88
+ rules={{
89
+ required: t('admin.product.description.required'),
90
+ maxLength: {
91
+ value: 250,
92
+ message: t('common.maxLength', { len: 250 }),
93
+ },
94
+ }}
95
+ label={t('admin.product.description.label')}
96
+ placeholder={
97
+ productType === 'credit'
98
+ ? t('admin.creditProduct.description.placeholder')
99
+ : t('admin.product.description.placeholder')
100
+ }
101
+ error={!!formState.errors.description}
102
+ helperText={formState.errors.description?.message as string}
103
+ multiline
104
+ required
105
+ minRows={2}
106
+ maxRows={4}
107
+ inputProps={{ maxLength: 250 }}
108
+ />
109
+ </Stack>
110
+
111
+ <Box sx={{ width: '100%', maxWidth: 160 }}>
112
+ <Typography variant="body2" sx={{ mb: 1, fontWeight: 500 }}>
113
+ {t('admin.product.image.label')}
114
+ </Typography>
101
115
  <Uploader onUploaded={onUploaded} preview={images[0]} />
116
+ </Box>
117
+ </Stack>
118
+ <Collapse trigger={t('admin.product.additional')}>
119
+ <Stack
120
+ spacing={2}
121
+ sx={{
122
+ alignItems: 'flex-start',
123
+ }}>
124
+ <FormInput
125
+ name="statement_descriptor"
126
+ label={t('admin.product.statement_descriptor.label')}
127
+ rules={{
128
+ maxLength: { value: 22, message: t('common.maxLength', { len: 22 }) },
129
+ pattern: {
130
+ value: /^(?=.*[A-Za-z])[^\u4e00-\u9fa5<>"'\\]*$/,
131
+ message: t('common.latinOnly'),
132
+ },
133
+ }}
134
+ />
135
+ <FormInput
136
+ name="unit_label"
137
+ label={t('admin.product.unit_label.label')}
138
+ placeholder={
139
+ productType === 'credit'
140
+ ? t('admin.creditProduct.unitLabel.placeholder')
141
+ : t('admin.product.unit_label.placeholder')
142
+ }
143
+ rules={{
144
+ maxLength: { value: 12, message: t('common.maxLength', { len: 12 }) },
145
+ }}
146
+ />
147
+ {!simple && <ProductFeatures />}
148
+ {!simple && <MetadataForm title={t('common.metadata.label')} color="inherit" />}
102
149
  </Stack>
103
- </Box>
150
+ </Collapse>
104
151
  </Stack>
105
152
  );
106
153
  }
107
-
108
- ProductForm.defaultProps = {
109
- simple: false,
110
- };
@@ -3,7 +3,7 @@ import LinearProgress from '@mui/material/LinearProgress';
3
3
  import * as React from 'react';
4
4
 
5
5
  type Props = {
6
- pending: boolean;
6
+ pending?: boolean;
7
7
  };
8
8
 
9
9
  export default function ProgressBar({ pending = true }: Props) {
@@ -15,13 +15,7 @@ type Props = {
15
15
  variant?: LiteralUnion<'compact' | 'normal', string>;
16
16
  };
17
17
 
18
- RefundActions.defaultProps = {
19
- variant: 'compact',
20
- // eslint-disable-next-line @typescript-eslint/no-empty-function
21
- onChange: () => {},
22
- };
23
-
24
- export default function RefundActions({ data, variant, onChange }: Props) {
18
+ export default function RefundActions({ data, variant = 'compact', onChange = () => {} }: Props) {
25
19
  const { t } = useLocaleContext();
26
20
  const navigate = useNavigate();
27
21
  const [state, setState] = useSetState({
@@ -10,7 +10,7 @@ import {
10
10
  useDefaultPageSize,
11
11
  } from '@blocklet/payment-react';
12
12
  import type { TRefundExpanded } from '@blocklet/payment-types';
13
- import { CircularProgress, Typography } from '@mui/material';
13
+ import { Avatar, CircularProgress, Typography } from '@mui/material';
14
14
  import { useLocalStorageState } from 'ahooks';
15
15
  import { useEffect, useState } from 'react';
16
16
  import { Link } from 'react-router-dom';
@@ -78,25 +78,16 @@ const getListKey = (props: ListProps) => {
78
78
  return 'refunds';
79
79
  };
80
80
 
81
- RefundList.defaultProps = {
82
- features: {
81
+ export default function RefundList({
82
+ customer_id = '',
83
+ invoice_id = '',
84
+ subscription_id = '',
85
+ status = '',
86
+ features = {
83
87
  customer: true,
84
88
  filter: true,
85
89
  },
86
- customer_id: '',
87
- invoice_id: '',
88
- status: '',
89
- subscription_id: '',
90
- payment_intent_id: '',
91
- };
92
-
93
- export default function RefundList({
94
- customer_id,
95
- invoice_id,
96
- subscription_id,
97
- status,
98
- features,
99
- payment_intent_id,
90
+ payment_intent_id = '',
100
91
  }: ListProps) {
101
92
  const { t } = useLocaleContext();
102
93
  const listKey = getListKey({ customer_id, invoice_id, subscription_id, payment_intent_id });
@@ -139,7 +130,11 @@ export default function RefundList({
139
130
  const item = data.list[index] as TRefundExpanded;
140
131
  return (
141
132
  <Link to={`/admin/payments/${item.id}`}>
142
- <Typography component="strong" fontWeight={600}>
133
+ <Typography
134
+ component="strong"
135
+ sx={{
136
+ fontWeight: 600,
137
+ }}>
143
138
  {formatBNStr(item?.amount, item?.paymentCurrency.decimal)}&nbsp;
144
139
  {item?.paymentCurrency.symbol}
145
140
  </Typography>
@@ -148,6 +143,24 @@ export default function RefundList({
148
143
  },
149
144
  },
150
145
  },
146
+ {
147
+ label: t('common.paymentMethod'),
148
+ name: 'paymentMethod',
149
+ width: 120,
150
+ options: {
151
+ customBodyRenderLite: (_: string, index: number) => {
152
+ const item = data.list[index] as TRefundExpanded;
153
+ return (
154
+ <Link to={`/admin/payments/${item.id}`}>
155
+ <Typography sx={{ display: 'flex', alignItems: 'center', whiteSpace: 'nowrap' }}>
156
+ <Avatar src={item.paymentMethod.logo} sx={{ width: 18, height: 18, mr: 1 }} />
157
+ {item.paymentMethod.name}
158
+ </Typography>
159
+ </Link>
160
+ );
161
+ },
162
+ },
163
+ },
151
164
  {
152
165
  label: t('common.status'),
153
166
  name: 'status',
@@ -8,16 +8,20 @@ type Props = {
8
8
  mt?: number;
9
9
  };
10
10
 
11
- export default function SectionHeader(props: Props) {
11
+ export default function SectionHeader({ title, children = null, mb = 1.5, mt = 1.5 }: Props) {
12
12
  return (
13
13
  <Stack
14
14
  className="section-header"
15
15
  direction="row"
16
- justifyContent="space-between"
17
- alignItems="center"
18
- flexWrap="wrap"
19
- gap={1}
20
- sx={{ mb: props.mb, mt: props.mt, pb: 1 }}>
16
+ sx={{
17
+ justifyContent: 'space-between',
18
+ alignItems: 'center',
19
+ flexWrap: 'wrap',
20
+ gap: 1,
21
+ mb,
22
+ mt,
23
+ pb: 1,
24
+ }}>
21
25
  <Typography
22
26
  variant="h3"
23
27
  sx={{
@@ -27,15 +31,9 @@ export default function SectionHeader(props: Props) {
27
31
  },
28
32
  }}
29
33
  component="div">
30
- {props.title}
34
+ {title}
31
35
  </Typography>
32
- {props.children}
36
+ {children}
33
37
  </Stack>
34
38
  );
35
39
  }
36
-
37
- SectionHeader.defaultProps = {
38
- children: null,
39
- mb: 1.5,
40
- mt: 1.5,
41
- };
@@ -56,7 +56,12 @@ export default function SubscriptionCancelForm({ data }: { data: TSubscriptionEx
56
56
 
57
57
  return (
58
58
  <Root sx={{ width: 400 }}>
59
- <Stack direction="row" spacing={3} alignItems="flex-start">
59
+ <Stack
60
+ direction="row"
61
+ spacing={3}
62
+ sx={{
63
+ alignItems: 'flex-start',
64
+ }}>
60
65
  <Typography className="form-title">{t('admin.subscription.cancel.at.title')}</Typography>
61
66
  <Stack>
62
67
  <RadioGroup>
@@ -114,7 +119,12 @@ export default function SubscriptionCancelForm({ data }: { data: TSubscriptionEx
114
119
  </Stack>
115
120
  </Stack>
116
121
  <Divider sx={{ my: 1 }} />
117
- <Stack direction="row" spacing={3} alignItems="flex-start">
122
+ <Stack
123
+ direction="row"
124
+ spacing={3}
125
+ sx={{
126
+ alignItems: 'flex-start',
127
+ }}>
118
128
  <Typography className="form-title">{t('admin.subscription.cancel.refund.title')}</Typography>
119
129
  <Stack>
120
130
  <RadioGroup>
@@ -152,7 +162,12 @@ export default function SubscriptionCancelForm({ data }: { data: TSubscriptionEx
152
162
  {data.paymentMethod.type === 'arcblock' && (
153
163
  <>
154
164
  <Divider sx={{ my: 1 }} />
155
- <Stack direction="row" spacing={3} alignItems="flex-start">
165
+ <Stack
166
+ direction="row"
167
+ spacing={3}
168
+ sx={{
169
+ alignItems: 'flex-start',
170
+ }}>
156
171
  <Typography className="form-title">{t('admin.subscription.cancel.staking.title')}</Typography>
157
172
  <RadioGroup>
158
173
  <FormControlLabel
@@ -204,8 +219,10 @@ export default function SubscriptionCancelForm({ data }: { data: TSubscriptionEx
204
219
  placeholder={t('admin.subscription.cancel.staking.slashReason')}
205
220
  error={!!(formState.errors as any)?.cancel?.slashReason}
206
221
  helperText={(formState.errors as any)?.cancel?.slashReason?.message}
207
- inputProps={{
208
- maxLength: 200,
222
+ slotProps={{
223
+ htmlInput: {
224
+ maxLength: 200,
225
+ },
209
226
  }}
210
227
  />
211
228
  )}
@@ -20,15 +20,11 @@ type Props = {
20
20
  onChange: (action: string) => void;
21
21
  };
22
22
 
23
- SubscriptionActionsInner.defaultProps = {
24
- variant: 'compact',
25
- };
26
-
27
23
  const fetchStakingData = (id: string, time: string): Promise<{ return_amount: string; slash_amount: string }> => {
28
24
  return api.get(`/api/subscriptions/${id}/staking?time=${encodeURIComponent(time)}`).then((res: any) => res.data);
29
25
  };
30
26
 
31
- function SubscriptionActionsInner({ data, variant, onChange }: Props) {
27
+ function SubscriptionActionsInner({ data, variant = 'compact', onChange }: Props) {
32
28
  const { t } = useLocaleContext();
33
29
  const navigate = useNavigate();
34
30
  const { reset, getValues, setError, handleSubmit } = useFormContext();
@@ -197,7 +193,14 @@ function SubscriptionActionsInner({ data, variant, onChange }: Props) {
197
193
  );
198
194
  }
199
195
 
200
- export default function SubscriptionActions(props: Props) {
196
+ export default function SubscriptionActions(rawProps: Props) {
197
+ const props = Object.assign(
198
+ {
199
+ variant: 'compact',
200
+ },
201
+ rawProps
202
+ );
203
+
201
204
  const methods = useForm({
202
205
  defaultValues: {
203
206
  cancel: {
@@ -224,7 +227,3 @@ export default function SubscriptionActions(props: Props) {
224
227
  </FormProvider>
225
228
  );
226
229
  }
227
-
228
- SubscriptionActions.defaultProps = {
229
- variant: 'compact',
230
- };
@@ -9,9 +9,22 @@ export default function SubscriptionPauseForm() {
9
9
 
10
10
  return (
11
11
  <Stack direction="column" spacing={3} sx={{ width: 400 }}>
12
- <Stack direction="row" spacing={3} alignItems="flex-start">
13
- <Typography flex={1}>{t('admin.subscription.pause.type.title')}</Typography>
14
- <Stack flex={2}>
12
+ <Stack
13
+ direction="row"
14
+ spacing={3}
15
+ sx={{
16
+ alignItems: 'flex-start',
17
+ }}>
18
+ <Typography
19
+ sx={{
20
+ flex: 1,
21
+ }}>
22
+ {t('admin.subscription.pause.type.title')}
23
+ </Typography>
24
+ <Stack
25
+ sx={{
26
+ flex: 2,
27
+ }}>
15
28
  <Controller
16
29
  name="pause.type"
17
30
  control={control}
@@ -50,9 +63,22 @@ export default function SubscriptionPauseForm() {
50
63
  )}
51
64
  </Stack>
52
65
  </Stack>
53
- <Stack direction="row" spacing={3} alignItems="flex-start">
54
- <Typography flex={1}>{t('admin.subscription.pause.behavior.title')}</Typography>
55
- <Stack flex={2}>
66
+ <Stack
67
+ direction="row"
68
+ spacing={3}
69
+ sx={{
70
+ alignItems: 'flex-start',
71
+ }}>
72
+ <Typography
73
+ sx={{
74
+ flex: 1,
75
+ }}>
76
+ {t('admin.subscription.pause.behavior.title')}
77
+ </Typography>
78
+ <Stack
79
+ sx={{
80
+ flex: 2,
81
+ }}>
56
82
  <Controller
57
83
  name="pause.behavior"
58
84
  control={control}
@@ -34,10 +34,12 @@ export default function SlashStakeForm({ data, stakeValue }: { data: TSubscripti
34
34
  placeholder={t('admin.subscription.cancel.staking.slashReason')}
35
35
  error={!!(formState.errors as any)?.slashStake?.slashReason}
36
36
  helperText={(formState.errors as any)?.slashStake?.slashReason?.message}
37
- inputProps={{
38
- maxLength: 200,
39
- }}
40
37
  sx={{ mt: 1 }}
38
+ slotProps={{
39
+ htmlInput: {
40
+ maxLength: 200,
41
+ },
42
+ }}
41
43
  />
42
44
  )}
43
45
  />
@@ -10,11 +10,21 @@ type Props = {
10
10
  maxLength?: number;
11
11
  };
12
12
 
13
- export default function SubscriptionDescription({ subscription, variant, hideSubscription, maxLength = 80 }: Props) {
13
+ export default function SubscriptionDescription({
14
+ subscription,
15
+ variant = 'body1',
16
+ hideSubscription = false,
17
+ maxLength = 80,
18
+ }: Props) {
14
19
  const { isMobile } = useMobile();
15
20
  if (subscription.description) {
16
21
  return (
17
- <Stack direction="row" alignItems="center" spacing={1}>
22
+ <Stack
23
+ direction="row"
24
+ spacing={1}
25
+ sx={{
26
+ alignItems: 'center',
27
+ }}>
18
28
  <Typography variant={variant} className="subscription-description">
19
29
  <TruncatedText text={subscription.description} maxLength={maxLength} useWidth />
20
30
  </Typography>
@@ -33,9 +43,3 @@ export default function SubscriptionDescription({ subscription, variant, hideSub
33
43
  </Typography>
34
44
  );
35
45
  }
36
-
37
- SubscriptionDescription.defaultProps = {
38
- variant: 'body1',
39
- hideSubscription: false,
40
- maxLength: 80,
41
- };
@@ -15,13 +15,9 @@ type ListProps = {
15
15
  mode?: 'admin' | 'customer';
16
16
  };
17
17
 
18
- SubscriptionItemList.defaultProps = {
19
- mode: 'customer',
20
- };
21
-
22
18
  const size = { width: 48, height: 48 };
23
19
 
24
- export default function SubscriptionItemList({ data, currency, mode }: ListProps) {
20
+ export default function SubscriptionItemList({ data, currency, mode = 'customer' }: ListProps) {
25
21
  const { t } = useLocaleContext();
26
22
  const { isMobile } = useMobile();
27
23
  const isAdmin = mode === 'admin';
@@ -35,12 +31,15 @@ export default function SubscriptionItemList({ data, currency, mode }: ListProps
35
31
  const item = data[index] as TSubscriptionItemExpanded;
36
32
  return (
37
33
  <Stack
38
- flexDirection="row"
39
- flexWrap="wrap"
40
- alignItems="center"
41
- gap={{
42
- xs: 1,
43
- sm: 2,
34
+ sx={{
35
+ flexDirection: 'row',
36
+ flexWrap: 'wrap',
37
+ alignItems: 'center',
38
+
39
+ gap: {
40
+ xs: 1,
41
+ sm: 2,
42
+ },
44
43
  }}>
45
44
  {item.price.product.images.length > 0 ? (
46
45
  // @ts-ignore
@@ -58,12 +57,20 @@ export default function SubscriptionItemList({ data, currency, mode }: ListProps
58
57
  )}
59
58
  {isAdmin ? (
60
59
  <>
61
- <Typography color="text.primary" fontWeight={600}>
60
+ <Typography
61
+ sx={{
62
+ color: 'text.primary',
63
+ fontWeight: 600,
64
+ }}>
62
65
  <Link to={`/admin/products/${item?.price.product_id}`}>
63
66
  <TruncatedText text={item?.price.product.name} maxLength={isMobile ? 20 : 50} useWidth />
64
67
  </Link>
65
68
  </Typography>
66
- <Typography color="text.secondary" whiteSpace="nowrap">
69
+ <Typography
70
+ sx={{
71
+ color: 'text.secondary',
72
+ whiteSpace: 'nowrap',
73
+ }}>
67
74
  <Link to={`/admin/products/${item?.price.id}`}>
68
75
  {formatPrice(item.price, currency, item?.price.product.unit_label)}
69
76
  </Link>
@@ -71,10 +78,18 @@ export default function SubscriptionItemList({ data, currency, mode }: ListProps
71
78
  </>
72
79
  ) : (
73
80
  <>
74
- <Typography color="text.primary" fontWeight={600}>
81
+ <Typography
82
+ sx={{
83
+ color: 'text.primary',
84
+ fontWeight: 600,
85
+ }}>
75
86
  <TruncatedText text={item?.price.product.name} maxLength={isMobile ? 20 : 50} useWidth />
76
87
  </Typography>
77
- <Typography color="text.secondary" whiteSpace="nowrap">
88
+ <Typography
89
+ sx={{
90
+ color: 'text.secondary',
91
+ whiteSpace: 'nowrap',
92
+ }}>
78
93
  {formatPrice(item.price, currency, item?.price.product.unit_label)}
79
94
  </Typography>
80
95
  </>
@@ -94,7 +109,7 @@ export default function SubscriptionItemList({ data, currency, mode }: ListProps
94
109
  },
95
110
  },
96
111
  },
97
- {
112
+ currency.type !== 'credit' && {
98
113
  label: t('common.quantity'),
99
114
  name: 'quantity',
100
115
  options: {