@blocklet/payment-react 1.14.21 → 1.14.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/es/checkout/donate.d.ts +4 -2
- package/es/checkout/donate.js +13 -10
- package/es/checkout/form.d.ts +1 -1
- package/es/checkout/form.js +50 -4
- package/es/checkout/table.d.ts +1 -1
- package/es/checkout/table.js +11 -1
- package/es/components/blockchain/tx.js +2 -1
- package/es/components/country-select.d.ts +16 -0
- package/es/components/country-select.js +82 -0
- package/es/components/input.d.ts +21 -21
- package/es/components/input.js +43 -42
- package/es/components/livemode.js +1 -0
- package/es/components/pricing-table.js +0 -2
- package/es/components/status.js +2 -3
- package/es/components/table.d.ts +2 -0
- package/es/components/table.js +186 -0
- package/es/contexts/payment.d.ts +2 -0
- package/es/contexts/payment.js +5 -2
- package/es/history/invoice/list.d.ts +3 -1
- package/es/history/invoice/list.js +215 -48
- package/es/hooks/mobile.d.ts +4 -0
- package/es/hooks/mobile.js +10 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +7 -1
- package/es/libs/util.d.ts +21 -8
- package/es/libs/util.js +92 -28
- package/es/locales/en.js +22 -7
- package/es/locales/index.d.ts +0 -1
- package/es/locales/index.js +10 -1
- package/es/locales/zh.js +21 -6
- package/es/payment/error.js +2 -2
- package/es/payment/footer.js +1 -1
- package/es/payment/form/address.d.ts +9 -2
- package/es/payment/form/address.js +69 -69
- package/es/payment/form/currency.js +39 -25
- package/es/payment/form/index.d.ts +1 -1
- package/es/payment/form/index.js +83 -81
- package/es/payment/form/phone.js +15 -51
- package/es/payment/index.d.ts +3 -10
- package/es/payment/index.js +295 -224
- package/es/payment/product-card.js +4 -4
- package/es/payment/product-donation.js +9 -3
- package/es/payment/product-item.d.ts +2 -2
- package/es/payment/product-item.js +120 -81
- package/es/payment/summary.js +188 -118
- package/es/theme/index.css +240 -0
- package/es/theme/index.d.ts +14 -0
- package/es/theme/index.js +256 -0
- package/es/theme/typography.d.ts +2 -0
- package/es/theme/typography.js +53 -0
- package/es/types/index.d.ts +16 -0
- package/lib/checkout/donate.d.ts +4 -2
- package/lib/checkout/donate.js +23 -2
- package/lib/checkout/form.d.ts +1 -1
- package/lib/checkout/form.js +60 -15
- package/lib/checkout/table.d.ts +1 -1
- package/lib/checkout/table.js +22 -1
- package/lib/components/blockchain/tx.js +4 -1
- package/lib/components/country-select.d.ts +16 -0
- package/lib/components/country-select.js +115 -0
- package/lib/components/input.d.ts +21 -21
- package/lib/components/input.js +21 -12
- package/lib/components/livemode.js +1 -0
- package/lib/components/pricing-table.js +0 -2
- package/lib/components/status.js +2 -3
- package/lib/components/table.d.ts +2 -0
- package/lib/components/table.js +220 -0
- package/lib/contexts/payment.d.ts +2 -0
- package/lib/contexts/payment.js +4 -1
- package/lib/history/invoice/list.d.ts +3 -1
- package/lib/history/invoice/list.js +290 -62
- package/lib/hooks/mobile.d.ts +4 -0
- package/lib/hooks/mobile.js +17 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +36 -0
- package/lib/libs/util.d.ts +21 -8
- package/lib/libs/util.js +115 -37
- package/lib/locales/en.js +22 -7
- package/lib/locales/index.d.ts +0 -1
- package/lib/locales/index.js +14 -3
- package/lib/locales/zh.js +21 -6
- package/lib/payment/error.js +5 -1
- package/lib/payment/footer.js +1 -1
- package/lib/payment/form/address.d.ts +9 -2
- package/lib/payment/form/address.js +67 -59
- package/lib/payment/form/currency.js +31 -24
- package/lib/payment/form/index.d.ts +1 -1
- package/lib/payment/form/index.js +92 -93
- package/lib/payment/form/phone.js +11 -59
- package/lib/payment/index.d.ts +3 -10
- package/lib/payment/index.js +302 -225
- package/lib/payment/product-card.js +5 -4
- package/lib/payment/product-donation.js +11 -7
- package/lib/payment/product-item.d.ts +2 -2
- package/lib/payment/product-item.js +38 -19
- package/lib/payment/summary.js +219 -127
- package/lib/theme/index.css +240 -0
- package/lib/theme/index.d.ts +14 -0
- package/lib/theme/index.js +273 -0
- package/lib/theme/typography.d.ts +2 -0
- package/lib/theme/typography.js +59 -0
- package/lib/types/index.d.ts +16 -0
- package/package.json +14 -11
- package/src/checkout/donate.tsx +25 -11
- package/src/checkout/form.tsx +63 -15
- package/src/checkout/table.tsx +20 -1
- package/src/components/blockchain/tx.tsx +2 -1
- package/src/components/country-select.tsx +93 -0
- package/src/components/input.tsx +49 -46
- package/src/components/livemode.tsx +1 -0
- package/src/components/pricing-table.tsx +0 -2
- package/src/components/status.tsx +1 -2
- package/src/components/table.tsx +200 -0
- package/src/contexts/payment.tsx +6 -1
- package/src/history/invoice/list.tsx +254 -49
- package/src/hooks/mobile.ts +13 -0
- package/src/index.ts +7 -0
- package/src/libs/util.ts +120 -31
- package/src/locales/en.tsx +18 -4
- package/src/locales/index.tsx +10 -3
- package/src/locales/zh.tsx +17 -3
- package/src/payment/error.tsx +2 -2
- package/src/payment/footer.tsx +1 -1
- package/src/payment/form/address.tsx +56 -47
- package/src/payment/form/currency.tsx +29 -23
- package/src/payment/form/index.tsx +89 -76
- package/src/payment/form/phone.tsx +14 -51
- package/src/payment/index.tsx +298 -231
- package/src/payment/product-card.tsx +4 -4
- package/src/payment/product-donation.tsx +9 -4
- package/src/payment/product-item.tsx +49 -20
- package/src/payment/summary.tsx +191 -108
- package/src/theme/index.css +240 -0
- package/src/theme/index.tsx +271 -0
- package/src/theme/typography.ts +56 -0
- package/src/types/index.ts +17 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import Empty from "@arcblock/ux/lib/Empty";
|
|
4
|
+
import Datatable from "@arcblock/ux/lib/Datatable";
|
|
5
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
+
import { styled } from "@mui/system";
|
|
7
|
+
import { useMobile } from "../hooks/mobile.js";
|
|
8
|
+
function EmptyStub() {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const Table = React.memo(
|
|
12
|
+
({ options, columns, toolbar = true, footer = true, hasRowLink = false, emptyNodeText = "", ...rest }) => {
|
|
13
|
+
const { locale, t } = useLocaleContext();
|
|
14
|
+
const { isMobile } = useMobile();
|
|
15
|
+
const defaultOptions = {
|
|
16
|
+
print: false,
|
|
17
|
+
download: false,
|
|
18
|
+
filter: false,
|
|
19
|
+
selectableRows: "none",
|
|
20
|
+
rowsPerPage: 10,
|
|
21
|
+
rowsPerPageOptions: [10, 20, 50, 100],
|
|
22
|
+
searchDebounceTime: 300,
|
|
23
|
+
tableBodyHeight: "100%",
|
|
24
|
+
loading: true
|
|
25
|
+
};
|
|
26
|
+
const components = {};
|
|
27
|
+
if (!toolbar) {
|
|
28
|
+
components.TableToolbar = EmptyStub;
|
|
29
|
+
}
|
|
30
|
+
if (!footer) {
|
|
31
|
+
components.TableFooter = EmptyStub;
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
Wrapped,
|
|
35
|
+
{
|
|
36
|
+
locale,
|
|
37
|
+
options: { ...defaultOptions, ...options },
|
|
38
|
+
columns: columns.map((x) => {
|
|
39
|
+
x.options = x.options || {};
|
|
40
|
+
x.options.filter = x.options.filter || false;
|
|
41
|
+
x.options.sort = x.options.sort || false;
|
|
42
|
+
return x;
|
|
43
|
+
}),
|
|
44
|
+
emptyNode: /* @__PURE__ */ jsx(Empty, { children: emptyNodeText || t("empty.records") }),
|
|
45
|
+
...rest,
|
|
46
|
+
components,
|
|
47
|
+
hasRowLink,
|
|
48
|
+
isMobile
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
const Wrapped = styled(Datatable)`
|
|
54
|
+
${(props) => props.hasRowLink ? `.MuiTableCell-root {
|
|
55
|
+
font-size: 1rem !important;
|
|
56
|
+
}` : ""}
|
|
57
|
+
.MuiPaper-root {
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|
|
61
|
+
table.MuiTable-root {
|
|
62
|
+
outline: 1px solid var(--stroke-border-base, #eff1f5);
|
|
63
|
+
border-radius: var(--radius-m, 8px);
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
}
|
|
66
|
+
[class*='MUIDataTable-responsiveBase'] {
|
|
67
|
+
outline: 1px solid var(--stroke-border-base, #eff1f5);
|
|
68
|
+
border-radius: var(--radius-m, 8px);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
th.MuiTableCell-head {
|
|
72
|
+
padding: 8px 16px 8px 16px;
|
|
73
|
+
text-transform: inherit;
|
|
74
|
+
background: var(--backgrounds-bg-subtle, #f9fafb);
|
|
75
|
+
border-bottom: none;
|
|
76
|
+
&:first-of-type {
|
|
77
|
+
border-top-left-radius: 8px;
|
|
78
|
+
padding-left: 20px;
|
|
79
|
+
}
|
|
80
|
+
&:last-of-type {
|
|
81
|
+
border-top-right-radius: 8px;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
tr.MuiTableRow-root:not(.MuiTableRow-footer):hover {
|
|
86
|
+
background: #f5f5f5;
|
|
87
|
+
}
|
|
88
|
+
tr.MuiTableRow-root:last-of-type td:first-of-type {
|
|
89
|
+
border-bottom-left-radius: 8px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
tr.MuiTableRow-root:last-of-type td:last-of-type {
|
|
93
|
+
border-bottom-right-radius: 8px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
tr.MuiTableRow-root:nth-of-type(even) {
|
|
97
|
+
background: var(--backgrounds-bg-subtle, #f9fafb);
|
|
98
|
+
}
|
|
99
|
+
td.MuiTableCell-root {
|
|
100
|
+
border-bottom: none;
|
|
101
|
+
&:first-of-type {
|
|
102
|
+
padding-left: 20px;
|
|
103
|
+
}
|
|
104
|
+
&.MuiTableCell-footer {
|
|
105
|
+
border: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.datatable-footer {
|
|
110
|
+
.MuiTableRow-root.MuiTableRow-footer {
|
|
111
|
+
border: none;
|
|
112
|
+
}
|
|
113
|
+
table.MuiTable-root {
|
|
114
|
+
outline: none;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
}
|
|
117
|
+
.MuiTablePagination-input {
|
|
118
|
+
background: none;
|
|
119
|
+
}
|
|
120
|
+
div.MuiSelect-select {
|
|
121
|
+
padding: 0 24px 0 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
th a,
|
|
126
|
+
td a {
|
|
127
|
+
text-decoration: none;
|
|
128
|
+
display: block;
|
|
129
|
+
color: inherit;
|
|
130
|
+
&:first-of-type {
|
|
131
|
+
padding-left: 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
> div {
|
|
136
|
+
overflow: auto;
|
|
137
|
+
}
|
|
138
|
+
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
139
|
+
th a,
|
|
140
|
+
td a {
|
|
141
|
+
text-decoration: none;
|
|
142
|
+
display: block;
|
|
143
|
+
color: inherit;
|
|
144
|
+
padding-top: 0;
|
|
145
|
+
padding-bottom: 0;
|
|
146
|
+
padding-right: 0;
|
|
147
|
+
}
|
|
148
|
+
tr.MuiTableRow-root {
|
|
149
|
+
border: none;
|
|
150
|
+
padding: 20px;
|
|
151
|
+
display: block;
|
|
152
|
+
}
|
|
153
|
+
td.MuiTableCell-root:first-of-type {
|
|
154
|
+
padding-left: 0;
|
|
155
|
+
margin-top: 0;
|
|
156
|
+
}
|
|
157
|
+
td.MuiTableCell-root {
|
|
158
|
+
margin: 0;
|
|
159
|
+
margin-top: 8px;
|
|
160
|
+
align-items: center;
|
|
161
|
+
padding: 0;
|
|
162
|
+
flex-wrap: wrap;
|
|
163
|
+
flex-direction: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection || "row"};
|
|
164
|
+
align-items: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "column" ? "flex-start" : "center"};
|
|
165
|
+
justify-content: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "column" ? "flex-start" : "space-between"};
|
|
166
|
+
}
|
|
167
|
+
td.MuiTableCell-root > div {
|
|
168
|
+
margin-bottom: 4px;
|
|
169
|
+
}
|
|
170
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
171
|
+
display: flex;
|
|
172
|
+
flex-direction: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection || "row"};
|
|
173
|
+
align-items: flex-start;
|
|
174
|
+
justify-content: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "row" ? "space-between" : "flex-start"};
|
|
175
|
+
flex-wrap: ${({ mobileTDFlexDirection = "column" }) => mobileTDFlexDirection === "row" ? "nowrap" : "wrap"};
|
|
176
|
+
word-break: break-all;
|
|
177
|
+
&.datatables-noprint {
|
|
178
|
+
justify-content: center;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
[class*='MUIDataTable-responsiveBase'] tr:not([class*='responsiveSimple']) td.MuiTableCell-body > div {
|
|
182
|
+
width: inherit;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
export default Table;
|
package/es/contexts/payment.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export type PaymentContextType = {
|
|
|
18
18
|
getMethod: (methodId: string) => TPaymentMethodExpanded | undefined;
|
|
19
19
|
setLivemode: (livemode: boolean) => void;
|
|
20
20
|
api: Axios;
|
|
21
|
+
payable: boolean;
|
|
22
|
+
setPayable: (status: boolean) => void;
|
|
21
23
|
};
|
|
22
24
|
export type PaymentContextProps = {
|
|
23
25
|
session: import('@arcblock/did-connect/lib/types').SessionContext['session'];
|
package/es/contexts/payment.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Alert } from "@mui/material";
|
|
3
3
|
import { useLocalStorageState, useRequest } from "ahooks";
|
|
4
|
-
import { createContext, useContext } from "react";
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
5
|
import api from "../libs/api.js";
|
|
6
6
|
import { getPrefix } from "../libs/util.js";
|
|
7
7
|
const PaymentContext = createContext({ api });
|
|
@@ -24,6 +24,7 @@ function PaymentProvider({ session, connect, children, baseUrl }) {
|
|
|
24
24
|
const { data, error, run, loading } = useRequest(getSettings);
|
|
25
25
|
const [livemode, setLivemode] = useLocalStorageState("livemode", { defaultValue: true });
|
|
26
26
|
const prefix = getPrefix();
|
|
27
|
+
const [payable, setPayable] = useState(true);
|
|
27
28
|
if (error) {
|
|
28
29
|
return /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message });
|
|
29
30
|
}
|
|
@@ -43,7 +44,9 @@ function PaymentProvider({ session, connect, children, baseUrl }) {
|
|
|
43
44
|
getMethod: (methodId) => getMethod(methodId, data.paymentMethods),
|
|
44
45
|
refresh: run,
|
|
45
46
|
setLivemode,
|
|
46
|
-
api
|
|
47
|
+
api,
|
|
48
|
+
payable,
|
|
49
|
+
setPayable
|
|
47
50
|
},
|
|
48
51
|
children
|
|
49
52
|
}
|
|
@@ -9,8 +9,9 @@ type Props = {
|
|
|
9
9
|
pageSize?: number;
|
|
10
10
|
target?: string;
|
|
11
11
|
action?: string;
|
|
12
|
+
type?: 'list' | 'table';
|
|
12
13
|
};
|
|
13
|
-
declare function CustomerInvoiceList(
|
|
14
|
+
declare function CustomerInvoiceList(props: Props): JSX.Element;
|
|
14
15
|
declare namespace CustomerInvoiceList {
|
|
15
16
|
var defaultProps: {
|
|
16
17
|
customer_id: string;
|
|
@@ -22,6 +23,7 @@ declare namespace CustomerInvoiceList {
|
|
|
22
23
|
pageSize: number;
|
|
23
24
|
target: string;
|
|
24
25
|
action: string;
|
|
26
|
+
type: string;
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
export default CustomerInvoiceList;
|
|
@@ -4,8 +4,8 @@ import Toast from "@arcblock/ux/lib/Toast";
|
|
|
4
4
|
import { OpenInNewOutlined } from "@mui/icons-material";
|
|
5
5
|
import { Box, Button, CircularProgress, Hidden, Stack, Typography } from "@mui/material";
|
|
6
6
|
import { styled } from "@mui/system";
|
|
7
|
-
import { useInfiniteScroll, useSetState } from "ahooks";
|
|
8
|
-
import { useEffect } from "react";
|
|
7
|
+
import { useInfiniteScroll, useRequest, useSetState } from "ahooks";
|
|
8
|
+
import React, { useEffect, useState } from "react";
|
|
9
9
|
import { joinURL } from "ufo";
|
|
10
10
|
import Status from "../../components/status.js";
|
|
11
11
|
import { usePaymentContext } from "../../contexts/payment.js";
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getPrefix,
|
|
21
21
|
getTxLink
|
|
22
22
|
} from "../../libs/util.js";
|
|
23
|
+
import Table from "../../components/table.js";
|
|
23
24
|
const groupByDate = (items) => {
|
|
24
25
|
const grouped = {};
|
|
25
26
|
items.forEach((item) => {
|
|
@@ -57,22 +58,178 @@ const getInvoiceLink = (invoice, action) => {
|
|
|
57
58
|
url: getTxLink(invoice.paymentMethod, invoice.metadata?.payment_details).link
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
const InvoiceTable = React.memo((props) => {
|
|
62
|
+
const {
|
|
63
|
+
pageSize,
|
|
64
|
+
target,
|
|
65
|
+
action,
|
|
66
|
+
onPay,
|
|
67
|
+
status,
|
|
68
|
+
customer_id,
|
|
69
|
+
currency_id,
|
|
70
|
+
subscription_id,
|
|
71
|
+
include_staking,
|
|
72
|
+
include_recovered_from
|
|
73
|
+
} = props;
|
|
74
|
+
const listKey = "invoice-table";
|
|
75
|
+
const { t, locale } = useLocaleContext();
|
|
76
|
+
const [search, setSearch] = useState({
|
|
77
|
+
pageSize: pageSize || 10,
|
|
78
|
+
page: 1
|
|
79
|
+
});
|
|
80
|
+
const { loading, data = { list: [], count: 0 } } = useRequest(
|
|
81
|
+
() => fetchData({
|
|
82
|
+
...search,
|
|
83
|
+
status,
|
|
84
|
+
customer_id,
|
|
85
|
+
currency_id,
|
|
86
|
+
subscription_id,
|
|
87
|
+
include_staking,
|
|
88
|
+
include_recovered_from,
|
|
89
|
+
ignore_zero: true
|
|
90
|
+
}),
|
|
91
|
+
{
|
|
92
|
+
refreshDeps: [search]
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
const columns = [
|
|
96
|
+
{
|
|
97
|
+
label: t("payment.customer.invoice.invoiceNumber"),
|
|
98
|
+
name: "number",
|
|
99
|
+
options: {
|
|
100
|
+
customBodyRenderLite: (_, index) => {
|
|
101
|
+
const invoice = data?.list[index];
|
|
102
|
+
const link = getInvoiceLink(invoice, action);
|
|
103
|
+
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: invoice?.number });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: t("common.amount"),
|
|
109
|
+
name: "total",
|
|
110
|
+
options: {
|
|
111
|
+
customBodyRenderLite: (_, index) => {
|
|
112
|
+
const invoice = data?.list[index];
|
|
113
|
+
const link = getInvoiceLink(invoice, action);
|
|
114
|
+
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: /* @__PURE__ */ jsxs(Typography, { children: [
|
|
115
|
+
formatBNStr(invoice.total, invoice.paymentCurrency.decimal),
|
|
116
|
+
"\xA0",
|
|
117
|
+
invoice.paymentCurrency.symbol
|
|
118
|
+
] }) });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: t("common.updatedAt"),
|
|
124
|
+
name: "name",
|
|
125
|
+
options: {
|
|
126
|
+
customBodyRenderLite: (val, index) => {
|
|
127
|
+
const invoice = data?.list[index];
|
|
128
|
+
const link = getInvoiceLink(invoice, action);
|
|
129
|
+
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: formatToDate(invoice.created_at, locale, "YYYY-MM-DD HH:mm:ss") });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: t("common.description"),
|
|
135
|
+
name: "",
|
|
136
|
+
options: {
|
|
137
|
+
sort: false,
|
|
138
|
+
customBodyRenderLite: (val, index) => {
|
|
139
|
+
const invoice = data?.list[index];
|
|
140
|
+
const link = getInvoiceLink(invoice, action);
|
|
141
|
+
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: invoice.description || invoice.id });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: t("common.status"),
|
|
147
|
+
name: "created_at",
|
|
148
|
+
options: {
|
|
149
|
+
sort: true,
|
|
150
|
+
customBodyRenderLite: (val, index) => {
|
|
151
|
+
const invoice = data?.list[index];
|
|
152
|
+
const link = getInvoiceLink(invoice, action);
|
|
153
|
+
if (action) {
|
|
154
|
+
return link.connect ? /* @__PURE__ */ jsx(Button, { variant: "text", size: "small", onClick: () => onPay(invoice.id), sx: { color: "text.link" }, children: t("payment.customer.invoice.pay") }) : /* @__PURE__ */ jsx(
|
|
155
|
+
Button,
|
|
156
|
+
{
|
|
157
|
+
component: "a",
|
|
158
|
+
variant: "text",
|
|
159
|
+
size: "small",
|
|
160
|
+
href: link.url,
|
|
161
|
+
target: link.external ? "_blank" : target,
|
|
162
|
+
sx: { color: "var(--foregrounds-fg-interactive, #0086FF) !important" },
|
|
163
|
+
rel: "noreferrer",
|
|
164
|
+
children: t("payment.customer.invoice.pay")
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return /* @__PURE__ */ jsx("a", { href: link.url, target: link.external ? "_blank" : target, rel: "noreferrer", children: /* @__PURE__ */ jsx(Status, { label: invoice.status, color: getInvoiceStatusColor(invoice.status) }) });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
const onTableChange = ({ page, rowsPerPage }) => {
|
|
174
|
+
if (search.pageSize !== rowsPerPage) {
|
|
175
|
+
setSearch((x) => ({ ...x, pageSize: rowsPerPage, page: 1 }));
|
|
176
|
+
} else if (search.page !== page + 1) {
|
|
177
|
+
setSearch((x) => ({ ...x, page: page + 1 }));
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
return /* @__PURE__ */ jsx(InvoiceTableRoot, { children: /* @__PURE__ */ jsx(
|
|
181
|
+
Table,
|
|
182
|
+
{
|
|
183
|
+
hasRowLink: true,
|
|
184
|
+
durable: `__${listKey}__`,
|
|
185
|
+
durableKeys: ["page", "rowsPerPage", "searchText"],
|
|
186
|
+
data: data.list,
|
|
187
|
+
columns,
|
|
188
|
+
options: {
|
|
189
|
+
count: data.count,
|
|
190
|
+
page: search.page - 1,
|
|
191
|
+
rowsPerPage: search.pageSize
|
|
192
|
+
},
|
|
193
|
+
loading,
|
|
194
|
+
onChange: onTableChange,
|
|
195
|
+
toolbar: false,
|
|
196
|
+
sx: { mt: 2 },
|
|
197
|
+
showMobile: false,
|
|
198
|
+
mobileTDFlexDirection: "row",
|
|
199
|
+
emptyNodeText: t("payment.customer.invoice.emptyList")
|
|
200
|
+
}
|
|
201
|
+
) });
|
|
202
|
+
});
|
|
203
|
+
const InvoiceTableRoot = styled(Box)`
|
|
204
|
+
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
205
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
206
|
+
> div {
|
|
207
|
+
width: fit-content;
|
|
208
|
+
flex: inherit;
|
|
209
|
+
font-size: 14px;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
.invoice-summary {
|
|
213
|
+
padding-right: 20px;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
`;
|
|
217
|
+
const InvoiceList = React.memo((props) => {
|
|
218
|
+
const {
|
|
219
|
+
customer_id,
|
|
220
|
+
subscription_id,
|
|
221
|
+
include_recovered_from,
|
|
222
|
+
currency_id,
|
|
223
|
+
include_staking,
|
|
224
|
+
status,
|
|
225
|
+
pageSize,
|
|
226
|
+
target,
|
|
227
|
+
action,
|
|
228
|
+
onPay
|
|
229
|
+
} = props;
|
|
71
230
|
const size = pageSize || 10;
|
|
72
231
|
const subscription = useSubscription("events");
|
|
73
232
|
const { t, locale } = useLocaleContext();
|
|
74
|
-
const { connect } = usePaymentContext();
|
|
75
|
-
const [state, setState] = useSetState({ paying: "" });
|
|
76
233
|
const { data, loadMore, loadingMore, loading, reloadAsync } = useInfiniteScroll(
|
|
77
234
|
(d) => {
|
|
78
235
|
const page = d ? Math.ceil(d.list.length / size) + 1 : 1;
|
|
@@ -101,36 +258,6 @@ export default function CustomerInvoiceList({
|
|
|
101
258
|
});
|
|
102
259
|
}
|
|
103
260
|
}, [subscription]);
|
|
104
|
-
const onPay = (invoiceId) => {
|
|
105
|
-
if (state.paying) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
setState({ paying: invoiceId });
|
|
109
|
-
connect.open({
|
|
110
|
-
action: "collect",
|
|
111
|
-
saveConnect: false,
|
|
112
|
-
messages: {
|
|
113
|
-
scan: "",
|
|
114
|
-
title: t(`payment.customer.invoice.${action || "pay"}`),
|
|
115
|
-
success: t(`payment.customer.invoice.${action || "pay"}Success`),
|
|
116
|
-
error: t(`payment.customer.invoice.${action || "pay"}Error`),
|
|
117
|
-
confirm: ""
|
|
118
|
-
},
|
|
119
|
-
extraParams: { invoiceId, action },
|
|
120
|
-
onSuccess: () => {
|
|
121
|
-
connect.close();
|
|
122
|
-
setState({ paying: "" });
|
|
123
|
-
},
|
|
124
|
-
onClose: () => {
|
|
125
|
-
connect.close();
|
|
126
|
-
setState({ paying: "" });
|
|
127
|
-
},
|
|
128
|
-
onError: (err) => {
|
|
129
|
-
setState({ paying: "" });
|
|
130
|
-
Toast.error(formatError(err));
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
261
|
if (loading || !data) {
|
|
135
262
|
return /* @__PURE__ */ jsx(CircularProgress, {});
|
|
136
263
|
}
|
|
@@ -176,7 +303,6 @@ export default function CustomerInvoiceList({
|
|
|
176
303
|
{
|
|
177
304
|
component: "a",
|
|
178
305
|
variant: "contained",
|
|
179
|
-
color: "primary",
|
|
180
306
|
size: "small",
|
|
181
307
|
href: link.url,
|
|
182
308
|
target: link.external ? "_blank" : target,
|
|
@@ -195,6 +321,46 @@ export default function CustomerInvoiceList({
|
|
|
195
321
|
!hasMore && data.count > size && /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: t("common.noMore", { resource: t("payment.customer.invoices") }) })
|
|
196
322
|
] })
|
|
197
323
|
] });
|
|
324
|
+
});
|
|
325
|
+
export default function CustomerInvoiceList(props) {
|
|
326
|
+
const { action, type } = props;
|
|
327
|
+
const { t } = useLocaleContext();
|
|
328
|
+
const { connect } = usePaymentContext();
|
|
329
|
+
const [state, setState] = useSetState({ paying: "" });
|
|
330
|
+
const onPay = (invoiceId) => {
|
|
331
|
+
if (state.paying) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
setState({ paying: invoiceId });
|
|
335
|
+
connect.open({
|
|
336
|
+
action: "collect",
|
|
337
|
+
saveConnect: false,
|
|
338
|
+
messages: {
|
|
339
|
+
scan: "",
|
|
340
|
+
title: t(`payment.customer.invoice.${action || "pay"}`),
|
|
341
|
+
success: t(`payment.customer.invoice.${action || "pay"}Success`),
|
|
342
|
+
error: t(`payment.customer.invoice.${action || "pay"}Error`),
|
|
343
|
+
confirm: ""
|
|
344
|
+
},
|
|
345
|
+
extraParams: { invoiceId, action },
|
|
346
|
+
onSuccess: () => {
|
|
347
|
+
connect.close();
|
|
348
|
+
setState({ paying: "" });
|
|
349
|
+
},
|
|
350
|
+
onClose: () => {
|
|
351
|
+
connect.close();
|
|
352
|
+
setState({ paying: "" });
|
|
353
|
+
},
|
|
354
|
+
onError: (err) => {
|
|
355
|
+
setState({ paying: "" });
|
|
356
|
+
Toast.error(formatError(err));
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
if (type === "table") {
|
|
361
|
+
return /* @__PURE__ */ jsx(InvoiceTable, { ...props, onPay });
|
|
362
|
+
}
|
|
363
|
+
return /* @__PURE__ */ jsx(InvoiceList, { ...props, onPay });
|
|
198
364
|
}
|
|
199
365
|
CustomerInvoiceList.defaultProps = {
|
|
200
366
|
customer_id: "",
|
|
@@ -205,10 +371,11 @@ CustomerInvoiceList.defaultProps = {
|
|
|
205
371
|
status: "open,paid,uncollectible",
|
|
206
372
|
pageSize: 10,
|
|
207
373
|
target: "_self",
|
|
208
|
-
action: ""
|
|
374
|
+
action: "",
|
|
375
|
+
type: "list"
|
|
209
376
|
};
|
|
210
377
|
const Root = styled(Stack)`
|
|
211
|
-
@media (max-width:
|
|
378
|
+
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
212
379
|
.invoice-description {
|
|
213
380
|
display: none !important;
|
|
214
381
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useTheme } from "@mui/material/styles";
|
|
2
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
3
|
+
const MOBILE_POINT = "md";
|
|
4
|
+
export function useMobile(mobilePoint = MOBILE_POINT) {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
return {
|
|
7
|
+
isMobile: useMediaQuery(theme.breakpoints.down(mobilePoint)),
|
|
8
|
+
mobileSize: `${theme.breakpoints.values[mobilePoint]}px`
|
|
9
|
+
};
|
|
10
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import ConfirmDialog from './components/confirm';
|
|
|
7
7
|
import FormInput from './components/input';
|
|
8
8
|
import Livemode from './components/livemode';
|
|
9
9
|
import PricingTable from './components/pricing-table';
|
|
10
|
+
import Table from './components/table';
|
|
10
11
|
import SafeGuard from './components/safe-guard';
|
|
11
12
|
import Status from './components/status';
|
|
12
13
|
import Switch from './components/switch-button';
|
|
@@ -23,9 +24,12 @@ import Payment from './payment/index';
|
|
|
23
24
|
import ProductSkeleton from './payment/product-skeleton';
|
|
24
25
|
import PaymentSummary from './payment/summary';
|
|
25
26
|
import PricingItem from './components/pricing-item';
|
|
27
|
+
import CountrySelect from './components/country-select';
|
|
28
|
+
export { PaymentThemeProvider } from './theme';
|
|
26
29
|
export * from './libs/util';
|
|
27
30
|
export * from './libs/connect';
|
|
28
31
|
export * from './contexts/payment';
|
|
29
32
|
export * from './hooks/subscription';
|
|
33
|
+
export * from './hooks/mobile';
|
|
30
34
|
export { translations, createTranslator } from './locales';
|
|
31
|
-
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, };
|
|
35
|
+
export { api, dayjs, FormInput, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, };
|
package/es/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import ConfirmDialog from "./components/confirm.js";
|
|
|
7
7
|
import FormInput from "./components/input.js";
|
|
8
8
|
import Livemode from "./components/livemode.js";
|
|
9
9
|
import PricingTable from "./components/pricing-table.js";
|
|
10
|
+
import Table from "./components/table.js";
|
|
10
11
|
import SafeGuard from "./components/safe-guard.js";
|
|
11
12
|
import Status from "./components/status.js";
|
|
12
13
|
import Switch from "./components/switch-button.js";
|
|
@@ -23,10 +24,13 @@ import Payment from "./payment/index.js";
|
|
|
23
24
|
import ProductSkeleton from "./payment/product-skeleton.js";
|
|
24
25
|
import PaymentSummary from "./payment/summary.js";
|
|
25
26
|
import PricingItem from "./components/pricing-item.js";
|
|
27
|
+
import CountrySelect from "./components/country-select.js";
|
|
28
|
+
export { PaymentThemeProvider } from "./theme/index.js";
|
|
26
29
|
export * from "./libs/util.js";
|
|
27
30
|
export * from "./libs/connect.js";
|
|
28
31
|
export * from "./contexts/payment.js";
|
|
29
32
|
export * from "./hooks/subscription.js";
|
|
33
|
+
export * from "./hooks/mobile.js";
|
|
30
34
|
export { translations, createTranslator } from "./locales/index.js";
|
|
31
35
|
export {
|
|
32
36
|
api,
|
|
@@ -53,5 +57,7 @@ export {
|
|
|
53
57
|
TxLink,
|
|
54
58
|
TxGas,
|
|
55
59
|
SafeGuard,
|
|
56
|
-
PricingItem
|
|
60
|
+
PricingItem,
|
|
61
|
+
CountrySelect,
|
|
62
|
+
Table
|
|
57
63
|
};
|