@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.
Files changed (251) hide show
  1. package/es/checkout/donate.d.ts +1 -15
  2. package/es/checkout/donate.js +301 -189
  3. package/es/checkout/form.d.ts +1 -15
  4. package/es/checkout/form.js +5 -13
  5. package/es/checkout/table.js +3 -3
  6. package/es/components/blockchain/gas.d.ts +1 -5
  7. package/es/components/blockchain/gas.js +10 -2
  8. package/es/components/blockchain/tx.d.ts +1 -8
  9. package/es/components/blockchain/tx.js +29 -10
  10. package/es/components/confirm.d.ts +1 -10
  11. package/es/components/confirm.js +4 -10
  12. package/es/components/country-select.d.ts +3 -2
  13. package/es/components/country-select.js +375 -352
  14. package/es/components/date-range-picker.d.ts +13 -0
  15. package/es/components/date-range-picker.js +279 -0
  16. package/es/components/input.d.ts +14 -20
  17. package/es/components/input.js +51 -44
  18. package/es/components/label.d.ts +7 -0
  19. package/es/components/label.js +49 -0
  20. package/es/components/lazy-loader.js +1 -2
  21. package/es/components/link.d.ts +2 -9
  22. package/es/components/link.js +9 -6
  23. package/es/components/livemode.d.ts +2 -8
  24. package/es/components/livemode.js +1 -5
  25. package/es/components/loading-button.d.ts +6 -1
  26. package/es/components/loading-button.js +56 -66
  27. package/es/components/over-due-invoice-payment.d.ts +0 -18
  28. package/es/components/over-due-invoice-payment.js +138 -95
  29. package/es/components/payment-beneficiaries.d.ts +2 -7
  30. package/es/components/payment-beneficiaries.js +86 -40
  31. package/es/components/pricing-item.d.ts +0 -5
  32. package/es/components/pricing-item.js +1 -4
  33. package/es/components/pricing-table.d.ts +2 -10
  34. package/es/components/pricing-table.js +8 -7
  35. package/es/components/resume-subscription.d.ts +0 -10
  36. package/es/components/resume-subscription.js +42 -21
  37. package/es/components/truncated-text.d.ts +2 -9
  38. package/es/components/truncated-text.js +0 -5
  39. package/es/contexts/donate.d.ts +0 -7
  40. package/es/contexts/donate.js +10 -8
  41. package/es/contexts/payment.d.ts +1 -4
  42. package/es/contexts/payment.js +7 -2
  43. package/es/history/credit/grants-list.d.ts +14 -0
  44. package/es/history/credit/grants-list.js +215 -0
  45. package/es/history/credit/transactions-list.d.ts +13 -0
  46. package/es/history/credit/transactions-list.js +255 -0
  47. package/es/history/invoice/list.d.ts +2 -18
  48. package/es/history/invoice/list.js +172 -74
  49. package/es/history/payment/list.js +115 -38
  50. package/es/hooks/keyboard.d.ts +1 -1
  51. package/es/hooks/keyboard.js +2 -4
  52. package/es/index.d.ts +5 -1
  53. package/es/index.js +10 -1
  54. package/es/libs/cached-request.js +2 -4
  55. package/es/libs/phone-validator.js +1 -2
  56. package/es/libs/util.d.ts +2 -0
  57. package/es/libs/util.js +14 -4
  58. package/es/libs/validator.js +2 -4
  59. package/es/locales/en.js +20 -2
  60. package/es/locales/zh.js +20 -2
  61. package/es/payment/amount.d.ts +2 -7
  62. package/es/payment/amount.js +1 -5
  63. package/es/payment/donation-form.d.ts +2 -10
  64. package/es/payment/donation-form.js +196 -160
  65. package/es/payment/error.d.ts +2 -8
  66. package/es/payment/error.js +40 -20
  67. package/es/payment/footer.d.ts +2 -3
  68. package/es/payment/footer.js +19 -6
  69. package/es/payment/form/addon.js +14 -4
  70. package/es/payment/form/address.d.ts +2 -9
  71. package/es/payment/form/address.js +3 -6
  72. package/es/payment/form/currency.js +45 -25
  73. package/es/payment/form/index.d.ts +2 -8
  74. package/es/payment/form/index.js +151 -71
  75. package/es/payment/form/phone.js +2 -4
  76. package/es/payment/form/stripe/form.d.ts +2 -8
  77. package/es/payment/form/stripe/form.js +1 -3
  78. package/es/payment/header.js +38 -16
  79. package/es/payment/index.d.ts +2 -9
  80. package/es/payment/index.js +23 -17
  81. package/es/payment/product-card.d.ts +2 -11
  82. package/es/payment/product-card.js +84 -50
  83. package/es/payment/product-donation.js +175 -114
  84. package/es/payment/product-item.d.ts +9 -9
  85. package/es/payment/product-item.js +320 -145
  86. package/es/payment/product-skeleton.js +2 -2
  87. package/es/payment/skeleton/donation.js +27 -7
  88. package/es/payment/skeleton/overview.js +22 -2
  89. package/es/payment/skeleton/payment.js +33 -5
  90. package/es/payment/success.d.ts +2 -9
  91. package/es/payment/success.js +41 -14
  92. package/es/payment/summary.d.ts +4 -17
  93. package/es/payment/summary.js +193 -111
  94. package/es/theme/index.d.ts +0 -5
  95. package/es/theme/index.js +2 -5
  96. package/es/theme/typography.d.ts +2 -2
  97. package/lib/checkout/donate.d.ts +1 -15
  98. package/lib/checkout/donate.js +75 -54
  99. package/lib/checkout/form.d.ts +1 -15
  100. package/lib/checkout/form.js +7 -15
  101. package/lib/checkout/table.js +4 -4
  102. package/lib/components/blockchain/gas.d.ts +1 -5
  103. package/lib/components/blockchain/gas.js +3 -2
  104. package/lib/components/blockchain/tx.d.ts +1 -8
  105. package/lib/components/blockchain/tx.js +15 -10
  106. package/lib/components/confirm.d.ts +1 -10
  107. package/lib/components/confirm.js +5 -11
  108. package/lib/components/country-select.d.ts +3 -2
  109. package/lib/components/country-select.js +23 -22
  110. package/lib/components/date-range-picker.d.ts +13 -0
  111. package/lib/components/date-range-picker.js +329 -0
  112. package/lib/components/input.d.ts +14 -20
  113. package/lib/components/input.js +28 -27
  114. package/lib/components/label.d.ts +7 -0
  115. package/lib/components/label.js +60 -0
  116. package/lib/components/lazy-loader.js +1 -1
  117. package/lib/components/link.d.ts +2 -9
  118. package/lib/components/link.js +3 -8
  119. package/lib/components/livemode.d.ts +2 -8
  120. package/lib/components/livemode.js +3 -7
  121. package/lib/components/loading-button.d.ts +6 -1
  122. package/lib/components/loading-button.js +9 -17
  123. package/lib/components/over-due-invoice-payment.d.ts +0 -18
  124. package/lib/components/over-due-invoice-payment.js +31 -33
  125. package/lib/components/payment-beneficiaries.d.ts +2 -7
  126. package/lib/components/payment-beneficiaries.js +12 -11
  127. package/lib/components/pricing-item.d.ts +0 -5
  128. package/lib/components/pricing-item.js +2 -5
  129. package/lib/components/pricing-table.d.ts +2 -10
  130. package/lib/components/pricing-table.js +5 -11
  131. package/lib/components/resume-subscription.d.ts +0 -10
  132. package/lib/components/resume-subscription.js +16 -16
  133. package/lib/components/table.js +1 -1
  134. package/lib/components/truncated-text.d.ts +2 -9
  135. package/lib/components/truncated-text.js +1 -6
  136. package/lib/contexts/donate.d.ts +0 -7
  137. package/lib/contexts/donate.js +4 -7
  138. package/lib/contexts/payment.d.ts +1 -4
  139. package/lib/contexts/payment.js +4 -7
  140. package/lib/history/credit/grants-list.d.ts +14 -0
  141. package/lib/history/credit/grants-list.js +277 -0
  142. package/lib/history/credit/transactions-list.d.ts +13 -0
  143. package/lib/history/credit/transactions-list.js +301 -0
  144. package/lib/history/invoice/list.d.ts +2 -18
  145. package/lib/history/invoice/list.js +73 -37
  146. package/lib/history/payment/list.js +30 -16
  147. package/lib/hooks/keyboard.d.ts +1 -1
  148. package/lib/hooks/mobile.js +1 -1
  149. package/lib/hooks/subscription.js +1 -1
  150. package/lib/index.d.ts +5 -1
  151. package/lib/index.js +41 -2
  152. package/lib/libs/api.js +1 -1
  153. package/lib/libs/dayjs.js +1 -1
  154. package/lib/libs/phone-validator.js +0 -2
  155. package/lib/libs/theme.js +1 -1
  156. package/lib/libs/util.d.ts +2 -0
  157. package/lib/libs/util.js +15 -1
  158. package/lib/libs/validator.js +1 -1
  159. package/lib/locales/en.js +21 -3
  160. package/lib/locales/index.js +1 -1
  161. package/lib/locales/zh.js +21 -3
  162. package/lib/payment/amount.d.ts +2 -7
  163. package/lib/payment/amount.js +2 -6
  164. package/lib/payment/donation-form.d.ts +2 -10
  165. package/lib/payment/donation-form.js +33 -38
  166. package/lib/payment/error.d.ts +2 -8
  167. package/lib/payment/error.js +11 -13
  168. package/lib/payment/footer.d.ts +2 -3
  169. package/lib/payment/footer.js +5 -5
  170. package/lib/payment/form/addon.js +5 -3
  171. package/lib/payment/form/address.d.ts +2 -9
  172. package/lib/payment/form/address.js +5 -8
  173. package/lib/payment/form/currency.js +3 -3
  174. package/lib/payment/form/index.d.ts +2 -8
  175. package/lib/payment/form/index.js +64 -21
  176. package/lib/payment/form/phone.js +1 -1
  177. package/lib/payment/form/stripe/form.d.ts +2 -8
  178. package/lib/payment/form/stripe/form.js +3 -6
  179. package/lib/payment/header.js +8 -4
  180. package/lib/payment/index.d.ts +2 -9
  181. package/lib/payment/index.js +27 -18
  182. package/lib/payment/product-card.d.ts +2 -11
  183. package/lib/payment/product-card.js +13 -20
  184. package/lib/payment/product-donation.js +71 -66
  185. package/lib/payment/product-item.d.ts +9 -9
  186. package/lib/payment/product-item.js +168 -29
  187. package/lib/payment/product-skeleton.js +2 -2
  188. package/lib/payment/skeleton/donation.js +8 -4
  189. package/lib/payment/skeleton/overview.js +6 -2
  190. package/lib/payment/skeleton/payment.js +9 -3
  191. package/lib/payment/success.d.ts +2 -9
  192. package/lib/payment/success.js +12 -15
  193. package/lib/payment/summary.d.ts +4 -17
  194. package/lib/payment/summary.js +53 -45
  195. package/lib/theme/index.d.ts +0 -5
  196. package/lib/theme/index.js +2 -5
  197. package/lib/theme/typography.d.ts +2 -2
  198. package/package.json +40 -40
  199. package/src/checkout/donate.tsx +103 -35
  200. package/src/checkout/form.tsx +5 -14
  201. package/src/checkout/table.tsx +3 -3
  202. package/src/components/blockchain/gas.tsx +5 -3
  203. package/src/components/blockchain/tx.tsx +19 -11
  204. package/src/components/confirm.tsx +4 -11
  205. package/src/components/country-select.tsx +391 -378
  206. package/src/components/date-range-picker.tsx +310 -0
  207. package/src/components/input.tsx +61 -46
  208. package/src/components/label.tsx +58 -0
  209. package/src/components/link.tsx +9 -7
  210. package/src/components/livemode.tsx +2 -6
  211. package/src/components/loading-button.tsx +63 -76
  212. package/src/components/over-due-invoice-payment.tsx +43 -28
  213. package/src/components/payment-beneficiaries.tsx +33 -14
  214. package/src/components/pricing-item.tsx +1 -4
  215. package/src/components/pricing-table.tsx +8 -8
  216. package/src/components/resume-subscription.tsx +20 -14
  217. package/src/components/table.tsx +2 -2
  218. package/src/components/truncated-text.tsx +0 -6
  219. package/src/contexts/donate.tsx +6 -7
  220. package/src/contexts/payment.tsx +7 -3
  221. package/src/history/credit/grants-list.tsx +276 -0
  222. package/src/history/credit/transactions-list.tsx +317 -0
  223. package/src/history/invoice/list.tsx +92 -36
  224. package/src/history/payment/list.tsx +53 -16
  225. package/src/hooks/keyboard.ts +1 -1
  226. package/src/index.ts +9 -0
  227. package/src/libs/util.ts +14 -0
  228. package/src/locales/en.tsx +20 -0
  229. package/src/locales/zh.tsx +19 -0
  230. package/src/payment/amount.tsx +1 -6
  231. package/src/payment/donation-form.tsx +47 -29
  232. package/src/payment/error.tsx +16 -8
  233. package/src/payment/footer.tsx +11 -3
  234. package/src/payment/form/addon.tsx +6 -1
  235. package/src/payment/form/address.tsx +3 -7
  236. package/src/payment/form/currency.tsx +12 -2
  237. package/src/payment/form/index.tsx +121 -45
  238. package/src/payment/form/stripe/form.tsx +1 -5
  239. package/src/payment/header.tsx +14 -2
  240. package/src/payment/index.tsx +27 -22
  241. package/src/payment/product-card.tsx +41 -18
  242. package/src/payment/product-donation.tsx +85 -47
  243. package/src/payment/product-item.tsx +198 -28
  244. package/src/payment/product-skeleton.tsx +3 -2
  245. package/src/payment/skeleton/donation.tsx +12 -2
  246. package/src/payment/skeleton/overview.tsx +12 -2
  247. package/src/payment/skeleton/payment.tsx +16 -3
  248. package/src/payment/success.tsx +26 -15
  249. package/src/payment/summary.tsx +87 -44
  250. package/src/theme/index.tsx +5 -8
  251. package/src/theme/typography.ts +2 -2
@@ -0,0 +1,255 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
3
+ import { Box, Typography, Stack, Link, Grid } from "@mui/material";
4
+ import { useRequest } from "ahooks";
5
+ import { useNavigate } from "react-router-dom";
6
+ import React, { useCallback, useEffect, useRef, useState } from "react";
7
+ import { joinURL } from "ufo";
8
+ import { styled } from "@mui/system";
9
+ import DateRangePicker from "../../components/date-range-picker.js";
10
+ import { formatBNStr, formatToDate, getPrefix } from "../../libs/util.js";
11
+ import { usePaymentContext } from "../../contexts/payment.js";
12
+ import api from "../../libs/api.js";
13
+ import Table from "../../components/table.js";
14
+ import { createLink, handleNavigation } from "../../libs/navigation.js";
15
+ const fetchData = (params = {}) => {
16
+ const search = new URLSearchParams();
17
+ Object.keys(params).forEach((key) => {
18
+ if (params[key]) {
19
+ search.set(key, String(params[key]));
20
+ }
21
+ });
22
+ return api.get(`/api/credit-transactions?${search.toString()}`).then((res) => res.data);
23
+ };
24
+ const getGrantDetailLink = (grantId, inDashboard) => {
25
+ let path = `/customer/credit-grant/${grantId}`;
26
+ if (inDashboard) {
27
+ path = `/admin/customers/${grantId}`;
28
+ }
29
+ return {
30
+ link: createLink(path),
31
+ connect: false
32
+ };
33
+ };
34
+ const TransactionsTable = React.memo((props) => {
35
+ const {
36
+ pageSize,
37
+ customer_id,
38
+ subscription_id,
39
+ credit_grant_id,
40
+ onTableDataChange,
41
+ showAdminColumns = false,
42
+ showTimeFilter = false,
43
+ source,
44
+ mode = "portal"
45
+ } = props;
46
+ const listKey = "credit-transactions-table";
47
+ const { t, locale } = useLocaleContext();
48
+ const { session } = usePaymentContext();
49
+ const isAdmin = ["owner", "admin"].includes(session?.user?.role || "");
50
+ const navigate = useNavigate();
51
+ const effectiveCustomerId = customer_id || session?.user?.did;
52
+ const [search, setSearch] = useState({
53
+ pageSize: pageSize || 10,
54
+ page: 1
55
+ });
56
+ const [filters, setFilters] = useState({
57
+ start: void 0,
58
+ end: void 0
59
+ });
60
+ const handleDateRangeChange = useCallback((newValue) => {
61
+ setFilters(newValue);
62
+ setSearch((prev) => ({
63
+ ...prev,
64
+ page: 1,
65
+ start: newValue.start || void 0,
66
+ end: newValue.end || void 0
67
+ }));
68
+ }, []);
69
+ const { loading, data = { list: [], count: 0 } } = useRequest(
70
+ () => fetchData({
71
+ ...search,
72
+ customer_id: effectiveCustomerId,
73
+ subscription_id,
74
+ credit_grant_id,
75
+ source
76
+ }),
77
+ {
78
+ refreshDeps: [search, effectiveCustomerId, subscription_id, credit_grant_id, source]
79
+ }
80
+ );
81
+ useEffect(() => {
82
+ if (showTimeFilter && !search.start && !search.end) {
83
+ handleDateRangeChange(filters);
84
+ }
85
+ }, [showTimeFilter, handleDateRangeChange, search.start, search.end, filters]);
86
+ const prevData = useRef(data);
87
+ useEffect(() => {
88
+ if (onTableDataChange) {
89
+ onTableDataChange(data, prevData.current);
90
+ prevData.current = data;
91
+ }
92
+ }, [data]);
93
+ const columns = [
94
+ {
95
+ label: t("common.creditAmount"),
96
+ name: "credit_amount",
97
+ align: "right",
98
+ width: 120,
99
+ options: {
100
+ customBodyRenderLite: (_, index) => {
101
+ const transaction = data?.list[index];
102
+ const unit = transaction.meter?.unit || transaction.paymentCurrency.symbol;
103
+ return /* @__PURE__ */ jsxs(Typography, { children: [
104
+ formatBNStr(transaction.credit_amount, transaction.paymentCurrency.decimal),
105
+ " ",
106
+ unit
107
+ ] });
108
+ }
109
+ }
110
+ },
111
+ !credit_grant_id && {
112
+ label: t("common.creditGrant"),
113
+ name: "credit_grant",
114
+ options: {
115
+ customBodyRenderLite: (_, index) => {
116
+ const transaction = data?.list[index];
117
+ return /* @__PURE__ */ jsx(
118
+ Stack,
119
+ {
120
+ direction: "row",
121
+ spacing: 1,
122
+ onClick: (e) => {
123
+ const link = getGrantDetailLink(transaction.credit_grant_id, isAdmin && mode === "dashboard");
124
+ handleNavigation(e, link.link, navigate);
125
+ },
126
+ sx: {
127
+ alignItems: "center"
128
+ },
129
+ children: /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { color: "text.link", cursor: "pointer" }, children: transaction.creditGrant.name || `Grant ${transaction.credit_grant_id.slice(-6)}` })
130
+ }
131
+ );
132
+ }
133
+ }
134
+ },
135
+ {
136
+ label: t("common.description"),
137
+ name: "subscription",
138
+ options: {
139
+ customBodyRenderLite: (_, index) => {
140
+ const transaction = data?.list[index];
141
+ return /* @__PURE__ */ jsx(Typography, { variant: "body2", children: transaction.subscription?.description || transaction.description });
142
+ }
143
+ }
144
+ },
145
+ ...showAdminColumns && isAdmin ? [
146
+ {
147
+ label: t("common.meterEvent"),
148
+ name: "meter_event",
149
+ options: {
150
+ customBodyRenderLite: (_, index) => {
151
+ const transaction = data?.list[index];
152
+ if (!transaction.meter) {
153
+ return /* @__PURE__ */ jsx(Typography, { variant: "body2", children: "-" });
154
+ }
155
+ return /* @__PURE__ */ jsx(Link, { href: joinURL(getPrefix(), `/admin/billing/${transaction.meter.id}`), children: /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { color: "text.link" }, children: transaction.meter.event_name }) });
156
+ }
157
+ }
158
+ }
159
+ ] : [],
160
+ {
161
+ label: t("admin.creditTransactions.transactionDate"),
162
+ name: "created_at",
163
+ options: {
164
+ customBodyRenderLite: (_, index) => {
165
+ const transaction = data?.list[index];
166
+ return /* @__PURE__ */ jsx(Typography, { variant: "body2", children: formatToDate(transaction.created_at, locale, "YYYY-MM-DD HH:mm:ss") });
167
+ }
168
+ }
169
+ }
170
+ ].filter(Boolean);
171
+ const onTableChange = ({ page, rowsPerPage }) => {
172
+ if (search.pageSize !== rowsPerPage) {
173
+ setSearch((x) => ({ ...x, pageSize: rowsPerPage, page: 1 }));
174
+ } else if (search.page !== page + 1) {
175
+ setSearch((x) => ({ ...x, page: page + 1 }));
176
+ }
177
+ };
178
+ return /* @__PURE__ */ jsxs(TableRoot, { children: [
179
+ showTimeFilter && /* @__PURE__ */ jsx(Box, { sx: { my: 2 }, children: /* @__PURE__ */ jsx(Box, { sx: { mt: 2 }, children: /* @__PURE__ */ jsx(
180
+ Grid,
181
+ {
182
+ container: true,
183
+ spacing: 2,
184
+ sx: {
185
+ alignItems: "center"
186
+ },
187
+ children: /* @__PURE__ */ jsx(
188
+ Grid,
189
+ {
190
+ size: {
191
+ xs: 12,
192
+ sm: 6,
193
+ md: 4
194
+ },
195
+ children: /* @__PURE__ */ jsx(DateRangePicker, { value: filters, onChange: handleDateRangeChange, size: "small", fullWidth: true })
196
+ }
197
+ )
198
+ }
199
+ ) }) }),
200
+ /* @__PURE__ */ jsx(
201
+ Table,
202
+ {
203
+ hasRowLink: true,
204
+ durable: `__${listKey}__`,
205
+ durableKeys: ["page", "rowsPerPage"],
206
+ data: data.list,
207
+ columns,
208
+ options: {
209
+ count: data.count,
210
+ page: search.page - 1,
211
+ rowsPerPage: search.pageSize
212
+ },
213
+ loading,
214
+ onChange: onTableChange,
215
+ toolbar: false,
216
+ sx: { mt: 2 },
217
+ showMobile: false,
218
+ mobileTDFlexDirection: "row",
219
+ emptyNodeText: t("admin.creditTransactions.noTransactions")
220
+ }
221
+ )
222
+ ] });
223
+ });
224
+ const TableRoot = styled(Box)`
225
+ @media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
226
+ .MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
227
+ > div {
228
+ width: fit-content;
229
+ flex: inherit;
230
+ font-size: 14px;
231
+ }
232
+ }
233
+ .invoice-summary {
234
+ padding-right: 20px;
235
+ }
236
+ }
237
+ `;
238
+ export default function CreditTransactionsList(rawProps) {
239
+ const props = Object.assign(
240
+ {
241
+ customer_id: "",
242
+ subscription_id: "",
243
+ credit_grant_id: "",
244
+ source: "",
245
+ pageSize: 10,
246
+ onTableDataChange: () => {
247
+ },
248
+ showAdminColumns: false,
249
+ showTimeFilter: false,
250
+ mode: "portal"
251
+ },
252
+ rawProps
253
+ );
254
+ return /* @__PURE__ */ jsx(TransactionsTable, { ...props });
255
+ }
@@ -13,21 +13,5 @@ type Props = {
13
13
  onTableDataChange?: Function;
14
14
  relatedSubscription?: boolean;
15
15
  };
16
- declare function CustomerInvoiceList(props: Props): JSX.Element;
17
- declare namespace CustomerInvoiceList {
18
- var defaultProps: {
19
- customer_id: string;
20
- subscription_id: string;
21
- currency_id: string;
22
- include_staking: boolean;
23
- include_recovered_from: boolean;
24
- status: string;
25
- pageSize: number;
26
- target: string;
27
- action: string;
28
- type: string;
29
- onTableDataChange: () => void;
30
- relatedSubscription: boolean;
31
- };
32
- }
33
- export default CustomerInvoiceList;
16
+ export default function CustomerInvoiceList(rawProps: Props): JSX.Element;
17
+ export {};
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
3
3
  import Toast from "@arcblock/ux/lib/Toast";
4
4
  import { OpenInNewOutlined } from "@mui/icons-material";
5
- import { Box, Button, CircularProgress, Stack, Typography, Tooltip } from "@mui/material";
5
+ import { Box, Button, CircularProgress, Stack, Typography, Tooltip, Avatar } from "@mui/material";
6
6
  import { styled } from "@mui/system";
7
7
  import { useInfiniteScroll, useRequest, useSetState } from "ahooks";
8
8
  import React, { useEffect, useRef, useState } from "react";
@@ -160,6 +160,26 @@ const InvoiceTable = React.memo((props) => {
160
160
  }
161
161
  }
162
162
  },
163
+ {
164
+ label: t("common.paymentMethod"),
165
+ name: "paymentMethod",
166
+ options: {
167
+ customBodyRenderLite: (_, index) => {
168
+ const invoice = data?.list[index];
169
+ return /* @__PURE__ */ jsxs(
170
+ Typography,
171
+ {
172
+ sx: { display: "flex", alignItems: "center", whiteSpace: "nowrap" },
173
+ onClick: (e) => handleLinkClick(e, invoice),
174
+ children: [
175
+ /* @__PURE__ */ jsx(Avatar, { src: invoice.paymentMethod.logo, sx: { width: 18, height: 18, mr: 1 } }),
176
+ invoice.paymentMethod.name
177
+ ]
178
+ }
179
+ );
180
+ }
181
+ }
182
+ },
163
183
  {
164
184
  label: t("common.type"),
165
185
  name: "billing_reason",
@@ -367,9 +387,27 @@ const InvoiceList = React.memo((props) => {
367
387
  }
368
388
  if (data && data.list.length === 0) {
369
389
  if (data.subscription && ["active", "trialing"].includes(data.subscription.status)) {
370
- return /* @__PURE__ */ jsx(Typography, { color: "text.secondary", sx: { my: 0.5 }, children: t("payment.customer.invoice.next", { date: formatToDatetime(data.subscription.current_period_end * 1e3) }) });
390
+ return /* @__PURE__ */ jsx(
391
+ Typography,
392
+ {
393
+ sx: {
394
+ color: "text.secondary",
395
+ my: 0.5
396
+ },
397
+ children: t("payment.customer.invoice.next", { date: formatToDatetime(data.subscription.current_period_end * 1e3) })
398
+ }
399
+ );
371
400
  }
372
- return /* @__PURE__ */ jsx(Typography, { color: "text.secondary", sx: { my: 0.5 }, children: t("payment.customer.invoice.empty") });
401
+ return /* @__PURE__ */ jsx(
402
+ Typography,
403
+ {
404
+ sx: {
405
+ color: "text.secondary",
406
+ my: 0.5
407
+ },
408
+ children: t("payment.customer.invoice.empty")
409
+ }
410
+ );
373
411
  }
374
412
  const hasMore = data && data.list.length < data.count;
375
413
  const grouped = groupByDate(data.list);
@@ -386,75 +424,124 @@ const InvoiceList = React.memo((props) => {
386
424
  Stack,
387
425
  {
388
426
  direction: "row",
389
- sx: { my: 1 },
390
- gap: {
391
- xs: 0.5,
392
- sm: 1.5,
393
- md: 3
427
+ sx: {
428
+ gap: {
429
+ xs: 0.5,
430
+ sm: 1.5,
431
+ md: 3
432
+ },
433
+ alignItems: "center",
434
+ flexWrap: "nowrap",
435
+ my: 1
394
436
  },
395
- alignItems: "center",
396
- flexWrap: "nowrap",
397
437
  children: [
398
- /* @__PURE__ */ jsx(Box, { flex: 2, children: /* @__PURE__ */ jsx(
399
- "a",
438
+ /* @__PURE__ */ jsx(
439
+ Box,
400
440
  {
401
- href: link.url,
402
- target: link.external ? "_blank" : target,
403
- rel: "noreferrer",
404
- onClick: (e) => handleLinkClick(e, link),
405
- children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
406
- /* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }),
407
- link.external && /* @__PURE__ */ jsx(
408
- OpenInNewOutlined,
409
- {
410
- fontSize: "small",
411
- sx: {
412
- color: "text.secondary",
413
- display: { xs: "none", md: "inline-flex" }
441
+ sx: {
442
+ flex: 2
443
+ },
444
+ children: /* @__PURE__ */ jsx(
445
+ "a",
446
+ {
447
+ href: link.url,
448
+ target: link.external ? "_blank" : target,
449
+ rel: "noreferrer",
450
+ onClick: (e) => handleLinkClick(e, link),
451
+ children: /* @__PURE__ */ jsxs(
452
+ Stack,
453
+ {
454
+ direction: "row",
455
+ spacing: 0.5,
456
+ sx: {
457
+ alignItems: "center"
458
+ },
459
+ children: [
460
+ /* @__PURE__ */ jsx(Typography, { component: "span", children: invoice.number }),
461
+ link.external && /* @__PURE__ */ jsx(
462
+ OpenInNewOutlined,
463
+ {
464
+ fontSize: "small",
465
+ sx: {
466
+ color: "text.secondary",
467
+ display: { xs: "none", md: "inline-flex" }
468
+ }
469
+ }
470
+ )
471
+ ]
414
472
  }
415
- }
416
- )
473
+ )
474
+ }
475
+ )
476
+ }
477
+ ),
478
+ /* @__PURE__ */ jsx(
479
+ Box,
480
+ {
481
+ sx: {
482
+ flex: 1,
483
+ textAlign: "right"
484
+ },
485
+ children: /* @__PURE__ */ jsxs(Typography, { sx: isVoid ? { textDecoration: "line-through" } : {}, children: [
486
+ formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
487
+ "\xA0",
488
+ invoice.paymentCurrency.symbol
417
489
  ] })
418
490
  }
419
- ) }),
420
- /* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsxs(Typography, { sx: isVoid ? { textDecoration: "line-through" } : {}, children: [
421
- formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
422
- "\xA0",
423
- invoice.paymentCurrency.symbol
424
- ] }) }),
425
- /* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at, locale, "HH:mm:ss") }) }),
491
+ ),
492
+ /* @__PURE__ */ jsx(
493
+ Box,
494
+ {
495
+ sx: {
496
+ flex: 1,
497
+ textAlign: "right"
498
+ },
499
+ children: /* @__PURE__ */ jsx(Typography, { children: formatToDate(invoice.created_at, locale, "HH:mm:ss") })
500
+ }
501
+ ),
426
502
  !action && /* @__PURE__ */ jsx(
427
503
  Box,
428
504
  {
429
- flex: 2,
430
505
  className: "invoice-description",
431
- textAlign: "right",
432
- sx: { display: { xs: "none", lg: "inline-flex" } },
506
+ sx: {
507
+ flex: 2,
508
+ textAlign: "right",
509
+ display: { xs: "none", lg: "inline-flex" }
510
+ },
433
511
  children: /* @__PURE__ */ jsx(Typography, { children: invoice.description || invoice.id })
434
512
  }
435
513
  ),
436
- /* @__PURE__ */ jsx(Box, { flex: 1, textAlign: "right", children: action ? connect ? /* @__PURE__ */ jsx(
437
- Button,
438
- {
439
- variant: "contained",
440
- color: "primary",
441
- size: "small",
442
- onClick: () => onPay(invoice.id),
443
- sx: { whiteSpace: "nowrap" },
444
- children: t("payment.customer.invoice.pay")
445
- }
446
- ) : /* @__PURE__ */ jsx(
447
- Button,
514
+ /* @__PURE__ */ jsx(
515
+ Box,
448
516
  {
449
- component: "a",
450
- variant: "contained",
451
- size: "small",
452
- onClick: (e) => handleLinkClick(e, link),
453
- sx: { whiteSpace: "nowrap" },
454
- rel: "noreferrer",
455
- children: t("payment.customer.invoice.pay")
517
+ sx: {
518
+ flex: 1,
519
+ textAlign: "right"
520
+ },
521
+ children: action ? connect ? /* @__PURE__ */ jsx(
522
+ Button,
523
+ {
524
+ variant: "contained",
525
+ color: "primary",
526
+ size: "small",
527
+ onClick: () => onPay(invoice.id),
528
+ sx: { whiteSpace: "nowrap" },
529
+ children: t("payment.customer.invoice.pay")
530
+ }
531
+ ) : /* @__PURE__ */ jsx(
532
+ Button,
533
+ {
534
+ component: "a",
535
+ variant: "contained",
536
+ size: "small",
537
+ onClick: (e) => handleLinkClick(e, link),
538
+ sx: { whiteSpace: "nowrap" },
539
+ rel: "noreferrer",
540
+ children: t("payment.customer.invoice.pay")
541
+ }
542
+ ) : isVoid ? /* @__PURE__ */ jsx(Tooltip, { title: t("payment.customer.invoice.noPaymentRequired"), arrow: true, placement: "top", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) }) }) : /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) })
456
543
  }
457
- ) : isVoid ? /* @__PURE__ */ jsx(Tooltip, { title: t("payment.customer.invoice.noPaymentRequired"), arrow: true, placement: "top", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) }) }) : /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) })
544
+ )
458
545
  ]
459
546
  },
460
547
  invoice.id
@@ -463,11 +550,37 @@ const InvoiceList = React.memo((props) => {
463
550
  ] }, date)),
464
551
  /* @__PURE__ */ jsxs(Box, { children: [
465
552
  hasMore && /* @__PURE__ */ jsx(Button, { variant: "text", type: "button", color: "inherit", onClick: loadMore, disabled: loadingMore, children: loadingMore ? t("common.loadingMore", { resource: t("payment.customer.invoices") }) : t("common.loadMore", { resource: t("payment.customer.invoices") }) }),
466
- !hasMore && data.count > size && /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: t("common.noMore", { resource: t("payment.customer.invoices") }) })
553
+ !hasMore && data.count > size && /* @__PURE__ */ jsx(
554
+ Typography,
555
+ {
556
+ sx: {
557
+ color: "text.secondary"
558
+ },
559
+ children: t("common.noMore", { resource: t("payment.customer.invoices") })
560
+ }
561
+ )
467
562
  ] })
468
563
  ] });
469
564
  });
470
- export default function CustomerInvoiceList(props) {
565
+ export default function CustomerInvoiceList(rawProps) {
566
+ const props = Object.assign(
567
+ {
568
+ customer_id: "",
569
+ subscription_id: "",
570
+ currency_id: "",
571
+ include_staking: false,
572
+ include_recovered_from: false,
573
+ status: "open,paid,uncollectible",
574
+ pageSize: 10,
575
+ target: "_self",
576
+ action: "",
577
+ type: "list",
578
+ onTableDataChange: () => {
579
+ },
580
+ relatedSubscription: false
581
+ },
582
+ rawProps
583
+ );
471
584
  const { action, type } = props;
472
585
  const { t, locale } = useLocaleContext();
473
586
  const { connect } = usePaymentContext();
@@ -509,21 +622,6 @@ export default function CustomerInvoiceList(props) {
509
622
  }
510
623
  return /* @__PURE__ */ jsx(InvoiceList, { ...props, onPay });
511
624
  }
512
- CustomerInvoiceList.defaultProps = {
513
- customer_id: "",
514
- subscription_id: "",
515
- currency_id: "",
516
- include_staking: false,
517
- include_recovered_from: false,
518
- status: "open,paid,uncollectible",
519
- pageSize: 10,
520
- target: "_self",
521
- action: "",
522
- type: "list",
523
- onTableDataChange: () => {
524
- },
525
- relatedSubscription: false
526
- };
527
625
  const Root = styled(Stack)`
528
626
  @media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
529
627
  svg.MuiSvgIcon-root {