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
@@ -6,10 +6,10 @@ import { InfoType, UserCardProps } from '@arcblock/ux/lib/UserCard/types';
6
6
 
7
7
  export default function CustomerLink({
8
8
  customer,
9
- linked,
10
- linkTo,
11
- size,
12
- cardProps,
9
+ linked = true,
10
+ linkTo = '',
11
+ size = 'default',
12
+ cardProps = {},
13
13
  }: {
14
14
  customer: TCustomer;
15
15
  linked?: boolean;
@@ -61,11 +61,3 @@ export default function CustomerLink({
61
61
 
62
62
  return CustomerCard;
63
63
  }
64
-
65
- CustomerLink.defaultProps = {
66
- linked: true,
67
- linkTo: '',
68
- size: 'default',
69
- tooltip: true,
70
- cardProps: {},
71
- };
@@ -92,14 +92,10 @@ function TimeSelector({
92
92
  );
93
93
  }
94
94
 
95
- DaySelector.defaultProps = {
96
- onBlur: () => {},
97
- };
98
-
99
95
  function DaySelector({
100
96
  value,
101
97
  onChange,
102
- onBlur,
98
+ onBlur = () => {},
103
99
  }: {
104
100
  value: number;
105
101
  onChange: (day: number) => void;
@@ -275,7 +271,12 @@ export function NotificationPreferenceDialog({ open, onClose }: NotificationPref
275
271
  onClose={onClose}
276
272
  disableEscapeKeyDown
277
273
  title={
278
- <Stack direction="row" alignItems="center" spacing={1}>
274
+ <Stack
275
+ direction="row"
276
+ spacing={1}
277
+ sx={{
278
+ alignItems: 'center',
279
+ }}>
279
280
  <NotificationsOutlined fontSize="small" />
280
281
  <Typography variant="h6" component="span">
281
282
  {t('notification.preferences.title')}
@@ -301,7 +302,12 @@ export function NotificationPreferenceDialog({ open, onClose }: NotificationPref
301
302
  </Stack>
302
303
  }>
303
304
  {loading ? (
304
- <Stack alignItems="center" justifyContent="center" height={200}>
305
+ <Stack
306
+ sx={{
307
+ alignItems: 'center',
308
+ justifyContent: 'center',
309
+ height: 200,
310
+ }}>
305
311
  <CircularProgress />
306
312
  </Stack>
307
313
  ) : (
@@ -311,7 +317,10 @@ export function NotificationPreferenceDialog({ open, onClose }: NotificationPref
311
317
  <Typography id="frequency-label" sx={{ color: 'text.primary', mt: 2, mb: 1 }}>
312
318
  {t('notification.preferences.frequency.label')}
313
319
  </Typography>
314
- <Stack flexDirection="row">
320
+ <Stack
321
+ sx={{
322
+ flexDirection: 'row',
323
+ }}>
315
324
  <Box
316
325
  sx={{
317
326
  display: 'flex',
@@ -371,8 +380,8 @@ export function NotificationPreferenceDialog({ open, onClose }: NotificationPref
371
380
  {selectedDate > 28 && frequency === 'monthly' && (
372
381
  <Typography
373
382
  variant="caption"
374
- color="text.secondary"
375
383
  sx={{
384
+ color: 'text.secondary',
376
385
  fontStyle: 'italic',
377
386
  display: 'flex',
378
387
  alignItems: 'center',
@@ -90,23 +90,17 @@ type OverdraftProtectionDialogProps = {
90
90
  } | null;
91
91
  };
92
92
 
93
- OverdraftProtectionDialog.defaultProps = {
94
- payerAddress: '',
95
- stakingAddress: '',
96
- initValues: null,
97
- };
98
-
99
93
  export default function OverdraftProtectionDialog({
100
94
  value,
101
95
  loading,
102
96
  onSave,
103
97
  onCancel,
104
98
  open,
105
- stakingAddress,
106
- payerAddress,
99
+ stakingAddress = '',
100
+ payerAddress = '',
107
101
  currency,
108
102
  subscription,
109
- initValues,
103
+ initValues = null,
110
104
  }: OverdraftProtectionDialogProps) {
111
105
  const { t, locale } = useLocaleContext();
112
106
  const { isMobile } = useMobile();
@@ -251,7 +245,12 @@ export default function OverdraftProtectionDialog({
251
245
  fullWidth
252
246
  className="base-dialog"
253
247
  title={
254
- <Stack direction="row" alignItems="center" spacing={1}>
248
+ <Stack
249
+ direction="row"
250
+ spacing={1}
251
+ sx={{
252
+ alignItems: 'center',
253
+ }}>
255
254
  <Typography variant="h6" component="span">
256
255
  {t('customer.overdraftProtection.setting')}
257
256
  </Typography>
@@ -296,7 +295,10 @@ export default function OverdraftProtectionDialog({
296
295
  </Button>
297
296
  </Stack>
298
297
  }>
299
- <Stack gap={2}>
298
+ <Stack
299
+ sx={{
300
+ gap: 2,
301
+ }}>
300
302
  <Alert severity="info">
301
303
  {value.used !== '0' && !isEnabled ? (
302
304
  <>{t('customer.overdraftProtection.disableConfirm')}</>
@@ -317,8 +319,17 @@ export default function OverdraftProtectionDialog({
317
319
  )}
318
320
  </Alert>
319
321
 
320
- <Stack spacing={2} direction="row" alignItems="center">
321
- <Typography variant="subtitle1" color="text.secondary">
322
+ <Stack
323
+ spacing={2}
324
+ direction="row"
325
+ sx={{
326
+ alignItems: 'center',
327
+ }}>
328
+ <Typography
329
+ variant="subtitle1"
330
+ sx={{
331
+ color: 'text.secondary',
332
+ }}>
322
333
  {t('customer.overdraftProtection.title')}
323
334
  </Typography>
324
335
  <FormControlLabel
@@ -328,7 +339,11 @@ export default function OverdraftProtectionDialog({
328
339
  </Stack>
329
340
 
330
341
  {isEnabled ? (
331
- <Stack gap={1} sx={{ mt: '-8px' }}>
342
+ <Stack
343
+ sx={{
344
+ gap: 1,
345
+ mt: '-8px',
346
+ }}>
332
347
  {payerAddress && (
333
348
  <Stack
334
349
  sx={
@@ -343,7 +358,11 @@ export default function OverdraftProtectionDialog({
343
358
  gap: 2,
344
359
  }
345
360
  }>
346
- <Typography variant="subtitle2" color="text.secondary">
361
+ <Typography
362
+ variant="subtitle2"
363
+ sx={{
364
+ color: 'text.secondary',
365
+ }}>
347
366
  {t('customer.overdraftProtection.payerAddress')}
348
367
  </Typography>
349
368
  <Typography variant="body2" sx={{ wordBreak: 'break-all', fontFamily: 'monospace', fontWeight: '700' }}>
@@ -366,7 +385,11 @@ export default function OverdraftProtectionDialog({
366
385
  gap: 2,
367
386
  }
368
387
  }>
369
- <Typography variant="subtitle2" color="text.secondary">
388
+ <Typography
389
+ variant="subtitle2"
390
+ sx={{
391
+ color: 'text.secondary',
392
+ }}>
370
393
  {t('customer.overdraftProtection.stakingAddress')}
371
394
  </Typography>
372
395
  <Link
@@ -390,7 +413,11 @@ export default function OverdraftProtectionDialog({
390
413
  </Stack>
391
414
  )}
392
415
 
393
- <Typography variant="body2" color="text.secondary">
416
+ <Typography
417
+ variant="body2"
418
+ sx={{
419
+ color: 'text.secondary',
420
+ }}>
394
421
  {(() => {
395
422
  if (Number(dueAmount) > 0 && !value.enabled) {
396
423
  return t('customer.overdraftProtection.remainingNotEnough', {
@@ -414,15 +441,25 @@ export default function OverdraftProtectionDialog({
414
441
  })()}
415
442
  </Typography>
416
443
 
417
- <Grid container spacing={2} ml={-2} sx={{ mt: -1 }}>
444
+ <Grid
445
+ container
446
+ spacing={2}
447
+ sx={{
448
+ ml: -2,
449
+ mt: -1,
450
+ }}>
418
451
  {cycleAmountLoading ? (
419
452
  // 加载状态的占位
420
453
  <>
421
454
  {[1, 2, 3, 4, 5].map((key) => (
422
- <Grid item xs={6} sm={4} key={key}>
455
+ <Grid size={{ xs: 6, sm: 4 }} key={key}>
423
456
  <Card variant="outlined" sx={{ height: '100%' }}>
424
457
  <CardActionArea sx={{ height: '100%', p: 1 }}>
425
- <Stack spacing={1} alignItems="center">
458
+ <Stack
459
+ spacing={1}
460
+ sx={{
461
+ alignItems: 'center',
462
+ }}>
426
463
  <Skeleton variant="rectangular" width={80} height={32} />
427
464
  <Skeleton width={100} />
428
465
  </Stack>
@@ -430,10 +467,14 @@ export default function OverdraftProtectionDialog({
430
467
  </Card>
431
468
  </Grid>
432
469
  ))}
433
- <Grid item xs={6} sm={4}>
470
+ <Grid size={{ xs: 6, sm: 4 }}>
434
471
  <Card variant="outlined" sx={{ height: '100%' }}>
435
472
  <CardActionArea sx={{ height: '100%', p: 2 }}>
436
- <Stack spacing={1} alignItems="center">
473
+ <Stack
474
+ spacing={1}
475
+ sx={{
476
+ alignItems: 'center',
477
+ }}>
437
478
  <Skeleton variant="rectangular" width={80} height={24} />
438
479
  </Stack>
439
480
  </CardActionArea>
@@ -443,7 +484,7 @@ export default function OverdraftProtectionDialog({
443
484
  ) : (
444
485
  <>
445
486
  {presetAmounts.map(({ amount: presetAmount, cycles }) => (
446
- <Grid item xs={6} sm={4} key={presetAmount}>
487
+ <Grid size={{ xs: 6, sm: 4 }} key={presetAmount}>
447
488
  <Card
448
489
  variant="outlined"
449
490
  sx={{
@@ -464,11 +505,19 @@ export default function OverdraftProtectionDialog({
464
505
  setCustomAmount(false);
465
506
  }}
466
507
  sx={{ height: '100%', p: 1 }}>
467
- <Stack spacing={1} alignItems="center">
508
+ <Stack
509
+ spacing={1}
510
+ sx={{
511
+ alignItems: 'center',
512
+ }}>
468
513
  <Typography variant="h6" sx={{ fontWeight: 600 }}>
469
514
  {presetAmount} {currency.symbol}
470
515
  </Typography>
471
- <Typography variant="caption" color="text.secondary">
516
+ <Typography
517
+ variant="caption"
518
+ sx={{
519
+ color: 'text.secondary',
520
+ }}>
472
521
  {formatEstimatedDuration(cycles)}
473
522
  </Typography>
474
523
  </Stack>
@@ -476,7 +525,7 @@ export default function OverdraftProtectionDialog({
476
525
  </Card>
477
526
  </Grid>
478
527
  ))}
479
- <Grid item xs={6} sm={4}>
528
+ <Grid size={{ xs: 6, sm: 4 }}>
480
529
  <Card
481
530
  variant="outlined"
482
531
  sx={{
@@ -490,7 +539,11 @@ export default function OverdraftProtectionDialog({
490
539
  ...(customAmount ? { borderColor: 'primary.main', borderWidth: 1 } : {}),
491
540
  }}>
492
541
  <CardActionArea onClick={handleCustomSelect} sx={{ height: '100%', p: 2 }}>
493
- <Stack spacing={1} alignItems="center">
542
+ <Stack
543
+ spacing={1}
544
+ sx={{
545
+ alignItems: 'center',
546
+ }}>
494
547
  <Typography variant="h6" sx={{ fontWeight: 600 }}>
495
548
  {t('common.custom')}
496
549
  </Typography>
@@ -538,16 +591,18 @@ export default function OverdraftProtectionDialog({
538
591
  helperText={methods.formState.errors.amount?.message}
539
592
  fullWidth
540
593
  variant="outlined"
541
- InputProps={{
542
- endAdornment: (
543
- <Box sx={{ ml: 1, display: 'flex', alignItems: 'center' }}>
544
- <Currency logo={currency.logo} name={currency.symbol} />
545
- </Box>
546
- ),
547
- inputProps: {
548
- min: 0,
549
- max: MAX_SAFE_AMOUNT,
550
- step: Number(estimateAmount),
594
+ slotProps={{
595
+ input: {
596
+ endAdornment: (
597
+ <Box sx={{ ml: 1, display: 'flex', alignItems: 'center' }}>
598
+ <Currency logo={currency.logo} name={currency.symbol} />
599
+ </Box>
600
+ ),
601
+ inputProps: {
602
+ min: 0,
603
+ max: MAX_SAFE_AMOUNT,
604
+ step: Number(estimateAmount),
605
+ },
551
606
  },
552
607
  }}
553
608
  />
@@ -555,7 +610,13 @@ export default function OverdraftProtectionDialog({
555
610
  </Stack>
556
611
  )}
557
612
  {amount && Number(amount) > 0 && Number(estimateAmount) > 0 && !methods.formState.errors.amount && (
558
- <Typography variant="body2" sx={{ color: 'text.lighter', mt: '8px !important' }} fontSize={12}>
613
+ <Typography
614
+ variant="body2"
615
+ sx={{
616
+ fontSize: 12,
617
+ color: 'text.lighter',
618
+ mt: '8px !important',
619
+ }}>
559
620
  {t('customer.overdraftProtection.total', {
560
621
  total: safeAdd(currency, amount, availableAmount),
561
622
  symbol: currency.symbol,
@@ -568,11 +629,21 @@ export default function OverdraftProtectionDialog({
568
629
  </Stack>
569
630
  ) : (
570
631
  Number(availableAmount) > 0 && (
571
- <Stack direction="row" alignItems="flex-start" gap={2}>
632
+ <Stack
633
+ direction="row"
634
+ sx={{
635
+ alignItems: 'flex-start',
636
+ gap: 2,
637
+ }}>
572
638
  <Typography
573
639
  variant="subtitle2"
574
- color="text.secondary"
575
- sx={{ height: 39, display: 'flex', alignItems: 'center', width: 56 }}>
640
+ sx={{
641
+ color: 'text.secondary',
642
+ height: 39,
643
+ display: 'flex',
644
+ alignItems: 'center',
645
+ width: 56,
646
+ }}>
576
647
  {t('customer.overdraftProtection.stake')}
577
648
  </Typography>
578
649
  <RadioGroup
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  import { Livemode, usePaymentContext } from '@blocklet/payment-react';
2
3
  import { Close } from '@mui/icons-material';
3
4
  import { Box, Button, Divider, Drawer, Stack, Typography } from '@mui/material';
@@ -19,17 +20,19 @@ type Props = {
19
20
  footer?: React.ReactNode;
20
21
  };
21
22
 
22
- DrawerForm.defaultProps = {
23
- style: {},
24
- open: false,
25
- width: 960,
26
- onClose: noop,
27
- hideLiveMode: false,
28
- footer: null,
29
- addons: null,
30
- };
31
-
32
- export default function DrawerForm(props: Props) {
23
+ export default function DrawerForm(rawProps: Props) {
24
+ const props = Object.assign(
25
+ {
26
+ style: {},
27
+ open: false,
28
+ width: 960,
29
+ onClose: noop,
30
+ hideLiveMode: false,
31
+ footer: null,
32
+ addons: null,
33
+ },
34
+ rawProps
35
+ );
33
36
  const [open, setOpen] = useState(props.open);
34
37
  const settings = usePaymentContext();
35
38
  const handleClose = () => {
@@ -58,11 +61,11 @@ export default function DrawerForm(props: Props) {
58
61
  disableEscapeKeyDown>
59
62
  <Stack
60
63
  direction="row"
61
- alignItems="center"
62
- justifyContent="space-between"
63
64
  className="drawer-form-header-wrapper"
64
- flexWrap="wrap"
65
65
  sx={{
66
+ alignItems: 'center',
67
+ justifyContent: 'space-between',
68
+ flexWrap: 'wrap',
66
69
  pl: 3,
67
70
  pr: 3,
68
71
  pb: 2,
@@ -70,6 +73,7 @@ export default function DrawerForm(props: Props) {
70
73
  gap: 1,
71
74
  borderBottom: '1px solid',
72
75
  borderColor: 'grey.200',
76
+
73
77
  '@media (max-width: 600px)': {
74
78
  '& > .addons-wrapper': {
75
79
  width: '100%',
@@ -80,21 +84,41 @@ export default function DrawerForm(props: Props) {
80
84
  },
81
85
  },
82
86
  }}>
83
- <Box flex={1} display="flex" alignItems="center" justifyContent="space-between">
84
- <Stack direction="row" alignItems="center">
87
+ <Box
88
+ sx={{
89
+ flex: 1,
90
+ display: 'flex',
91
+ alignItems: 'center',
92
+ justifyContent: 'space-between',
93
+ }}>
94
+ <Stack
95
+ direction="row"
96
+ sx={{
97
+ alignItems: 'center',
98
+ }}>
85
99
  <Typography className="drawer-form-header" variant="h6" sx={{ fontWeight: 600 }}>
86
100
  {props.text}
87
101
  </Typography>
88
102
  {!settings.livemode && !props.hideLiveMode && <Livemode />}
89
103
  </Stack>
90
- <Stack direction="row" alignItems="center" justifyContent="space-between">
104
+ <Stack
105
+ direction="row"
106
+ sx={{
107
+ alignItems: 'center',
108
+ justifyContent: 'space-between',
109
+ }}>
91
110
  <Close
92
111
  sx={{ mr: props.addons ? 1 : 0, color: 'text.secondary', cursor: 'pointer' }}
93
112
  onClick={handleClose}
94
113
  />
95
114
  </Stack>
96
115
  </Box>
97
- <Box display="flex" alignItems="center" className="addons-wrapper">
116
+ <Box
117
+ className="addons-wrapper"
118
+ sx={{
119
+ display: 'flex',
120
+ alignItems: 'center',
121
+ }}>
98
122
  {props.addons && <Divider orientation="vertical" flexItem sx={{ mr: 2 }} className="addons-divider" />}
99
123
  {props.addons}
100
124
  </Box>
@@ -24,7 +24,7 @@ const Content = styled(Box)`
24
24
  text-align: center;
25
25
  `;
26
26
 
27
- export default function Error({ error }: { error?: Error }) {
27
+ export default function Error({ error = undefined }: { error?: Error }) {
28
28
  const { t } = useLocaleContext();
29
29
 
30
30
  return (
@@ -34,7 +34,3 @@ export default function Error({ error }: { error?: Error }) {
34
34
  </Container>
35
35
  );
36
36
  }
37
-
38
- Error.defaultProps = {
39
- error: {},
40
- };
@@ -120,15 +120,7 @@ const getEventDescription = (event: TEventExpanded) => {
120
120
  }
121
121
  };
122
122
 
123
- EventList.defaultProps = {
124
- features: {
125
- toolbar: true,
126
- },
127
- type: '',
128
- object_id: '',
129
- };
130
-
131
- export default function EventList({ type, object_id, features }: ListProps) {
123
+ export default function EventList({ type = '', object_id = '', features = { toolbar: true } }: ListProps) {
132
124
  const listKey = getListKey({ type, object_id });
133
125
  const persisted = getDurableData(listKey);
134
126
 
@@ -156,7 +148,14 @@ export default function EventList({ type, object_id, features }: ListProps) {
156
148
  }
157
149
 
158
150
  if (data && data.list.length === 0) {
159
- return <Typography color="text.secondary">{t('admin.event.empty')}</Typography>;
151
+ return (
152
+ <Typography
153
+ sx={{
154
+ color: 'text.secondary',
155
+ }}>
156
+ {t('admin.event.empty')}
157
+ </Typography>
158
+ );
160
159
  }
161
160
 
162
161
  const columns = [
@@ -51,7 +51,9 @@ type Props = {
51
51
  formatStatus?: (x: string) => string;
52
52
  };
53
53
 
54
- export default function FilterToolbar(props: Props) {
54
+ export default function FilterToolbar(rawProps: Props) {
55
+ const props = Object.assign({}, defaultProps, rawProps);
56
+ // eslint-disable-next-line react/prop-types
55
57
  const { setSearch, search, status, currency, donation, formatStatus = (v) => v } = props;
56
58
  const { isMobile } = useMobile();
57
59
  const isProduct = window.location.pathname.includes('product');
@@ -74,7 +76,8 @@ export default function FilterToolbar(props: Props) {
74
76
  <SearchStatus setSearch={handleSearch} search={search} status={status} formatStatus={formatStatus} />
75
77
  {!isMobile && (
76
78
  <>
77
- {Array.isArray(donation) && donation.length > 0 && (
79
+ {/* eslint-disable-next-line react/prop-types */}
80
+ {Array.isArray(donation) && donation?.length > 0 && (
78
81
  <SearchDonation setSearch={handleSearch} search={search} donation={donation} />
79
82
  )}
80
83
  {isProduct ? null : (
@@ -96,26 +99,20 @@ export default function FilterToolbar(props: Props) {
96
99
  );
97
100
  }
98
101
 
99
- const defaultProps = {
102
+ const defaultProps: Props = {
100
103
  search: {},
101
104
  status: [],
102
105
  currency: false,
103
106
  donation: [],
104
107
  formatStatus: (v: string) => v,
108
+ setSearch: () => {},
105
109
  };
106
110
 
107
- FilterToolbar.defaultProps = defaultProps;
108
- SearchStatus.defaultProps = defaultProps;
109
- SearchCurrency.defaultProps = defaultProps;
110
- SearchProducts.defaultProps = defaultProps;
111
- SearchCustomers.defaultProps = defaultProps;
112
- SearchDonation.defaultProps = defaultProps;
113
-
114
111
  function SearchStatus({
115
- status = [],
116
- search,
112
+ status = defaultProps.status,
113
+ search = defaultProps.search,
117
114
  setSearch,
118
- formatStatus,
115
+ formatStatus = defaultProps.formatStatus,
119
116
  }: Pick<Props, 'status' | 'search' | 'setSearch' | 'formatStatus'>) {
120
117
  const [show, setShow] = useState(null);
121
118
  const { t } = useLocaleContext();
@@ -150,7 +147,7 @@ function SearchStatus({
150
147
  setShow(null);
151
148
  }}
152
149
  className="status-options">
153
- {status.map((x: any) => (
150
+ {status?.map((x: any) => (
154
151
  <MenuItem
155
152
  onClick={(e) => {
156
153
  e.stopPropagation();
@@ -179,7 +176,7 @@ function filterCurrency(methods: any) {
179
176
  return out;
180
177
  }
181
178
 
182
- function SearchCurrency({ setSearch, search }: Pick<Props, 'setSearch' | 'search'>) {
179
+ function SearchCurrency({ setSearch, search = defaultProps.search }: Pick<Props, 'setSearch' | 'search'>) {
183
180
  const [show, setShow] = useState(null);
184
181
  const { settings } = usePaymentContext();
185
182
  const currencies = filterCurrency(settings.paymentMethods);
@@ -234,7 +231,7 @@ function SearchCurrency({ setSearch, search }: Pick<Props, 'setSearch' | 'search
234
231
  );
235
232
  }
236
233
 
237
- function SearchCustomers({ setSearch, search }: Pick<Props, 'setSearch' | 'search'>) {
234
+ function SearchCustomers({ setSearch, search = defaultProps.search }: Pick<Props, 'setSearch' | 'search'>) {
238
235
  const [customers, setCustomers] = useState<TCustomer[]>([]);
239
236
  const [show, setShow] = useState(null);
240
237
  const [searchText, setSearchText] = useState('');
@@ -337,7 +334,7 @@ function SearchCustomers({ setSearch, search }: Pick<Props, 'setSearch' | 'searc
337
334
  );
338
335
  }
339
336
 
340
- function SearchProducts({ setSearch, search }: Pick<Props, 'setSearch' | 'search'>) {
337
+ function SearchProducts({ setSearch, search = defaultProps.search }: Pick<Props, 'setSearch' | 'search'>) {
341
338
  const [show, setShow] = useState(null);
342
339
  const { products } = useProductsContext();
343
340
  const { settings } = usePaymentContext();
@@ -427,7 +424,11 @@ function SearchProducts({ setSearch, search }: Pick<Props, 'setSearch' | 'search
427
424
  );
428
425
  }
429
426
 
430
- function SearchDonation({ donation = [], search, setSearch }: Pick<Props, 'donation' | 'search' | 'setSearch'>) {
427
+ function SearchDonation({
428
+ donation = defaultProps.donation,
429
+ search = defaultProps.search,
430
+ setSearch,
431
+ }: Pick<Props, 'donation' | 'search' | 'setSearch'>) {
431
432
  const [show, setShow] = useState(null);
432
433
  const { t } = useLocaleContext();
433
434
  return (
@@ -461,7 +462,7 @@ function SearchDonation({ donation = [], search, setSearch }: Pick<Props, 'donat
461
462
  setShow(null);
462
463
  }}
463
464
  className="status-options">
464
- {donation.map((x: any) => (
465
+ {donation?.map((x: any) => (
465
466
  <MenuItem
466
467
  onClick={(e) => {
467
468
  e.stopPropagation();