@blocklet/payment-react 1.24.2 → 1.24.3

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/locales/zh.js CHANGED
@@ -65,14 +65,24 @@ export default flat({
65
65
  remainingBalance: "\u5269\u4F59\u4F59\u989D",
66
66
  credits: "\u989D\u5EA6",
67
67
  ofCredits: "\u989D\u5EA6",
68
+ creditActivity: {
69
+ consumption: "\u989D\u5EA6\u6D88\u8017",
70
+ paidGrant: "\u989D\u5EA6\u5145\u503C",
71
+ paidAmount: "\u652F\u4ED8 {amount}",
72
+ promotionalGrant: "\u8D60\u9001",
73
+ resetGrant: "\u989D\u5EA6\u91CD\u7F6E",
74
+ repayment: "\u652F\u4ED8\u6B20\u8D39"
75
+ },
68
76
  transferStatus: "\u4EA4\u6613\u72B6\u6001",
69
77
  sourceData: "\u6E90\u6570\u636E",
70
78
  viewGrant: "\u67E5\u770B\u989D\u5EA6",
71
- viewSubscription: "\u67E5\u770B\u8BA2\u9605",
79
+ viewSubscription: "\u8BA2\u9605\u8BE6\u60C5",
72
80
  view: "\u67E5\u770B",
73
81
  meterEvent: "\u8BA1\u91CF\u4E8B\u4EF6",
74
82
  source: "\u6765\u6E90",
75
83
  viewDetail: "\u67E5\u770B\u8BE6\u60C5",
84
+ viewTransactionDetail: "\u4EA4\u6613\u8BE6\u60C5",
85
+ viewConsumptionDetail: "\u6D88\u8D39\u8BE6\u60C5",
76
86
  customer: "\u5BA2\u6237",
77
87
  currency: "\u5E01\u79CD",
78
88
  custom: "\u81EA\u5B9A\u4E49",
@@ -119,6 +129,8 @@ export default flat({
119
129
  slashStakeAmount: "\u7F5A\u6CA1\u91D1\u989D",
120
130
  know: "\u6211\u77E5\u9053\u4E86",
121
131
  relatedSubscription: "\u8BA2\u9605",
132
+ subscriptionOrCredit: "\u8BA2\u9605 / \u989D\u5EA6",
133
+ purchaseItems: "\u8D2D\u4E70\u9879",
122
134
  connect: {
123
135
  defaultScan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21\u64CD\u4F5C",
124
136
  scan: "\u4F7F\u7528\u4EE5\u4E0B\u65B9\u5F0F\u5B8C\u6210\u672C\u6B21{action}",
@@ -126,8 +138,10 @@ export default flat({
126
138
  cancel: "\u53D6\u6D88"
127
139
  },
128
140
  paymentMethod: "\u652F\u4ED8\u65B9\u5F0F",
129
- viewInvoice: "\u67E5\u770B\u8D26\u5355",
130
- submit: "\u63D0\u4EA4"
141
+ viewInvoice: "\u8D26\u5355\u8BE6\u60C5",
142
+ submit: "\u63D0\u4EA4",
143
+ expired: "\u5DF2\u8FC7\u671F",
144
+ consumed: "\u5DF2\u6D88\u8D39"
131
145
  },
132
146
  payment: {
133
147
  checkout: {
@@ -490,7 +504,9 @@ export default flat({
490
504
  payBatch: "\u652F\u4ED8\u6B20\u6B3E",
491
505
  paymentConfirmTitle: "\u652F\u4ED8\u786E\u8BA4",
492
506
  paymentConfirmDescription: "\u5B8C\u6210\u672C\u6B21\u652F\u4ED8\u540E\uFF0C\u60A8\u4F7F\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\u5C06\u81EA\u52A8\u8BBE\u7F6E\u4E3A\u8BE5\u8BA2\u9605\u7684\u9ED8\u8BA4\u652F\u4ED8\u65B9\u5F0F\u3002\u6B64\u5916\uFF0C\u6211\u4EEC\u8FD8\u5C06\u5BF9\u8BE5\u8BA2\u9605\u7684\u5176\u4ED6\u6B20\u8D39\u8D26\u5355\u8FDB\u884C\u91CD\u8BD5\u6536\u8D39\u3002",
493
- continue: "\u7EE7\u7EED"
507
+ continue: "\u7EE7\u7EED",
508
+ credit: "\u989D\u5EA6",
509
+ creditRefresh: "\u6BCF{interval}{unit}\u5237\u65B0"
494
510
  },
495
511
  payment: {
496
512
  empty: "\u6CA1\u6709\u652F\u4ED8\u8BB0\u5F55",
@@ -106,7 +106,9 @@ export default function ProductItem({
106
106
  if (!isCreditProduct || !pendingAmount) return null;
107
107
  const pendingAmountBN = new BN(pendingAmount || "0");
108
108
  if (!pendingAmountBN.gt(new BN(0))) return null;
109
+ if (!creditAmount || creditAmount <= 0) return null;
109
110
  const creditAmountBN = fromTokenToUnit(creditAmount, creditCurrency?.decimal || 2);
111
+ if (!creditAmountBN || creditAmountBN.isZero()) return null;
110
112
  return Math.ceil(pendingAmountBN.mul(new BN(100)).div(creditAmountBN).toNumber() / 100);
111
113
  }, [isCreditProduct, pendingAmount, creditAmount, creditCurrency?.decimal]);
112
114
  const initialQuantity = useMemo(() => {
@@ -13,6 +13,7 @@ var _ahooks = require("ahooks");
13
13
  var _react = require("react");
14
14
  var _axios = _interopRequireDefault(require("axios"));
15
15
  var _ufo = require("ufo");
16
+ var _useBus = _interopRequireDefault(require("use-bus"));
16
17
  var _api = _interopRequireDefault(require("../libs/api"));
17
18
  var _util = require("../libs/util");
18
19
  var _cachedRequest = require("../libs/cached-request");
@@ -136,6 +137,9 @@ function PaymentProvider({
136
137
  } = (0, _ahooks.useRequest)(getSettings, {
137
138
  refreshDeps: [livemode]
138
139
  });
140
+ (0, _useBus.default)(
141
+ // @ts-ignore
142
+ ["paymentMethod.created", "paymentMethod.updated", "paymentCurrency.added", "paymentCurrency.updated"], () => run(true), [run]);
139
143
  (0, _react.useEffect)(() => {
140
144
  const didSpace = session?.user?.didSpace;
141
145
  const userDid = session?.user?.did;
@@ -50,16 +50,101 @@ const getInvoiceDetailLink = (invoiceId, inDashboard) => {
50
50
  connect: false
51
51
  };
52
52
  };
53
- const getTransactionDetailLink = (transactionId, inDashboard) => {
54
- let path = `/customer/credit-transaction/${transactionId}`;
53
+ const getSubscriptionDetailLink = (subscriptionId, inDashboard) => {
54
+ let path = `/customer/subscription/${subscriptionId}`;
55
55
  if (inDashboard) {
56
- path = `/admin/customers/${transactionId}`;
56
+ path = `/admin/subscriptions/${subscriptionId}`;
57
57
  }
58
58
  return {
59
59
  link: (0, _navigation.createLink)(path),
60
60
  connect: false
61
61
  };
62
62
  };
63
+ const getMeterEventDetailLink = meterEventId => {
64
+ const path = `/admin/billing/${meterEventId}`;
65
+ return {
66
+ link: (0, _navigation.createLink)(path),
67
+ connect: false
68
+ };
69
+ };
70
+ const getSubscriptionId = item => item.metadata?.subscription_id || item.subscription_id || item.invoice?.subscription_id;
71
+ const getInvoiceId = item => item.metadata?.invoice_id || item.invoice?.id;
72
+ const getMeterEventId = item => item.source || item.metadata?.meter_event_id;
73
+ const getCreditActivityFlags = item => {
74
+ const isGrant = item.activity_type === "grant";
75
+ const isScheduled = isGrant && item.metadata?.delivery_mode === "schedule";
76
+ const isDepleted = isGrant && item.status === "depleted";
77
+ const isExpired = isGrant && (item.status === "expired" || item.status === "voided");
78
+ const isInactive = isDepleted || isExpired;
79
+ return {
80
+ isGrant,
81
+ isScheduled,
82
+ isDepleted,
83
+ isExpired,
84
+ isInactive
85
+ };
86
+ };
87
+ const getTransactionDetailLink = (item, inDashboard) => {
88
+ if (item.activity_type === "grant") {
89
+ const invoiceId = getInvoiceId(item);
90
+ if (invoiceId) {
91
+ return getInvoiceDetailLink(invoiceId, inDashboard);
92
+ }
93
+ return getGrantDetailLink(item.id, inDashboard);
94
+ }
95
+ const meterEventId = getMeterEventId(item);
96
+ if (!meterEventId) {
97
+ return null;
98
+ }
99
+ return getMeterEventDetailLink(meterEventId);
100
+ };
101
+ const getTransactionDescription = (item, t) => {
102
+ const {
103
+ isGrant,
104
+ isScheduled,
105
+ isInactive
106
+ } = getCreditActivityFlags(item);
107
+ const isPaid = isGrant && item.category === "paid" && (!isScheduled || item.metadata?.schedule_seq === 1);
108
+ if (!isGrant) {
109
+ const secondLine = item.metadata?.is_repayment ? t("common.creditActivity.repayment") : item.description || "";
110
+ return {
111
+ isGrant,
112
+ isInactive,
113
+ activityType: t("common.creditActivity.consumption"),
114
+ secondLine
115
+ };
116
+ }
117
+ if (isPaid) {
118
+ let secondLine = item.description || "";
119
+ if (item.invoice?.total && item.invoice?.paymentCurrency) {
120
+ const invoiceCurrency = item.invoice.paymentCurrency;
121
+ const paidAmount = (0, _util.formatCreditAmount)((0, _util.formatBNStr)(item.invoice.total, invoiceCurrency.decimal || 0), invoiceCurrency.symbol || "");
122
+ secondLine = t("common.creditActivity.paidAmount", {
123
+ amount: paidAmount
124
+ });
125
+ }
126
+ return {
127
+ isGrant,
128
+ isInactive,
129
+ activityType: t("common.creditActivity.paidGrant"),
130
+ secondLine
131
+ };
132
+ }
133
+ if (isScheduled) {
134
+ return {
135
+ isGrant,
136
+ isInactive,
137
+ activityType: t("common.creditActivity.resetGrant"),
138
+ secondLine: item.description || ""
139
+ };
140
+ }
141
+ return {
142
+ isGrant,
143
+ isInactive,
144
+ activityType: t("common.creditActivity.promotionalGrant"),
145
+ secondLine: item.description || ""
146
+ };
147
+ };
63
148
  const TransactionsTable = _react.default.memo(props => {
64
149
  const {
65
150
  pageSize,
@@ -82,6 +167,7 @@ const TransactionsTable = _react.default.memo(props => {
82
167
  session
83
168
  } = (0, _payment.usePaymentContext)();
84
169
  const isAdmin = ["owner", "admin"].includes(session?.user?.role || "");
170
+ const isDashboard = isAdmin && mode === "dashboard";
85
171
  const navigate = (0, _reactRouterDom.useNavigate)();
86
172
  const effectiveCustomerId = customer_id || session?.user?.did;
87
173
  const [search, setSearch] = (0, _react.useState)({
@@ -92,7 +178,7 @@ const TransactionsTable = _react.default.memo(props => {
92
178
  start: void 0,
93
179
  end: void 0
94
180
  });
95
- const handleDateRangeChange = (0, _react.useCallback)(newValue => {
181
+ const handleDateRangeChange = newValue => {
96
182
  setFilters(newValue);
97
183
  setSearch(prev => ({
98
184
  ...prev,
@@ -100,7 +186,7 @@ const TransactionsTable = _react.default.memo(props => {
100
186
  start: newValue.start || void 0,
101
187
  end: newValue.end || void 0
102
188
  }));
103
- }, []);
189
+ };
104
190
  const {
105
191
  loading,
106
192
  data = {
@@ -119,9 +205,14 @@ const TransactionsTable = _react.default.memo(props => {
119
205
  });
120
206
  (0, _react.useEffect)(() => {
121
207
  if (showTimeFilter && !search.start && !search.end) {
122
- handleDateRangeChange(filters);
208
+ setSearch(prev => ({
209
+ ...prev,
210
+ page: 1,
211
+ start: filters.start || void 0,
212
+ end: filters.end || void 0
213
+ }));
123
214
  }
124
- }, [showTimeFilter, handleDateRangeChange, search.start, search.end, filters]);
215
+ }, [showTimeFilter, search.start, search.end, filters.start, filters.end]);
125
216
  const prevData = (0, _react.useRef)(data);
126
217
  (0, _react.useEffect)(() => {
127
218
  if (onTableDataChange) {
@@ -130,127 +221,168 @@ const TransactionsTable = _react.default.memo(props => {
130
221
  }
131
222
  }, [data]);
132
223
  const handleTransactionClick = (e, item) => {
133
- if (item.activity_type === "grant") {
134
- const {
135
- link
136
- } = getGrantDetailLink(item.id, isAdmin && mode === "dashboard");
137
- (0, _navigation.handleNavigation)(e, link, navigate, {
138
- target: link.external ? "_blank" : "_self"
139
- });
140
- } else {
141
- const {
142
- link
143
- } = getTransactionDetailLink(item.id, isAdmin && mode === "dashboard");
144
- (0, _navigation.handleNavigation)(e, link, navigate, {
145
- target: link.external ? "_blank" : "_self"
146
- });
224
+ const detail = getTransactionDetailLink(item, isDashboard);
225
+ if (!detail) {
226
+ return;
147
227
  }
228
+ (0, _navigation.handleNavigation)(e, detail.link, navigate, {
229
+ target: detail.link.external ? "_blank" : "_self"
230
+ });
231
+ };
232
+ const openSubscription = (e, subscriptionId) => {
233
+ e.preventDefault();
234
+ const link = getSubscriptionDetailLink(subscriptionId, isDashboard);
235
+ (0, _navigation.handleNavigation)(e, link.link, navigate);
148
236
  };
237
+ const openInvoice = (e, invoiceId) => {
238
+ e.preventDefault();
239
+ const link = getInvoiceDetailLink(invoiceId, isDashboard);
240
+ (0, _navigation.handleNavigation)(e, link.link, navigate);
241
+ };
242
+ const renderActionButton = (label, onClick) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
243
+ variant: "text",
244
+ size: "small",
245
+ color: "primary",
246
+ sx: {
247
+ whiteSpace: "nowrap"
248
+ },
249
+ onClick,
250
+ children: label
251
+ });
149
252
  const columns = [{
150
- label: t("common.amount"),
151
- name: "credit_amount",
152
- align: "right",
253
+ label: t("common.date"),
254
+ name: "created_at",
153
255
  options: {
256
+ setCellProps: () => ({
257
+ style: {
258
+ width: "25%"
259
+ }
260
+ }),
154
261
  customBodyRenderLite: (_, index) => {
155
262
  const item = data?.list[index];
156
- const isGrant = item.activity_type === "grant";
157
- const isExpiredGrant = isGrant && item.status === "expired";
158
- const amount = isGrant ? item.amount : item.credit_amount;
159
- const currency = item.paymentCurrency || item.currency;
160
- const unit = !isGrant && item.meter?.unit ? item.meter.unit : currency?.symbol;
161
- const displayAmount = (0, _util.formatCreditAmount)((0, _util.formatBNStr)(amount, currency?.decimal || 0), unit);
162
- if (!includeGrants) {
163
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
164
- onClick: e => handleTransactionClick(e, item),
165
- children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
166
- children: displayAmount
167
- })
168
- });
169
- }
170
- const amountNode = /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
171
- sx: {
172
- color: isGrant ? isExpiredGrant ? "text.disabled" : "success.main" : "error.main"
173
- },
174
- children: [isGrant ? "+" : "-", " ", displayAmount]
175
- });
176
263
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
177
264
  onClick: e => handleTransactionClick(e, item),
178
- children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
179
- direction: "row",
180
- spacing: 1,
181
- alignItems: "center",
182
- justifyContent: "flex-end",
265
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
266
+ variant: "body2",
183
267
  sx: {
184
- width: "100%"
268
+ fontSize: "0.875rem"
185
269
  },
186
- children: [isExpiredGrant && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Chip, {
187
- label: t("admin.creditGrants.status.expired"),
188
- size: "small",
189
- variant: "outlined",
190
- sx: {
191
- mr: 2,
192
- height: 18,
193
- fontSize: "12px",
194
- color: "text.disabled",
195
- borderColor: "text.disabled"
196
- }
197
- }), amountNode]
270
+ children: (0, _util.formatToDate)(item.created_at, locale, "YYYY-MM-DD HH:mm")
198
271
  })
199
272
  });
200
273
  }
201
274
  }
202
275
  }, {
203
- label: t("common.creditGrant"),
204
- name: "credit_grant",
276
+ label: t("common.description"),
277
+ name: "description",
205
278
  options: {
279
+ setCellProps: () => ({
280
+ style: {
281
+ width: "25%"
282
+ }
283
+ }),
206
284
  customBodyRenderLite: (_, index) => {
207
285
  const item = data?.list[index];
208
- const isGrant = item.activity_type === "grant";
209
- const isExpiredGrant = isGrant && item.status === "expired";
210
- const grantName = isGrant ? item.name : item.creditGrant.name;
211
- const grantId = isGrant ? item.id : item.credit_grant_id;
212
- const nameNode = /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
213
- variant: "body2",
214
- sx: {
215
- cursor: "pointer",
216
- color: isExpiredGrant ? "text.disabled" : void 0
217
- },
218
- children: grantName || `Grant ${grantId.slice(-6)}`
219
- });
220
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
221
- direction: "row",
222
- spacing: 1,
223
- onClick: e => {
224
- const link = getGrantDetailLink(grantId, isAdmin && mode === "dashboard");
225
- (0, _navigation.handleNavigation)(e, link.link, navigate);
226
- },
286
+ const {
287
+ activityType,
288
+ secondLine,
289
+ isInactive,
290
+ isGrant
291
+ } = getTransactionDescription(item, t);
292
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
293
+ onClick: e => handleTransactionClick(e, item),
227
294
  sx: {
228
- alignItems: "center"
295
+ cursor: "pointer"
229
296
  },
230
- children: nameNode
297
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
298
+ direction: "column",
299
+ spacing: 0.25,
300
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
301
+ variant: "body2",
302
+ sx: {
303
+ color: isInactive ? "text.secondary" : isGrant ? "success.main" : "error.main"
304
+ },
305
+ children: activityType
306
+ }), secondLine && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
307
+ variant: "caption",
308
+ sx: {
309
+ color: "text.secondary"
310
+ },
311
+ children: secondLine
312
+ })]
313
+ })
231
314
  });
232
315
  }
233
316
  }
234
317
  }, {
235
- label: t("common.description"),
236
- name: "description",
318
+ label: t("common.amount"),
319
+ name: "credit_amount",
320
+ align: "right",
237
321
  options: {
322
+ setCellProps: () => ({
323
+ style: {
324
+ width: "20%"
325
+ }
326
+ }),
327
+ customHeadLabelRender: () => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
328
+ sx: {
329
+ pr: 5
330
+ },
331
+ children: t("common.amount")
332
+ }),
238
333
  customBodyRenderLite: (_, index) => {
239
334
  const item = data?.list[index];
240
- const isGrant = item.activity_type === "grant";
241
- const isExpiredGrant = isGrant && item.status === "expired";
242
- const description = isGrant ? item.name || item.description || "Credit Granted" : item.subscription?.description || item.description || `${item.meter_event_name} usage`;
243
- const descriptionNode = /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
244
- variant: "body2",
245
- sx: {
246
- fontWeight: 400,
247
- color: isExpiredGrant ? "text.disabled" : void 0
248
- },
249
- children: description
250
- });
335
+ const {
336
+ isGrant,
337
+ isDepleted,
338
+ isExpired,
339
+ isInactive
340
+ } = getCreditActivityFlags(item);
341
+ const amount = isGrant ? item.amount : item.credit_amount;
342
+ const currency = item.paymentCurrency || item.currency;
343
+ const unit = !isGrant && item.meter?.unit ? item.meter.unit : currency?.symbol;
344
+ const displayAmount = (0, _util.formatCreditAmount)((0, _util.formatBNStr)(amount, currency?.decimal || 0), unit);
345
+ if (!includeGrants) {
346
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
347
+ onClick: e => handleTransactionClick(e, item),
348
+ sx: {
349
+ pr: 5
350
+ },
351
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
352
+ children: displayAmount
353
+ })
354
+ });
355
+ }
251
356
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
252
357
  onClick: e => handleTransactionClick(e, item),
253
- children: descriptionNode
358
+ sx: {
359
+ pr: 5
360
+ },
361
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
362
+ direction: "column",
363
+ spacing: 0.25,
364
+ alignItems: "flex-end",
365
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
366
+ sx: {
367
+ fontWeight: 500,
368
+ color: isInactive ? "text.secondary" : isGrant ? "success.main" : "error.main",
369
+ whiteSpace: "nowrap"
370
+ },
371
+ children: [isGrant ? "+" : "-", " ", displayAmount]
372
+ }), isDepleted ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
373
+ variant: "caption",
374
+ sx: {
375
+ color: "text.secondary"
376
+ },
377
+ children: t("common.consumed")
378
+ }) : isExpired ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
379
+ variant: "caption",
380
+ sx: {
381
+ color: "text.secondary"
382
+ },
383
+ children: t("common.expired")
384
+ }) : null]
385
+ })
254
386
  });
255
387
  }
256
388
  }
@@ -279,59 +411,32 @@ const TransactionsTable = _react.default.memo(props => {
279
411
  }
280
412
  }
281
413
  }] : []), {
282
- label: t("common.date"),
283
- name: "created_at",
284
- options: {
285
- customBodyRenderLite: (_, index) => {
286
- const item = data?.list[index];
287
- return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
288
- onClick: e => handleTransactionClick(e, item),
289
- children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
290
- variant: "body2",
291
- sx: {
292
- color: "text.secondary",
293
- fontSize: "0.875rem"
294
- },
295
- children: (0, _util.formatToDate)(item.created_at, locale, "YYYY-MM-DD HH:mm")
296
- })
297
- });
298
- }
299
- }
300
- }, {
301
414
  label: t("common.actions"),
302
415
  name: "actions",
303
416
  options: {
417
+ setCellProps: () => ({
418
+ style: {
419
+ width: "25%"
420
+ }
421
+ }),
304
422
  customBodyRenderLite: (_, index) => {
305
423
  const item = data?.list[index];
306
- const isGrant = item.activity_type === "grant";
307
- const invoiceId = isGrant ? item.metadata?.invoice_id : null;
424
+ const {
425
+ isGrant,
426
+ isScheduled
427
+ } = getCreditActivityFlags(item);
428
+ const isPaid = isGrant && item.category === "paid" && !isScheduled;
429
+ const subscriptionId = getSubscriptionId(item);
430
+ const invoiceId = isGrant ? getInvoiceId(item) : null;
431
+ const shouldShowSubscription = Boolean(subscriptionId) && (!isGrant || isScheduled || isPaid);
308
432
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
309
433
  sx: {
310
434
  display: "flex",
311
435
  gap: 1,
312
- alignItems: "center"
436
+ alignItems: "center",
437
+ flexWrap: "nowrap"
313
438
  },
314
- children: [isGrant && invoiceId && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
315
- variant: "text",
316
- size: "small",
317
- color: "primary",
318
- onClick: e => {
319
- e.preventDefault();
320
- const link = getInvoiceDetailLink(invoiceId, isAdmin && mode === "dashboard");
321
- (0, _navigation.handleNavigation)(e, link.link, navigate);
322
- },
323
- children: t("common.viewInvoice")
324
- }), !isGrant && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
325
- variant: "text",
326
- size: "small",
327
- color: "primary",
328
- onClick: e => {
329
- e.preventDefault();
330
- const link = getTransactionDetailLink(item.id, isAdmin && mode === "dashboard");
331
- (0, _navigation.handleNavigation)(e, link.link, navigate);
332
- },
333
- children: t("common.viewDetail")
334
- })]
439
+ children: [shouldShowSubscription && subscriptionId ? renderActionButton(t("common.viewSubscription"), e => openSubscription(e, subscriptionId)) : null, isPaid && invoiceId ? renderActionButton(t("common.viewInvoice"), e => openInvoice(e, invoiceId)) : null]
335
440
  });
336
441
  }
337
442
  }