@blocklet/payment-react 1.20.13 → 1.20.14
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/components/source-data-viewer.d.ts +23 -0
- package/es/components/source-data-viewer.js +228 -0
- package/es/history/credit/transactions-list.d.ts +1 -0
- package/es/history/credit/transactions-list.js +137 -20
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/locales/en.js +2 -1
- package/es/locales/zh.js +2 -1
- package/es/payment/index.js +31 -4
- package/es/payment/summary.js +6 -6
- package/lib/components/source-data-viewer.d.ts +23 -0
- package/lib/components/source-data-viewer.js +236 -0
- package/lib/history/credit/transactions-list.d.ts +1 -0
- package/lib/history/credit/transactions-list.js +132 -16
- package/lib/index.d.ts +2 -1
- package/lib/index.js +8 -0
- package/lib/locales/en.js +2 -1
- package/lib/locales/zh.js +2 -1
- package/lib/payment/index.js +31 -4
- package/lib/payment/summary.js +6 -6
- package/package.json +3 -3
- package/src/components/source-data-viewer.tsx +295 -0
- package/src/history/credit/transactions-list.tsx +142 -18
- package/src/index.ts +2 -0
- package/src/locales/en.tsx +1 -0
- package/src/locales/zh.tsx +1 -0
- package/src/payment/index.tsx +32 -4
- package/src/payment/summary.tsx +7 -7
package/es/payment/summary.js
CHANGED
|
@@ -36,9 +36,9 @@ const ExpandMore = styled((props) => {
|
|
|
36
36
|
duration: theme.transitions.duration.shortest
|
|
37
37
|
})
|
|
38
38
|
}));
|
|
39
|
-
async function fetchCrossSell(id) {
|
|
39
|
+
async function fetchCrossSell(id, skipError = true) {
|
|
40
40
|
try {
|
|
41
|
-
const { data } = await api.get(`/api/checkout-sessions/${id}/cross-sell`);
|
|
41
|
+
const { data } = await api.get(`/api/checkout-sessions/${id}/cross-sell?skipError=${skipError}`);
|
|
42
42
|
if (!data.error) {
|
|
43
43
|
return data;
|
|
44
44
|
}
|
|
@@ -103,7 +103,7 @@ export default function PaymentSummary({
|
|
|
103
103
|
const { paymentState, ...settings } = usePaymentContext();
|
|
104
104
|
const [state, setState] = useSetState({ loading: false, shake: false, expanded: items?.length < 3 });
|
|
105
105
|
const { data, runAsync } = useRequest(
|
|
106
|
-
() => checkoutSessionId ? fetchCrossSell(checkoutSessionId) : Promise.resolve(null)
|
|
106
|
+
(skipError) => checkoutSessionId ? fetchCrossSell(checkoutSessionId, skipError) : Promise.resolve(null)
|
|
107
107
|
);
|
|
108
108
|
const sessionDiscounts = checkoutSession?.discounts || [];
|
|
109
109
|
const allowPromotionCodes = !!checkoutSession?.allow_promotion_codes;
|
|
@@ -157,15 +157,15 @@ export default function PaymentSummary({
|
|
|
157
157
|
);
|
|
158
158
|
const handleUpsell = async (from, to) => {
|
|
159
159
|
await onUpsell(from, to);
|
|
160
|
-
runAsync();
|
|
160
|
+
runAsync(false);
|
|
161
161
|
};
|
|
162
162
|
const handleQuantityChange = async (itemId, quantity) => {
|
|
163
163
|
await onQuantityChange(itemId, quantity);
|
|
164
|
-
runAsync();
|
|
164
|
+
runAsync(false);
|
|
165
165
|
};
|
|
166
166
|
const handleDownsell = async (from) => {
|
|
167
167
|
await onDownsell(from);
|
|
168
|
-
runAsync();
|
|
168
|
+
runAsync(false);
|
|
169
169
|
};
|
|
170
170
|
const handleApplyCrossSell = async () => {
|
|
171
171
|
if (data) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type LocalizedText = {
|
|
2
|
+
zh: string;
|
|
3
|
+
en: string;
|
|
4
|
+
};
|
|
5
|
+
type SimpleSourceData = Record<string, string>;
|
|
6
|
+
type StructuredSourceDataField = {
|
|
7
|
+
key: string;
|
|
8
|
+
label: string | LocalizedText;
|
|
9
|
+
value: string;
|
|
10
|
+
type?: 'text' | 'image' | 'url';
|
|
11
|
+
url?: string;
|
|
12
|
+
group?: string;
|
|
13
|
+
};
|
|
14
|
+
type SourceData = SimpleSourceData | StructuredSourceDataField[];
|
|
15
|
+
interface SourceDataViewerProps {
|
|
16
|
+
data: SourceData;
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
maxItems?: number;
|
|
19
|
+
locale?: 'en' | 'zh';
|
|
20
|
+
showGroups?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare function SourceDataViewer({ data, compact, maxItems, locale: propLocale, showGroups, }: SourceDataViewerProps): import("react").JSX.Element | null;
|
|
23
|
+
export default SourceDataViewer;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
9
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
10
|
+
var _material = require("@mui/material");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function SourceDataViewer({
|
|
13
|
+
data,
|
|
14
|
+
compact = false,
|
|
15
|
+
maxItems = void 0,
|
|
16
|
+
locale: propLocale = void 0,
|
|
17
|
+
showGroups = false
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
locale: contextLocale,
|
|
21
|
+
t
|
|
22
|
+
} = (0, _context.useLocaleContext)();
|
|
23
|
+
const currentLocale = propLocale || contextLocale || "en";
|
|
24
|
+
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|
|
25
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_Empty.default, {
|
|
26
|
+
children: t("common.none")
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const getLocalizedText = text => {
|
|
30
|
+
if (typeof text === "string") {
|
|
31
|
+
return text;
|
|
32
|
+
}
|
|
33
|
+
return text[currentLocale] || text.en || "";
|
|
34
|
+
};
|
|
35
|
+
const isSimpleSourceData = sourceData => {
|
|
36
|
+
return typeof sourceData === "object" && !Array.isArray(sourceData) && sourceData !== null;
|
|
37
|
+
};
|
|
38
|
+
const isUrlLike = str => {
|
|
39
|
+
try {
|
|
40
|
+
new URL(str);
|
|
41
|
+
return true;
|
|
42
|
+
} catch {
|
|
43
|
+
return /^https?:\/\/.+/.test(str) || /^www\..+/.test(str);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const normalizeData = inputData => {
|
|
47
|
+
if (isSimpleSourceData(inputData)) {
|
|
48
|
+
return Object.entries(inputData).map(([key, value]) => {
|
|
49
|
+
const stringValue = String(value);
|
|
50
|
+
const isUrl = isUrlLike(stringValue);
|
|
51
|
+
return {
|
|
52
|
+
key,
|
|
53
|
+
label: key.replace(/_/g, " ").replace(/\b\w/g, l => l.toUpperCase()),
|
|
54
|
+
value: stringValue,
|
|
55
|
+
type: isUrl ? "url" : "text",
|
|
56
|
+
url: isUrl ? stringValue : void 0
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return inputData;
|
|
61
|
+
};
|
|
62
|
+
const renderFieldValue = field => {
|
|
63
|
+
const displayValue = field.value;
|
|
64
|
+
if (field.type === "url") {
|
|
65
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Link, {
|
|
66
|
+
href: field.url || field.value,
|
|
67
|
+
target: "_blank",
|
|
68
|
+
rel: "noopener noreferrer",
|
|
69
|
+
sx: {
|
|
70
|
+
color: "primary.main",
|
|
71
|
+
textDecoration: "none",
|
|
72
|
+
fontSize: "0.85rem",
|
|
73
|
+
fontWeight: 600,
|
|
74
|
+
lineHeight: 1.4,
|
|
75
|
+
"&:hover": {
|
|
76
|
+
textDecoration: "underline",
|
|
77
|
+
color: "primary.dark"
|
|
78
|
+
},
|
|
79
|
+
"&:visited": {
|
|
80
|
+
color: "primary.main"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
children: displayValue
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (field.type === "image") {
|
|
87
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
88
|
+
sx: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
alignItems: "center",
|
|
91
|
+
gap: 1
|
|
92
|
+
},
|
|
93
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
94
|
+
component: "img",
|
|
95
|
+
src: field.url || field.value,
|
|
96
|
+
alt: displayValue,
|
|
97
|
+
sx: {
|
|
98
|
+
width: 24,
|
|
99
|
+
height: 24,
|
|
100
|
+
borderRadius: 1,
|
|
101
|
+
objectFit: "cover"
|
|
102
|
+
}
|
|
103
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
104
|
+
variant: "body2",
|
|
105
|
+
sx: {
|
|
106
|
+
fontWeight: 500
|
|
107
|
+
},
|
|
108
|
+
children: displayValue
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
113
|
+
variant: "body2",
|
|
114
|
+
sx: {
|
|
115
|
+
fontWeight: 500,
|
|
116
|
+
color: "text.primary"
|
|
117
|
+
},
|
|
118
|
+
children: displayValue
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const normalizedData = normalizeData(data);
|
|
125
|
+
const displayItems = maxItems ? normalizedData.slice(0, maxItems) : normalizedData;
|
|
126
|
+
if (compact) {
|
|
127
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
128
|
+
direction: "row",
|
|
129
|
+
spacing: 1,
|
|
130
|
+
flexWrap: "wrap",
|
|
131
|
+
useFlexGap: true,
|
|
132
|
+
children: [displayItems.map(field => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
133
|
+
label: `${getLocalizedText(field.label)}: ${field.value}`,
|
|
134
|
+
size: "small",
|
|
135
|
+
variant: "outlined",
|
|
136
|
+
sx: {
|
|
137
|
+
maxWidth: 200
|
|
138
|
+
}
|
|
139
|
+
}, field.key)), maxItems && normalizedData.length > maxItems && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
|
|
140
|
+
label: `+${normalizedData.length - maxItems} more`,
|
|
141
|
+
size: "small",
|
|
142
|
+
color: "primary",
|
|
143
|
+
variant: "outlined"
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (showGroups) {
|
|
148
|
+
const groupedData = displayItems.reduce((acc, field) => {
|
|
149
|
+
const group = field.group || "default";
|
|
150
|
+
if (!acc[group]) acc[group] = [];
|
|
151
|
+
acc[group].push(field);
|
|
152
|
+
return acc;
|
|
153
|
+
}, {});
|
|
154
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
155
|
+
spacing: 2.5,
|
|
156
|
+
children: Object.entries(groupedData).map(([group, fields]) => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
157
|
+
children: [group !== "default" && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
158
|
+
variant: "subtitle2",
|
|
159
|
+
sx: {
|
|
160
|
+
mb: 1.5,
|
|
161
|
+
fontWeight: 700,
|
|
162
|
+
color: "text.primary",
|
|
163
|
+
letterSpacing: "0.5px",
|
|
164
|
+
borderBottom: "1px solid",
|
|
165
|
+
borderColor: "divider",
|
|
166
|
+
pb: 0.5
|
|
167
|
+
},
|
|
168
|
+
children: group.replace(/_/g, " ").replace(/\b\w/g, l => l.toUpperCase())
|
|
169
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
170
|
+
spacing: 1.2,
|
|
171
|
+
sx: {
|
|
172
|
+
pl: group !== "default" ? 1 : 0
|
|
173
|
+
},
|
|
174
|
+
children: fields.map(field => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
175
|
+
sx: {
|
|
176
|
+
display: "flex",
|
|
177
|
+
flexDirection: "row",
|
|
178
|
+
alignItems: "flex-start",
|
|
179
|
+
gap: 3,
|
|
180
|
+
minHeight: 20
|
|
181
|
+
},
|
|
182
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
183
|
+
variant: "body2",
|
|
184
|
+
color: "text.secondary",
|
|
185
|
+
sx: {
|
|
186
|
+
fontSize: "0.8rem",
|
|
187
|
+
minWidth: 100,
|
|
188
|
+
fontWeight: 600,
|
|
189
|
+
lineHeight: 1.4
|
|
190
|
+
},
|
|
191
|
+
children: getLocalizedText(field.label)
|
|
192
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
193
|
+
sx: {
|
|
194
|
+
flex: 1,
|
|
195
|
+
minWidth: 0,
|
|
196
|
+
wordBreak: "break-all",
|
|
197
|
+
whiteSpace: "wrap"
|
|
198
|
+
},
|
|
199
|
+
children: renderFieldValue(field)
|
|
200
|
+
})]
|
|
201
|
+
}, field.key))
|
|
202
|
+
})]
|
|
203
|
+
}, group))
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
207
|
+
spacing: 1.5,
|
|
208
|
+
children: displayItems.map(field => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
209
|
+
sx: {
|
|
210
|
+
display: "flex",
|
|
211
|
+
flexDirection: "row",
|
|
212
|
+
alignItems: "flex-start",
|
|
213
|
+
gap: 3,
|
|
214
|
+
minHeight: 20
|
|
215
|
+
},
|
|
216
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
217
|
+
variant: "body2",
|
|
218
|
+
color: "text.secondary",
|
|
219
|
+
sx: {
|
|
220
|
+
fontSize: "0.8rem",
|
|
221
|
+
minWidth: 100,
|
|
222
|
+
fontWeight: 600,
|
|
223
|
+
lineHeight: 1.4
|
|
224
|
+
},
|
|
225
|
+
children: getLocalizedText(field.label)
|
|
226
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
227
|
+
sx: {
|
|
228
|
+
flex: 1,
|
|
229
|
+
minWidth: 0
|
|
230
|
+
},
|
|
231
|
+
children: renderFieldValue(field)
|
|
232
|
+
})]
|
|
233
|
+
}, field.key))
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
module.exports = SourceDataViewer;
|
|
@@ -10,14 +10,15 @@ var _material = require("@mui/material");
|
|
|
10
10
|
var _ahooks = require("ahooks");
|
|
11
11
|
var _reactRouterDom = require("react-router-dom");
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
var _ufo = require("ufo");
|
|
14
13
|
var _system = require("@mui/system");
|
|
14
|
+
var _ufo = require("ufo");
|
|
15
15
|
var _dateRangePicker = _interopRequireDefault(require("../../components/date-range-picker"));
|
|
16
16
|
var _util = require("../../libs/util");
|
|
17
17
|
var _payment = require("../../contexts/payment");
|
|
18
18
|
var _api = _interopRequireDefault(require("../../libs/api"));
|
|
19
19
|
var _table = _interopRequireDefault(require("../../components/table"));
|
|
20
20
|
var _navigation = require("../../libs/navigation");
|
|
21
|
+
var _sourceDataViewer = _interopRequireDefault(require("../../components/source-data-viewer"));
|
|
21
22
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -40,6 +41,16 @@ const getGrantDetailLink = (grantId, inDashboard) => {
|
|
|
40
41
|
connect: false
|
|
41
42
|
};
|
|
42
43
|
};
|
|
44
|
+
const getInvoiceDetailLink = (invoiceId, inDashboard) => {
|
|
45
|
+
let path = `/customer/invoice/${invoiceId}`;
|
|
46
|
+
if (inDashboard) {
|
|
47
|
+
path = `/admin/billing/${invoiceId}`;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
link: (0, _navigation.createLink)(path),
|
|
51
|
+
connect: false
|
|
52
|
+
};
|
|
53
|
+
};
|
|
43
54
|
const TransactionsTable = _react.default.memo(props => {
|
|
44
55
|
const {
|
|
45
56
|
pageSize,
|
|
@@ -49,6 +60,7 @@ const TransactionsTable = _react.default.memo(props => {
|
|
|
49
60
|
onTableDataChange,
|
|
50
61
|
showAdminColumns = false,
|
|
51
62
|
showTimeFilter = false,
|
|
63
|
+
includeGrants = false,
|
|
52
64
|
source,
|
|
53
65
|
mode = "portal"
|
|
54
66
|
} = props;
|
|
@@ -71,6 +83,10 @@ const TransactionsTable = _react.default.memo(props => {
|
|
|
71
83
|
start: void 0,
|
|
72
84
|
end: void 0
|
|
73
85
|
});
|
|
86
|
+
const [sourceDataPopover, setSourceDataPopover] = (0, _react.useState)({
|
|
87
|
+
anchorEl: null,
|
|
88
|
+
data: null
|
|
89
|
+
});
|
|
74
90
|
const handleDateRangeChange = (0, _react.useCallback)(newValue => {
|
|
75
91
|
setFilters(newValue);
|
|
76
92
|
setSearch(prev => ({
|
|
@@ -91,9 +107,10 @@ const TransactionsTable = _react.default.memo(props => {
|
|
|
91
107
|
customer_id: effectiveCustomerId,
|
|
92
108
|
subscription_id,
|
|
93
109
|
credit_grant_id,
|
|
94
|
-
source
|
|
110
|
+
source,
|
|
111
|
+
include_grants: includeGrants
|
|
95
112
|
}), {
|
|
96
|
-
refreshDeps: [search, effectiveCustomerId, subscription_id, credit_grant_id, source]
|
|
113
|
+
refreshDeps: [search, effectiveCustomerId, subscription_id, credit_grant_id, source, includeGrants]
|
|
97
114
|
});
|
|
98
115
|
(0, _react.useEffect)(() => {
|
|
99
116
|
if (showTimeFilter && !search.start && !search.end) {
|
|
@@ -113,24 +130,39 @@ const TransactionsTable = _react.default.memo(props => {
|
|
|
113
130
|
align: "right",
|
|
114
131
|
options: {
|
|
115
132
|
customBodyRenderLite: (_, index) => {
|
|
116
|
-
const
|
|
117
|
-
const
|
|
133
|
+
const item = data?.list[index];
|
|
134
|
+
const isGrant = item.activity_type === "grant";
|
|
135
|
+
const amount = isGrant ? item.amount : item.credit_amount;
|
|
136
|
+
const currency = item.paymentCurrency || item.currency;
|
|
137
|
+
const unit = !isGrant && item.meter?.unit ? item.meter.unit : currency?.symbol;
|
|
138
|
+
const displayAmount = (0, _util.formatBNStr)(amount, currency?.decimal || 0);
|
|
139
|
+
if (!includeGrants) {
|
|
140
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
141
|
+
children: [displayAmount, " ", unit]
|
|
142
|
+
});
|
|
143
|
+
}
|
|
118
144
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
119
|
-
|
|
145
|
+
sx: {
|
|
146
|
+
color: isGrant ? "success.main" : "error.main"
|
|
147
|
+
},
|
|
148
|
+
children: [isGrant ? "+" : "-", " ", displayAmount, " ", unit]
|
|
120
149
|
});
|
|
121
150
|
}
|
|
122
151
|
}
|
|
123
|
-
},
|
|
152
|
+
}, {
|
|
124
153
|
label: t("common.creditGrant"),
|
|
125
154
|
name: "credit_grant",
|
|
126
155
|
options: {
|
|
127
156
|
customBodyRenderLite: (_, index) => {
|
|
128
|
-
const
|
|
157
|
+
const item = data?.list[index];
|
|
158
|
+
const isGrant = item.activity_type === "grant";
|
|
159
|
+
const grantName = isGrant ? item.name : item.creditGrant.name;
|
|
160
|
+
const grantId = isGrant ? item.id : item.credit_grant_id;
|
|
129
161
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
130
162
|
direction: "row",
|
|
131
163
|
spacing: 1,
|
|
132
164
|
onClick: e => {
|
|
133
|
-
const link = getGrantDetailLink(
|
|
165
|
+
const link = getGrantDetailLink(grantId, isAdmin && mode === "dashboard");
|
|
134
166
|
(0, _navigation.handleNavigation)(e, link.link, navigate);
|
|
135
167
|
},
|
|
136
168
|
sx: {
|
|
@@ -139,23 +171,27 @@ const TransactionsTable = _react.default.memo(props => {
|
|
|
139
171
|
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
140
172
|
variant: "body2",
|
|
141
173
|
sx: {
|
|
142
|
-
color: "text.link",
|
|
143
174
|
cursor: "pointer"
|
|
144
175
|
},
|
|
145
|
-
children:
|
|
176
|
+
children: grantName || `Grant ${grantId.slice(-6)}`
|
|
146
177
|
})
|
|
147
178
|
});
|
|
148
179
|
}
|
|
149
180
|
}
|
|
150
181
|
}, {
|
|
151
182
|
label: t("common.description"),
|
|
152
|
-
name: "
|
|
183
|
+
name: "description",
|
|
153
184
|
options: {
|
|
154
185
|
customBodyRenderLite: (_, index) => {
|
|
155
|
-
const
|
|
186
|
+
const item = data?.list[index];
|
|
187
|
+
const isGrant = item.activity_type === "grant";
|
|
188
|
+
const description = isGrant ? item.name || item.description || "Credit Granted" : item.subscription?.description || item.description || `${item.meter_event_name} usage`;
|
|
156
189
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
157
190
|
variant: "body2",
|
|
158
|
-
|
|
191
|
+
sx: {
|
|
192
|
+
fontWeight: 400
|
|
193
|
+
},
|
|
194
|
+
children: description
|
|
159
195
|
});
|
|
160
196
|
}
|
|
161
197
|
}
|
|
@@ -188,10 +224,55 @@ const TransactionsTable = _react.default.memo(props => {
|
|
|
188
224
|
name: "created_at",
|
|
189
225
|
options: {
|
|
190
226
|
customBodyRenderLite: (_, index) => {
|
|
191
|
-
const
|
|
227
|
+
const item = data?.list[index];
|
|
192
228
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
193
229
|
variant: "body2",
|
|
194
|
-
|
|
230
|
+
color: "text.secondary",
|
|
231
|
+
sx: {
|
|
232
|
+
fontSize: "0.875rem"
|
|
233
|
+
},
|
|
234
|
+
children: (0, _util.formatToDate)(item.created_at, locale, "YYYY-MM-DD HH:mm")
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
label: t("common.actions"),
|
|
240
|
+
name: "actions",
|
|
241
|
+
options: {
|
|
242
|
+
customBodyRenderLite: (_, index) => {
|
|
243
|
+
const item = data?.list[index];
|
|
244
|
+
const isGrant = item.activity_type === "grant";
|
|
245
|
+
const invoiceId = isGrant ? item.metadata?.invoice_id : null;
|
|
246
|
+
const sourceData = !isGrant && item.meterEvent?.source_data;
|
|
247
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
248
|
+
sx: {
|
|
249
|
+
display: "flex",
|
|
250
|
+
gap: 1,
|
|
251
|
+
alignItems: "center"
|
|
252
|
+
},
|
|
253
|
+
children: [isGrant && invoiceId && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
254
|
+
variant: "text",
|
|
255
|
+
size: "small",
|
|
256
|
+
color: "primary",
|
|
257
|
+
onClick: e => {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
const link = getInvoiceDetailLink(invoiceId, isAdmin && mode === "dashboard");
|
|
260
|
+
(0, _navigation.handleNavigation)(e, link.link, navigate);
|
|
261
|
+
},
|
|
262
|
+
children: t("common.viewInvoice")
|
|
263
|
+
}), sourceData && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
|
|
264
|
+
variant: "text",
|
|
265
|
+
size: "small",
|
|
266
|
+
color: "primary",
|
|
267
|
+
onClick: e => {
|
|
268
|
+
e.preventDefault();
|
|
269
|
+
setSourceDataPopover({
|
|
270
|
+
anchorEl: e.currentTarget,
|
|
271
|
+
data: sourceData
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
children: t("common.viewSourceData")
|
|
275
|
+
})]
|
|
195
276
|
});
|
|
196
277
|
}
|
|
197
278
|
}
|
|
@@ -263,6 +344,40 @@ const TransactionsTable = _react.default.memo(props => {
|
|
|
263
344
|
showMobile: false,
|
|
264
345
|
mobileTDFlexDirection: "row",
|
|
265
346
|
emptyNodeText: t("admin.creditTransactions.noTransactions")
|
|
347
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Popover, {
|
|
348
|
+
open: Boolean(sourceDataPopover.anchorEl),
|
|
349
|
+
anchorEl: sourceDataPopover.anchorEl,
|
|
350
|
+
onClose: () => setSourceDataPopover({
|
|
351
|
+
anchorEl: null,
|
|
352
|
+
data: null
|
|
353
|
+
}),
|
|
354
|
+
anchorOrigin: {
|
|
355
|
+
vertical: "bottom",
|
|
356
|
+
horizontal: "left"
|
|
357
|
+
},
|
|
358
|
+
transformOrigin: {
|
|
359
|
+
vertical: "top",
|
|
360
|
+
horizontal: "left"
|
|
361
|
+
},
|
|
362
|
+
slotProps: {
|
|
363
|
+
paper: {
|
|
364
|
+
sx: {
|
|
365
|
+
minWidth: {
|
|
366
|
+
xs: 0,
|
|
367
|
+
md: 320
|
|
368
|
+
},
|
|
369
|
+
maxHeight: 450,
|
|
370
|
+
p: {
|
|
371
|
+
xs: 1,
|
|
372
|
+
md: 3
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
children: sourceDataPopover.data && /* @__PURE__ */(0, _jsxRuntime.jsx)(_sourceDataViewer.default, {
|
|
378
|
+
data: sourceDataPopover.data,
|
|
379
|
+
showGroups: true
|
|
380
|
+
})
|
|
266
381
|
})]
|
|
267
382
|
});
|
|
268
383
|
});
|
|
@@ -292,6 +407,7 @@ function CreditTransactionsList(rawProps) {
|
|
|
292
407
|
onTableDataChange: () => {},
|
|
293
408
|
showAdminColumns: false,
|
|
294
409
|
showTimeFilter: false,
|
|
410
|
+
includeGrants: false,
|
|
295
411
|
mode: "portal"
|
|
296
412
|
}, rawProps);
|
|
297
413
|
return /* @__PURE__ */(0, _jsxRuntime.jsx)(TransactionsTable, {
|
package/lib/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ import AutoTopupModal from './components/auto-topup/modal';
|
|
|
40
40
|
import AutoTopup from './components/auto-topup';
|
|
41
41
|
import Collapse from './components/collapse';
|
|
42
42
|
import PromotionCode from './components/promotion-code';
|
|
43
|
+
import SourceDataViewer from './components/source-data-viewer';
|
|
43
44
|
export { PaymentThemeProvider } from './theme';
|
|
44
45
|
export * from './libs/util';
|
|
45
46
|
export * from './libs/connect';
|
|
@@ -54,4 +55,4 @@ export * from './hooks/scroll';
|
|
|
54
55
|
export * from './hooks/keyboard';
|
|
55
56
|
export * from './libs/validator';
|
|
56
57
|
export { translations, createTranslator } from './locales';
|
|
57
|
-
export { createLazyComponent, api, dayjs, FormInput, FormLabel, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, PaymentBeneficiaries, LoadingButton, DonateDetails, ResumeSubscription, CreditGrantsList, CreditTransactionsList, DateRangePicker, CreditStatusChip, AutoTopupModal, AutoTopup, Collapse, PromotionCode, };
|
|
58
|
+
export { createLazyComponent, api, dayjs, FormInput, FormLabel, PhoneInput, AddressForm, StripeForm, Status, Livemode, Switch, ConfirmDialog, CheckoutForm, CheckoutTable, CheckoutDonate, CurrencySelector, Payment, PaymentSummary, PricingTable, ProductSkeleton, Amount, CustomerInvoiceList, CustomerPaymentList, TxLink, TxGas, SafeGuard, PricingItem, CountrySelect, Table, TruncatedText, Link, OverdueInvoicePayment, PaymentBeneficiaries, LoadingButton, DonateDetails, ResumeSubscription, CreditGrantsList, CreditTransactionsList, DateRangePicker, CreditStatusChip, AutoTopupModal, AutoTopup, Collapse, PromotionCode, SourceDataViewer, };
|
package/lib/index.js
CHANGED
|
@@ -48,6 +48,7 @@ var _exportNames = {
|
|
|
48
48
|
AutoTopup: true,
|
|
49
49
|
Collapse: true,
|
|
50
50
|
PromotionCode: true,
|
|
51
|
+
SourceDataViewer: true,
|
|
51
52
|
PaymentThemeProvider: true,
|
|
52
53
|
translations: true,
|
|
53
54
|
createTranslator: true
|
|
@@ -262,6 +263,12 @@ Object.defineProperty(exports, "SafeGuard", {
|
|
|
262
263
|
return _safeGuard.default;
|
|
263
264
|
}
|
|
264
265
|
});
|
|
266
|
+
Object.defineProperty(exports, "SourceDataViewer", {
|
|
267
|
+
enumerable: true,
|
|
268
|
+
get: function () {
|
|
269
|
+
return _sourceDataViewer.default;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
265
272
|
Object.defineProperty(exports, "Status", {
|
|
266
273
|
enumerable: true,
|
|
267
274
|
get: function () {
|
|
@@ -376,6 +383,7 @@ var _modal = _interopRequireDefault(require("./components/auto-topup/modal"));
|
|
|
376
383
|
var _autoTopup = _interopRequireDefault(require("./components/auto-topup"));
|
|
377
384
|
var _collapse = _interopRequireDefault(require("./components/collapse"));
|
|
378
385
|
var _promotionCode = _interopRequireDefault(require("./components/promotion-code"));
|
|
386
|
+
var _sourceDataViewer = _interopRequireDefault(require("./components/source-data-viewer"));
|
|
379
387
|
var _theme = require("./theme");
|
|
380
388
|
var _util = require("./libs/util");
|
|
381
389
|
Object.keys(_util).forEach(function (key) {
|
package/lib/locales/en.js
CHANGED
package/lib/locales/zh.js
CHANGED
|
@@ -114,7 +114,8 @@ module.exports = (0, _flat.default)({
|
|
|
114
114
|
confirm: "\u786E\u8BA4",
|
|
115
115
|
cancel: "\u53D6\u6D88"
|
|
116
116
|
},
|
|
117
|
-
paymentMethod: "\u652F\u4ED8\u65B9\u5F0F"
|
|
117
|
+
paymentMethod: "\u652F\u4ED8\u65B9\u5F0F",
|
|
118
|
+
viewInvoice: "\u67E5\u770B\u8D26\u5355"
|
|
118
119
|
},
|
|
119
120
|
payment: {
|
|
120
121
|
checkout: {
|