@blocklet/payment-react 1.13.124 → 1.13.126
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/es/api.js +0 -1
- package/es/components/confirm.d.ts +14 -0
- package/es/components/confirm.js +31 -0
- package/es/components/pricing-table.js +14 -5
- package/es/index.d.ts +4 -1
- package/es/index.js +7 -1
- package/es/locales/en.js +5 -1
- package/es/locales/zh.js +4 -0
- package/es/payment/index.js +3 -3
- package/es/portal/invoice/list.d.ts +6 -0
- package/es/portal/invoice/list.js +84 -0
- package/es/portal/payment/list.d.ts +6 -0
- package/es/portal/payment/list.js +84 -0
- package/es/util.d.ts +4 -0
- package/es/util.js +56 -0
- package/lib/api.js +0 -1
- package/lib/components/confirm.d.ts +14 -0
- package/lib/components/confirm.js +49 -0
- package/lib/components/pricing-table.js +144 -135
- package/lib/index.d.ts +4 -1
- package/lib/index.js +24 -0
- package/lib/locales/en.js +5 -1
- package/lib/locales/zh.js +4 -0
- package/lib/payment/index.js +3 -3
- package/lib/portal/invoice/list.d.ts +6 -0
- package/lib/portal/invoice/list.js +150 -0
- package/lib/portal/payment/list.d.ts +6 -0
- package/lib/portal/payment/list.js +149 -0
- package/lib/util.d.ts +4 -0
- package/lib/util.js +62 -1
- package/package.json +3 -3
- package/src/api.ts +1 -1
- package/src/components/confirm.tsx +39 -0
- package/src/components/pricing-table.tsx +124 -113
- package/src/index.ts +6 -0
- package/src/locales/en.tsx +5 -1
- package/src/locales/zh.tsx +4 -0
- package/src/payment/index.tsx +3 -3
- package/src/portal/invoice/list.tsx +122 -0
- package/src/portal/payment/list.tsx +120 -0
- package/src/util.ts +60 -0
|
@@ -10,6 +10,7 @@ var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
|
10
10
|
var _iconsMaterial = require("@mui/icons-material");
|
|
11
11
|
var _lab = require("@mui/lab");
|
|
12
12
|
var _material = require("@mui/material");
|
|
13
|
+
var _system = require("@mui/system");
|
|
13
14
|
var _ahooks = require("ahooks");
|
|
14
15
|
var _react = require("react");
|
|
15
16
|
var _amount = _interopRequireDefault(require("../payment/amount"));
|
|
@@ -78,151 +79,159 @@ function PricingTable({
|
|
|
78
79
|
_Toast.default.error((0, _util.formatError)(err));
|
|
79
80
|
}
|
|
80
81
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
sm: 2
|
|
88
|
-
},
|
|
89
|
-
gap: {
|
|
90
|
-
xs: 3,
|
|
91
|
-
sm: mode === "select" ? 3 : 5
|
|
82
|
+
const Root = (0, _system.styled)(_material.Box)`
|
|
83
|
+
@media (max-width: ${({
|
|
84
|
+
theme
|
|
85
|
+
}) => theme.breakpoints.values.sm}px) {
|
|
86
|
+
.price-table-item {
|
|
87
|
+
width: 90% !important;
|
|
92
88
|
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Root, {
|
|
92
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
93
|
+
direction: "column",
|
|
94
|
+
alignItems: alignItems === "center" ? "center" : "flex-start",
|
|
95
|
+
sx: {
|
|
96
|
+
pt: {
|
|
97
|
+
xs: 4,
|
|
98
|
+
sm: 2
|
|
99
|
+
},
|
|
100
|
+
gap: {
|
|
101
|
+
xs: 3,
|
|
102
|
+
sm: mode === "select" ? 3 : 5
|
|
102
103
|
}
|
|
103
104
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
value:
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
children: [Object.keys(recurring).length > 1 && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ToggleButtonGroup, {
|
|
106
|
+
color: "primary",
|
|
107
|
+
value: state.interval,
|
|
108
|
+
onChange: (_, value) => {
|
|
109
|
+
if (value !== null) {
|
|
110
|
+
setState({
|
|
111
|
+
interval: value
|
|
112
|
+
});
|
|
113
|
+
}
|
|
109
114
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
action = x.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
115
|
+
exclusive: true,
|
|
116
|
+
children: Object.keys(recurring).map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ToggleButton, {
|
|
117
|
+
value: x,
|
|
118
|
+
sx: {
|
|
119
|
+
textTransform: "capitalize"
|
|
120
|
+
},
|
|
121
|
+
children: (0, _util.formatRecurring)(recurring[x], true, "", locale)
|
|
122
|
+
}, x))
|
|
123
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
124
|
+
flexWrap: "wrap",
|
|
125
|
+
direction: "row",
|
|
126
|
+
gap: "calc(10px + 3%)",
|
|
127
|
+
justifyContent: alignItems === "center" ? "center" : "flex-start",
|
|
128
|
+
children: grouped[state.interval]?.map(x => {
|
|
129
|
+
let action = x.subscription_data?.trial_period_days ? t("payment.checkout.try") : t("payment.checkout.subscription");
|
|
130
|
+
if (mode === "select") {
|
|
131
|
+
action = x.is_selected ? t("payment.checkout.selected") : t("payment.checkout.select");
|
|
132
|
+
}
|
|
133
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Fade, {
|
|
134
|
+
in: true,
|
|
135
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
136
|
+
padding: 4,
|
|
137
|
+
spacing: 2,
|
|
138
|
+
direction: "column",
|
|
139
|
+
alignItems: "center",
|
|
140
|
+
className: "price-table-item",
|
|
141
|
+
justifyContent: "center",
|
|
142
|
+
sx: {
|
|
143
|
+
width: 0.9 / grouped[state.interval].length,
|
|
144
|
+
cursor: "pointer",
|
|
145
|
+
borderWidth: "1px",
|
|
146
|
+
borderStyle: "solid",
|
|
147
|
+
borderColor: mode === "select" && x.is_selected ? "primary.main" : "#eee",
|
|
148
|
+
borderRadius: 1,
|
|
149
|
+
transition: "border-color 0.3s ease 0s, box-shadow 0.3s ease 0s",
|
|
150
|
+
boxShadow: "0 4px 8px rgba(0, 0, 0, 20%)",
|
|
151
|
+
"&:hover": {
|
|
152
|
+
borderColor: mode === "select" && x.is_selected ? "primary.main" : "#ddd",
|
|
153
|
+
boxShadow: "0 8px 16px rgba(0, 0, 0, 20%)"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
157
|
+
textAlign: "center",
|
|
158
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
159
|
+
direction: "row",
|
|
160
|
+
alignItems: "center",
|
|
161
|
+
spacing: 1,
|
|
162
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
163
|
+
variant: "h5",
|
|
164
|
+
color: "text.primary",
|
|
165
|
+
fontWeight: 600,
|
|
166
|
+
children: x.product.name
|
|
167
|
+
}), x.is_highlight && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
168
|
+
label: x.highlight_text,
|
|
169
|
+
color: "default",
|
|
170
|
+
size: "small"
|
|
171
|
+
})]
|
|
172
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
173
|
+
color: "text.secondary",
|
|
174
|
+
children: x.product.description
|
|
175
|
+
})]
|
|
176
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
150
177
|
direction: "row",
|
|
151
178
|
alignItems: "center",
|
|
152
179
|
spacing: 1,
|
|
153
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
180
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_amount.default, {
|
|
181
|
+
amount: (0, _util.formatPriceAmount)(x.price, table.currency, x.product.unit_label)
|
|
182
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
183
|
+
direction: "column",
|
|
184
|
+
alignItems: "flex-start",
|
|
185
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
186
|
+
component: "span",
|
|
187
|
+
color: "text.secondary",
|
|
188
|
+
fontSize: "0.8rem",
|
|
189
|
+
children: t("payment.checkout.per")
|
|
190
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
191
|
+
component: "span",
|
|
192
|
+
color: "text.secondary",
|
|
193
|
+
fontSize: "0.8rem",
|
|
194
|
+
children: (0, _util.formatRecurring)(x.price.recurring, false, "", locale)
|
|
195
|
+
})]
|
|
162
196
|
})]
|
|
163
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
197
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_lab.LoadingButton, {
|
|
198
|
+
fullWidth: true,
|
|
199
|
+
size: "large",
|
|
200
|
+
variant: x.is_highlight || x.is_selected ? "contained" : "outlined",
|
|
201
|
+
color: x.is_highlight || x.is_selected ? "primary" : "info",
|
|
202
|
+
sx: {
|
|
203
|
+
fontSize: "1.2rem"
|
|
204
|
+
},
|
|
205
|
+
loading: state.loading === x.price_id,
|
|
206
|
+
disabled: x.is_disabled,
|
|
207
|
+
onClick: () => handleSelect(x.price_id),
|
|
208
|
+
children: action
|
|
209
|
+
}), x.product.features.length > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
176
210
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
children:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
211
|
+
children: t("payment.checkout.include")
|
|
212
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.List, {
|
|
213
|
+
dense: true,
|
|
214
|
+
children: x.product.features.map(f => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.ListItem, {
|
|
215
|
+
disableGutters: true,
|
|
216
|
+
disablePadding: true,
|
|
217
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
218
|
+
sx: {
|
|
219
|
+
minWidth: 25
|
|
220
|
+
},
|
|
221
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.CheckOutlined, {
|
|
222
|
+
color: "success",
|
|
223
|
+
fontSize: "small"
|
|
224
|
+
})
|
|
225
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ListItemText, {
|
|
226
|
+
primary: f.name
|
|
227
|
+
})]
|
|
228
|
+
}, f.name))
|
|
186
229
|
})]
|
|
187
230
|
})]
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
color: x.is_highlight || x.is_selected ? "primary" : "info",
|
|
194
|
-
sx: {
|
|
195
|
-
fontSize: "1.2rem"
|
|
196
|
-
},
|
|
197
|
-
loading: state.loading === x.price_id,
|
|
198
|
-
disabled: x.is_disabled,
|
|
199
|
-
onClick: () => handleSelect(x.price_id),
|
|
200
|
-
children: action
|
|
201
|
-
}), x.product.features.length > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
202
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
203
|
-
children: t("payment.checkout.include")
|
|
204
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.List, {
|
|
205
|
-
dense: true,
|
|
206
|
-
children: x.product.features.map(f => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.ListItem, {
|
|
207
|
-
disableGutters: true,
|
|
208
|
-
disablePadding: true,
|
|
209
|
-
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
210
|
-
sx: {
|
|
211
|
-
minWidth: 25
|
|
212
|
-
},
|
|
213
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_iconsMaterial.CheckOutlined, {
|
|
214
|
-
color: "success",
|
|
215
|
-
fontSize: "small"
|
|
216
|
-
})
|
|
217
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.ListItemText, {
|
|
218
|
-
primary: f.name
|
|
219
|
-
})]
|
|
220
|
-
}, f.name))
|
|
221
|
-
})]
|
|
222
|
-
})]
|
|
223
|
-
})
|
|
224
|
-
}, x.price_id);
|
|
225
|
-
})
|
|
226
|
-
})]
|
|
231
|
+
})
|
|
232
|
+
}, x.price_id);
|
|
233
|
+
})
|
|
234
|
+
})]
|
|
235
|
+
})
|
|
227
236
|
});
|
|
228
237
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import api from './api';
|
|
2
2
|
import CheckoutForm from './checkout/form';
|
|
3
3
|
import CheckoutTable from './checkout/table';
|
|
4
|
+
import ConfirmDialog from './components/confirm';
|
|
4
5
|
import FormInput from './components/input';
|
|
5
6
|
import Livemode from './components/livemode';
|
|
6
7
|
import PricingTable from './components/pricing-table';
|
|
@@ -11,7 +12,9 @@ import Amount from './payment/amount';
|
|
|
11
12
|
import PhoneInput from './payment/form/phone';
|
|
12
13
|
import Payment from './payment/index';
|
|
13
14
|
import ProductSkeleton from './payment/product-skeleton';
|
|
15
|
+
import CustomerInvoiceList from './portal/invoice/list';
|
|
16
|
+
import CustomerPaymentList from './portal/payment/list';
|
|
14
17
|
export * from './util';
|
|
15
18
|
export * from './contexts/payment';
|
|
16
19
|
export { translations, createTranslator } from './locales';
|
|
17
|
-
export { api, dayjs, FormInput, PhoneInput, Status, Livemode, Switch, CheckoutForm, CheckoutTable, Payment, PricingTable, ProductSkeleton, Amount, };
|
|
20
|
+
export { api, dayjs, FormInput, PhoneInput, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, Payment, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, };
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var _exportNames = {
|
|
|
7
7
|
api: true,
|
|
8
8
|
CheckoutForm: true,
|
|
9
9
|
CheckoutTable: true,
|
|
10
|
+
ConfirmDialog: true,
|
|
10
11
|
FormInput: true,
|
|
11
12
|
Livemode: true,
|
|
12
13
|
PricingTable: true,
|
|
@@ -17,6 +18,8 @@ var _exportNames = {
|
|
|
17
18
|
PhoneInput: true,
|
|
18
19
|
Payment: true,
|
|
19
20
|
ProductSkeleton: true,
|
|
21
|
+
CustomerInvoiceList: true,
|
|
22
|
+
CustomerPaymentList: true,
|
|
20
23
|
translations: true,
|
|
21
24
|
createTranslator: true
|
|
22
25
|
};
|
|
@@ -38,6 +41,24 @@ Object.defineProperty(exports, "CheckoutTable", {
|
|
|
38
41
|
return _table.default;
|
|
39
42
|
}
|
|
40
43
|
});
|
|
44
|
+
Object.defineProperty(exports, "ConfirmDialog", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _confirm.default;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "CustomerInvoiceList", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return _list.default;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "CustomerPaymentList", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () {
|
|
59
|
+
return _list2.default;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
41
62
|
Object.defineProperty(exports, "FormInput", {
|
|
42
63
|
enumerable: true,
|
|
43
64
|
get: function () {
|
|
@@ -113,6 +134,7 @@ Object.defineProperty(exports, "translations", {
|
|
|
113
134
|
var _api = _interopRequireDefault(require("./api"));
|
|
114
135
|
var _form = _interopRequireDefault(require("./checkout/form"));
|
|
115
136
|
var _table = _interopRequireDefault(require("./checkout/table"));
|
|
137
|
+
var _confirm = _interopRequireDefault(require("./components/confirm"));
|
|
116
138
|
var _input = _interopRequireDefault(require("./components/input"));
|
|
117
139
|
var _livemode = _interopRequireDefault(require("./components/livemode"));
|
|
118
140
|
var _pricingTable = _interopRequireDefault(require("./components/pricing-table"));
|
|
@@ -123,6 +145,8 @@ var _amount = _interopRequireDefault(require("./payment/amount"));
|
|
|
123
145
|
var _phone = _interopRequireDefault(require("./payment/form/phone"));
|
|
124
146
|
var _index = _interopRequireDefault(require("./payment/index"));
|
|
125
147
|
var _productSkeleton = _interopRequireDefault(require("./payment/product-skeleton"));
|
|
148
|
+
var _list = _interopRequireDefault(require("./portal/invoice/list"));
|
|
149
|
+
var _list2 = _interopRequireDefault(require("./portal/payment/list"));
|
|
126
150
|
var _util = require("./util");
|
|
127
151
|
Object.keys(_util).forEach(function (key) {
|
|
128
152
|
if (key === "default" || key === "__esModule") return;
|
package/lib/locales/en.js
CHANGED
|
@@ -153,6 +153,7 @@ module.exports = (0, _flat.default)({
|
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
customer: {
|
|
156
|
+
payments: "Payment History",
|
|
156
157
|
invoices: "Invoice History",
|
|
157
158
|
details: "Billing Details",
|
|
158
159
|
update: "Update Information",
|
|
@@ -208,7 +209,10 @@ module.exports = (0, _flat.default)({
|
|
|
208
209
|
pay: "Pay this invoice",
|
|
209
210
|
paySuccess: "You have successfully paid the invoice",
|
|
210
211
|
payError: "Failed to paid the invoice",
|
|
211
|
-
empty: "Seems you do not have any
|
|
212
|
+
empty: "Seems you do not have any invoice here"
|
|
213
|
+
},
|
|
214
|
+
payment: {
|
|
215
|
+
empty: "Seems you do not have any payment here"
|
|
212
216
|
},
|
|
213
217
|
subscriptions: {
|
|
214
218
|
title: "Manage subscriptions",
|
package/lib/locales/zh.js
CHANGED
|
@@ -153,6 +153,7 @@ module.exports = (0, _flat.default)({
|
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
customer: {
|
|
156
|
+
payments: "\u652F\u4ED8\u5386\u53F2",
|
|
156
157
|
invoices: "\u53D1\u7968\u5386\u53F2",
|
|
157
158
|
details: "\u8BA1\u8D39\u8BE6\u60C5",
|
|
158
159
|
update: "\u66F4\u65B0\u5BA2\u6237\u4FE1\u606F",
|
|
@@ -208,6 +209,9 @@ module.exports = (0, _flat.default)({
|
|
|
208
209
|
pay: "\u652F\u4ED8\u6B64\u53D1\u7968",
|
|
209
210
|
paySuccess: "\u652F\u4ED8\u6210\u529F",
|
|
210
211
|
payError: "\u652F\u4ED8\u5931\u8D25",
|
|
212
|
+
empty: "\u4F60\u6CA1\u6709\u4EFB\u4F55\u53D1\u7968"
|
|
213
|
+
},
|
|
214
|
+
payment: {
|
|
211
215
|
empty: "\u4F60\u6CA1\u6709\u4EFB\u4F55\u652F\u4ED8"
|
|
212
216
|
},
|
|
213
217
|
subscriptions: {
|
package/lib/payment/index.js
CHANGED
|
@@ -363,18 +363,18 @@ const Root = exports.Root = (0, _system.styled)(_material.Box)`
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
.cko-payment-card-unselect {
|
|
366
|
-
border: 2px solid #
|
|
366
|
+
border: 2px solid #ddd;
|
|
367
367
|
padding: 5px 10px;
|
|
368
368
|
margin: 5px 0;
|
|
369
369
|
cursor: pointer;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
.cko-payment-card:nth-child(odd) {
|
|
373
|
-
margin-right:
|
|
373
|
+
margin-right: 16px;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
.cko-payment-card-unselect:nth-child(odd) {
|
|
377
|
-
margin-right:
|
|
377
|
+
margin-right: 16px;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
.cko-payment-card::after {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = CustomerInvoiceList;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _util = require("@ocap/util");
|
|
11
|
+
var _ahooks = require("ahooks");
|
|
12
|
+
var _api = _interopRequireDefault(require("../../api"));
|
|
13
|
+
var _status = _interopRequireDefault(require("../../components/status"));
|
|
14
|
+
var _util2 = require("../../util");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
const groupByDate = items => {
|
|
17
|
+
const grouped = {};
|
|
18
|
+
items.forEach(item => {
|
|
19
|
+
const date = new Date(item.created_at).toLocaleDateString();
|
|
20
|
+
if (!grouped[date]) {
|
|
21
|
+
grouped[date] = [];
|
|
22
|
+
}
|
|
23
|
+
grouped[date]?.push(item);
|
|
24
|
+
});
|
|
25
|
+
return grouped;
|
|
26
|
+
};
|
|
27
|
+
const fetchData = (params = {}) => {
|
|
28
|
+
const search = new URLSearchParams();
|
|
29
|
+
Object.keys(params).forEach(key => {
|
|
30
|
+
search.set(key, String(params[key]));
|
|
31
|
+
});
|
|
32
|
+
return _api.default.get(`/api/invoices?${search.toString()}`).then(res => res.data);
|
|
33
|
+
};
|
|
34
|
+
const pageSize = 10;
|
|
35
|
+
function CustomerInvoiceList({
|
|
36
|
+
customer_id
|
|
37
|
+
}) {
|
|
38
|
+
const {
|
|
39
|
+
t
|
|
40
|
+
} = (0, _context.useLocaleContext)();
|
|
41
|
+
const {
|
|
42
|
+
data,
|
|
43
|
+
loadMore,
|
|
44
|
+
loadingMore,
|
|
45
|
+
loading
|
|
46
|
+
} = (0, _ahooks.useInfiniteScroll)(d => {
|
|
47
|
+
const page = d ? Math.ceil(d.list.length / pageSize) + 1 : 1;
|
|
48
|
+
return fetchData({
|
|
49
|
+
page,
|
|
50
|
+
pageSize,
|
|
51
|
+
status: "open,paid,uncollectible",
|
|
52
|
+
customer_id
|
|
53
|
+
});
|
|
54
|
+
}, {
|
|
55
|
+
reloadDeps: [customer_id]
|
|
56
|
+
});
|
|
57
|
+
if (loading || !data) {
|
|
58
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {});
|
|
59
|
+
}
|
|
60
|
+
if (data && data.list.length === 0) {
|
|
61
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
62
|
+
color: "text.secondary",
|
|
63
|
+
children: t("payment.customer.invoice.empty")
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const hasMore = data && data.list.length < data.count;
|
|
67
|
+
const grouped = groupByDate(data.list);
|
|
68
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
69
|
+
direction: "column",
|
|
70
|
+
gap: 1,
|
|
71
|
+
sx: {
|
|
72
|
+
mt: 1
|
|
73
|
+
},
|
|
74
|
+
children: [Object.entries(grouped).map(([date, invoices]) => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
75
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
76
|
+
sx: {
|
|
77
|
+
fontWeight: "bold",
|
|
78
|
+
color: "text.secondary",
|
|
79
|
+
mt: 2,
|
|
80
|
+
mb: 1
|
|
81
|
+
},
|
|
82
|
+
children: date
|
|
83
|
+
}), invoices.map(invoice => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
84
|
+
direction: {
|
|
85
|
+
xs: "column",
|
|
86
|
+
sm: "row"
|
|
87
|
+
},
|
|
88
|
+
sx: {
|
|
89
|
+
my: 1
|
|
90
|
+
},
|
|
91
|
+
gap: {
|
|
92
|
+
xs: 0.5,
|
|
93
|
+
sm: 1.5,
|
|
94
|
+
md: 3
|
|
95
|
+
},
|
|
96
|
+
flexWrap: "nowrap",
|
|
97
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
98
|
+
flex: 3,
|
|
99
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("a", {
|
|
100
|
+
href: `/customer/invoice/${invoice.id}`,
|
|
101
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
102
|
+
component: "span",
|
|
103
|
+
children: invoice.number
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
107
|
+
flex: 3,
|
|
108
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
109
|
+
children: (0, _util2.formatToDate)(invoice.created_at)
|
|
110
|
+
})
|
|
111
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
112
|
+
flex: 2,
|
|
113
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
114
|
+
textAlign: "right",
|
|
115
|
+
children: [(0, _util.fromUnitToToken)(invoice.total, invoice.paymentCurrency.decimal), "\xA0", invoice.paymentCurrency.symbol]
|
|
116
|
+
})
|
|
117
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
118
|
+
flex: 2,
|
|
119
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_status.default, {
|
|
120
|
+
label: invoice.status,
|
|
121
|
+
color: (0, _util2.getInvoiceStatusColor)(invoice.status)
|
|
122
|
+
})
|
|
123
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
124
|
+
flex: 4,
|
|
125
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
126
|
+
children: invoice.description || invoice.id
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
}, invoice.id))]
|
|
130
|
+
}, date)), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
131
|
+
children: [hasMore && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
132
|
+
variant: "text",
|
|
133
|
+
type: "button",
|
|
134
|
+
color: "inherit",
|
|
135
|
+
onClick: loadMore,
|
|
136
|
+
disabled: loadingMore,
|
|
137
|
+
children: loadingMore ? t("common.loadingMore", {
|
|
138
|
+
resource: t("payment.customer.invoices")
|
|
139
|
+
}) : t("common.loadMore", {
|
|
140
|
+
resource: t("payament.customer.invoices")
|
|
141
|
+
})
|
|
142
|
+
}), !hasMore && data.count > pageSize && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
143
|
+
color: "text.secondary",
|
|
144
|
+
children: t("common.noMore", {
|
|
145
|
+
resource: t("payment.customer.invoices")
|
|
146
|
+
})
|
|
147
|
+
})]
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
}
|