@blocklet/payment-react 1.24.2 → 1.24.4

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,111 @@ 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/billing/${subscriptionId}`;
57
57
  }
58
58
  return {
59
59
  link: (0, _navigation.createLink)(path),
60
60
  connect: false
61
61
  };
62
62
  };
63
+ const getCreditTransactionDetailLink = transactionId => {
64
+ const path = `/customer/credit-transaction/${transactionId}`;
65
+ return {
66
+ link: (0, _navigation.createLink)(path),
67
+ connect: false
68
+ };
69
+ };
70
+ const getMeterEventDetailLink = meterEventId => {
71
+ const path = `/admin/billing/${meterEventId}`;
72
+ return {
73
+ link: (0, _navigation.createLink)(path),
74
+ connect: false
75
+ };
76
+ };
77
+ const getSubscriptionId = item => item.metadata?.subscription_id || item.subscription_id || item.invoice?.subscription_id;
78
+ const getInvoiceId = item => item.metadata?.invoice_id || item.invoice?.id;
79
+ const getMeterEventId = item => item.source || item.metadata?.meter_event_id;
80
+ const getCreditActivityFlags = item => {
81
+ const isGrant = item.activity_type === "grant";
82
+ const isScheduled = isGrant && item.metadata?.delivery_mode === "schedule";
83
+ const isDepleted = isGrant && item.status === "depleted";
84
+ const isExpired = isGrant && (item.status === "expired" || item.status === "voided");
85
+ const isInactive = isDepleted || isExpired;
86
+ return {
87
+ isGrant,
88
+ isScheduled,
89
+ isDepleted,
90
+ isExpired,
91
+ isInactive
92
+ };
93
+ };
94
+ const getTransactionDetailLink = (item, inDashboard) => {
95
+ if (item.activity_type === "grant") {
96
+ const invoiceId = getInvoiceId(item);
97
+ if (invoiceId) {
98
+ return getInvoiceDetailLink(invoiceId, inDashboard);
99
+ }
100
+ return getGrantDetailLink(item.id, inDashboard);
101
+ }
102
+ if (!inDashboard) {
103
+ return getCreditTransactionDetailLink(item.id);
104
+ }
105
+ const meterEventId = getMeterEventId(item);
106
+ if (!meterEventId) {
107
+ return null;
108
+ }
109
+ return getMeterEventDetailLink(meterEventId);
110
+ };
111
+ const getTransactionDescription = (item, t) => {
112
+ const {
113
+ isGrant,
114
+ isScheduled,
115
+ isInactive
116
+ } = getCreditActivityFlags(item);
117
+ const isPaid = isGrant && item.category === "paid" && (!isScheduled || item.metadata?.schedule_seq === 1);
118
+ if (!isGrant) {
119
+ const secondLine = item.metadata?.is_repayment ? t("common.creditActivity.repayment") : item.description || "";
120
+ return {
121
+ isGrant,
122
+ isInactive,
123
+ activityType: t("common.creditActivity.consumption"),
124
+ secondLine
125
+ };
126
+ }
127
+ if (isPaid) {
128
+ let secondLine = item.description || "";
129
+ if (item.invoice?.total && item.invoice?.paymentCurrency) {
130
+ const invoiceCurrency = item.invoice.paymentCurrency;
131
+ const paidAmount = (0, _util.formatCreditAmount)((0, _util.formatBNStr)(item.invoice.total, invoiceCurrency.decimal || 0), invoiceCurrency.symbol || "");
132
+ secondLine = t("common.creditActivity.paidAmount", {
133
+ amount: paidAmount
134
+ });
135
+ }
136
+ return {
137
+ isGrant,
138
+ isInactive,
139
+ activityType: t("common.creditActivity.paidGrant"),
140
+ secondLine
141
+ };
142
+ }
143
+ if (isScheduled) {
144
+ return {
145
+ isGrant,
146
+ isInactive,
147
+ activityType: t("common.creditActivity.resetGrant"),
148
+ secondLine: item.description || ""
149
+ };
150
+ }
151
+ return {
152
+ isGrant,
153
+ isInactive,
154
+ activityType: t("common.creditActivity.promotionalGrant"),
155
+ secondLine: item.description || ""
156
+ };
157
+ };
63
158
  const TransactionsTable = _react.default.memo(props => {
64
159
  const {
65
160
  pageSize,
@@ -82,6 +177,7 @@ const TransactionsTable = _react.default.memo(props => {
82
177
  session
83
178
  } = (0, _payment.usePaymentContext)();
84
179
  const isAdmin = ["owner", "admin"].includes(session?.user?.role || "");
180
+ const isDashboard = isAdmin && mode === "dashboard";
85
181
  const navigate = (0, _reactRouterDom.useNavigate)();
86
182
  const effectiveCustomerId = customer_id || session?.user?.did;
87
183
  const [search, setSearch] = (0, _react.useState)({
@@ -92,7 +188,7 @@ const TransactionsTable = _react.default.memo(props => {
92
188
  start: void 0,
93
189
  end: void 0
94
190
  });
95
- const handleDateRangeChange = (0, _react.useCallback)(newValue => {
191
+ const handleDateRangeChange = newValue => {
96
192
  setFilters(newValue);
97
193
  setSearch(prev => ({
98
194
  ...prev,
@@ -100,7 +196,7 @@ const TransactionsTable = _react.default.memo(props => {
100
196
  start: newValue.start || void 0,
101
197
  end: newValue.end || void 0
102
198
  }));
103
- }, []);
199
+ };
104
200
  const {
105
201
  loading,
106
202
  data = {
@@ -119,9 +215,14 @@ const TransactionsTable = _react.default.memo(props => {
119
215
  });
120
216
  (0, _react.useEffect)(() => {
121
217
  if (showTimeFilter && !search.start && !search.end) {
122
- handleDateRangeChange(filters);
218
+ setSearch(prev => ({
219
+ ...prev,
220
+ page: 1,
221
+ start: filters.start || void 0,
222
+ end: filters.end || void 0
223
+ }));
123
224
  }
124
- }, [showTimeFilter, handleDateRangeChange, search.start, search.end, filters]);
225
+ }, [showTimeFilter, search.start, search.end, filters.start, filters.end]);
125
226
  const prevData = (0, _react.useRef)(data);
126
227
  (0, _react.useEffect)(() => {
127
228
  if (onTableDataChange) {
@@ -130,127 +231,168 @@ const TransactionsTable = _react.default.memo(props => {
130
231
  }
131
232
  }, [data]);
132
233
  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
- });
234
+ const detail = getTransactionDetailLink(item, isDashboard);
235
+ if (!detail) {
236
+ return;
147
237
  }
238
+ (0, _navigation.handleNavigation)(e, detail.link, navigate, {
239
+ target: detail.link.external ? "_blank" : "_self"
240
+ });
241
+ };
242
+ const openSubscription = (e, subscriptionId) => {
243
+ e.preventDefault();
244
+ const link = getSubscriptionDetailLink(subscriptionId, isDashboard);
245
+ (0, _navigation.handleNavigation)(e, link.link, navigate);
246
+ };
247
+ const openInvoice = (e, invoiceId) => {
248
+ e.preventDefault();
249
+ const link = getInvoiceDetailLink(invoiceId, isDashboard);
250
+ (0, _navigation.handleNavigation)(e, link.link, navigate);
148
251
  };
252
+ const renderActionButton = (label, onClick) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Button, {
253
+ variant: "text",
254
+ size: "small",
255
+ color: "primary",
256
+ sx: {
257
+ whiteSpace: "nowrap"
258
+ },
259
+ onClick,
260
+ children: label
261
+ });
149
262
  const columns = [{
150
- label: t("common.amount"),
151
- name: "credit_amount",
152
- align: "right",
263
+ label: t("common.date"),
264
+ name: "created_at",
153
265
  options: {
266
+ setCellProps: () => ({
267
+ style: {
268
+ width: "25%"
269
+ }
270
+ }),
154
271
  customBodyRenderLite: (_, index) => {
155
272
  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
273
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
177
274
  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",
275
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
276
+ variant: "body2",
183
277
  sx: {
184
- width: "100%"
278
+ fontSize: "0.875rem"
185
279
  },
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]
280
+ children: (0, _util.formatToDate)(item.created_at, locale, "YYYY-MM-DD HH:mm")
198
281
  })
199
282
  });
200
283
  }
201
284
  }
202
285
  }, {
203
- label: t("common.creditGrant"),
204
- name: "credit_grant",
286
+ label: t("common.description"),
287
+ name: "description",
205
288
  options: {
289
+ setCellProps: () => ({
290
+ style: {
291
+ width: "25%"
292
+ }
293
+ }),
206
294
  customBodyRenderLite: (_, index) => {
207
295
  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
- },
296
+ const {
297
+ activityType,
298
+ secondLine,
299
+ isInactive,
300
+ isGrant
301
+ } = getTransactionDescription(item, t);
302
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
303
+ onClick: e => handleTransactionClick(e, item),
227
304
  sx: {
228
- alignItems: "center"
305
+ cursor: "pointer"
229
306
  },
230
- children: nameNode
307
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
308
+ direction: "column",
309
+ spacing: 0.25,
310
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
311
+ variant: "body2",
312
+ sx: {
313
+ color: isInactive ? "text.secondary" : isGrant ? "success.main" : "error.main"
314
+ },
315
+ children: activityType
316
+ }), secondLine && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
317
+ variant: "caption",
318
+ sx: {
319
+ color: "text.secondary"
320
+ },
321
+ children: secondLine
322
+ })]
323
+ })
231
324
  });
232
325
  }
233
326
  }
234
327
  }, {
235
- label: t("common.description"),
236
- name: "description",
328
+ label: t("common.amount"),
329
+ name: "credit_amount",
330
+ align: "right",
237
331
  options: {
332
+ setCellProps: () => ({
333
+ style: {
334
+ width: "20%"
335
+ }
336
+ }),
337
+ customHeadLabelRender: () => /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
338
+ sx: {
339
+ pr: 5
340
+ },
341
+ children: t("common.amount")
342
+ }),
238
343
  customBodyRenderLite: (_, index) => {
239
344
  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
- });
345
+ const {
346
+ isGrant,
347
+ isDepleted,
348
+ isExpired,
349
+ isInactive
350
+ } = getCreditActivityFlags(item);
351
+ const amount = isGrant ? item.amount : item.credit_amount;
352
+ const currency = item.paymentCurrency || item.currency;
353
+ const unit = !isGrant && item.meter?.unit ? item.meter.unit : currency?.symbol;
354
+ const displayAmount = (0, _util.formatCreditAmount)((0, _util.formatBNStr)(amount, currency?.decimal || 0), unit);
355
+ if (!includeGrants) {
356
+ return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
357
+ onClick: e => handleTransactionClick(e, item),
358
+ sx: {
359
+ pr: 5
360
+ },
361
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
362
+ children: displayAmount
363
+ })
364
+ });
365
+ }
251
366
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
252
367
  onClick: e => handleTransactionClick(e, item),
253
- children: descriptionNode
368
+ sx: {
369
+ pr: 5
370
+ },
371
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
372
+ direction: "column",
373
+ spacing: 0.25,
374
+ alignItems: "flex-end",
375
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
376
+ sx: {
377
+ fontWeight: 500,
378
+ color: isInactive ? "text.secondary" : isGrant ? "success.main" : "error.main",
379
+ whiteSpace: "nowrap"
380
+ },
381
+ children: [isGrant ? "+" : "-", " ", displayAmount]
382
+ }), isDepleted ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
383
+ variant: "caption",
384
+ sx: {
385
+ color: "text.secondary"
386
+ },
387
+ children: t("common.consumed")
388
+ }) : isExpired ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
389
+ variant: "caption",
390
+ sx: {
391
+ color: "text.secondary"
392
+ },
393
+ children: t("common.expired")
394
+ }) : null]
395
+ })
254
396
  });
255
397
  }
256
398
  }
@@ -279,59 +421,32 @@ const TransactionsTable = _react.default.memo(props => {
279
421
  }
280
422
  }
281
423
  }] : []), {
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
424
  label: t("common.actions"),
302
425
  name: "actions",
303
426
  options: {
427
+ setCellProps: () => ({
428
+ style: {
429
+ width: "25%"
430
+ }
431
+ }),
304
432
  customBodyRenderLite: (_, index) => {
305
433
  const item = data?.list[index];
306
- const isGrant = item.activity_type === "grant";
307
- const invoiceId = isGrant ? item.metadata?.invoice_id : null;
434
+ const {
435
+ isGrant,
436
+ isScheduled
437
+ } = getCreditActivityFlags(item);
438
+ const isPaid = isGrant && item.category === "paid" && !isScheduled;
439
+ const subscriptionId = getSubscriptionId(item);
440
+ const invoiceId = isGrant ? getInvoiceId(item) : null;
441
+ const shouldShowSubscription = Boolean(subscriptionId) && (!isGrant || isScheduled || isPaid);
308
442
  return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
309
443
  sx: {
310
444
  display: "flex",
311
445
  gap: 1,
312
- alignItems: "center"
446
+ alignItems: "center",
447
+ flexWrap: "nowrap"
313
448
  },
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
- })]
449
+ children: [shouldShowSubscription && subscriptionId ? renderActionButton(t("common.viewSubscription"), e => openSubscription(e, subscriptionId)) : null, isPaid && invoiceId ? renderActionButton(t("common.viewInvoice"), e => openInvoice(e, invoiceId)) : null]
335
450
  });
336
451
  }
337
452
  }