@blocklet/payment-react 1.18.15 → 1.18.17

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.
@@ -15,7 +15,7 @@ import {
15
15
  } from "@mui/material";
16
16
  import { useRequest, useSetState } from "ahooks";
17
17
  import omit from "lodash/omit";
18
- import uniqBy from "lodash/unionBy";
18
+ import uniqBy from "lodash/uniqBy";
19
19
  import { useEffect, useRef, useState } from "react";
20
20
  import { Settings } from "@mui/icons-material";
21
21
  import api from "../libs/api.js";
@@ -111,11 +111,14 @@ export function DonateDetails({ supporters = [], currency, method }) {
111
111
  Avatar,
112
112
  {
113
113
  src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 20),
114
- alt: x.customer?.name,
114
+ alt: x.customer?.metadata?.anonymous ? "" : x.customer?.name,
115
115
  variant: "circular",
116
116
  sx: { width: 20, height: 20 },
117
117
  onClick: (e) => {
118
118
  e.stopPropagation();
119
+ if (x.customer?.metadata?.anonymous) {
120
+ return;
121
+ }
119
122
  if (x.customer?.did) {
120
123
  window.open(getUserProfileLink(x.customer?.did, locale), "_blank");
121
124
  }
@@ -135,6 +138,9 @@ export function DonateDetails({ supporters = [], currency, method }) {
135
138
  textOverflow: "ellipsis"
136
139
  },
137
140
  onClick: (e) => {
141
+ if (x.customer?.metadata?.anonymous) {
142
+ return;
143
+ }
138
144
  e.stopPropagation();
139
145
  if (x.customer?.did) {
140
146
  window.open(getUserProfileLink(x.customer?.did, locale), "_blank");
@@ -175,7 +181,7 @@ function SupporterAvatar({
175
181
  showDonateDetails = false
176
182
  }) {
177
183
  const [open, setOpen] = useState(false);
178
- const customers = uniqBy(supporters, "customer_did");
184
+ const customers = uniqBy(supporters, "customer_id");
179
185
  const customersNum = customers.length;
180
186
  if (customersNum === 0)
181
187
  return null;
@@ -186,7 +192,10 @@ function SupporterAvatar({
186
192
  max: 5,
187
193
  sx: {
188
194
  "& .MuiAvatar-root": {
189
- backgroundColor: "background.paper"
195
+ backgroundColor: "background.paper",
196
+ "&.MuiAvatar-colorDefault": {
197
+ backgroundColor: "#bdbdbd"
198
+ }
190
199
  }
191
200
  },
192
201
  children: customers.slice(0, 5).map((supporter) => /* @__PURE__ */ jsx(
@@ -197,7 +206,7 @@ function SupporterAvatar({
197
206
  supporter?.updated_at ? new Date(supporter.updated_at).toISOString() : "",
198
207
  24
199
208
  ),
200
- alt: supporter.customer?.name,
209
+ alt: supporter.customer?.metadata?.anonymous ? "" : supporter.customer?.name,
201
210
  sx: {
202
211
  width: "24px",
203
212
  height: "24px"
@@ -248,7 +257,7 @@ function SupporterAvatar({
248
257
  ] });
249
258
  }
250
259
  function SupporterTable({ supporters = [], totalAmount = "0", currency, method }) {
251
- const customers = uniqBy(supporters, "customer_did");
260
+ const customers = uniqBy(supporters, "customer_id");
252
261
  const customersNum = customers.length;
253
262
  if (customersNum === 0)
254
263
  return null;
@@ -259,7 +268,7 @@ function SupporterTable({ supporters = [], totalAmount = "0", currency, method }
259
268
  }
260
269
  function SupporterSimple({ supporters = [], totalAmount = "0", currency, method }) {
261
270
  const { t } = useLocaleContext();
262
- const customers = uniqBy(supporters, "customer_did");
271
+ const customers = uniqBy(supporters, "customer_id");
263
272
  const customersNum = customers.length;
264
273
  return /* @__PURE__ */ jsxs(
265
274
  Box,
@@ -281,7 +290,7 @@ function SupporterSimple({ supporters = [], totalAmount = "0", currency, method
281
290
  Avatar,
282
291
  {
283
292
  title: x.customer?.name,
284
- alt: x.customer?.name,
293
+ alt: x.customer?.metadata?.anonymous ? "" : x.customer?.name,
285
294
  src: getCustomerAvatar(x.customer?.did, x?.updated_at ? new Date(x.updated_at).toISOString() : "", 48),
286
295
  variant: "circular",
287
296
  sx: { width: 24, height: 24 }
@@ -4,19 +4,27 @@ type DialogProps = {
4
4
  onClose?: () => void;
5
5
  title?: string;
6
6
  };
7
+ type DetailLinkOptions = {
8
+ enabled?: boolean;
9
+ onClick?: (e: React.MouseEvent) => void;
10
+ title?: string;
11
+ };
7
12
  type Props = {
8
- subscriptionId: string;
13
+ subscriptionId?: string;
14
+ customerId?: string;
9
15
  mode?: 'default' | 'custom';
10
- onPaid?: (subscriptionId: string, currencyId: string) => void;
16
+ onPaid?: (id: string, currencyId: string, type: 'subscription' | 'customer') => void;
11
17
  dialogProps?: DialogProps;
12
- inSubscriptionDetail?: boolean;
18
+ detailLinkOptions?: DetailLinkOptions;
19
+ successToast?: boolean;
13
20
  children?: (handlePay: (item: SummaryItem) => void, data: {
14
- subscription: Subscription;
21
+ subscription?: Subscription;
15
22
  summary: {
16
23
  [key: string]: SummaryItem;
17
24
  };
18
25
  invoices: Invoice[];
19
- subscriptionUrl: string;
26
+ subscriptionCount?: number;
27
+ detailUrl: string;
20
28
  }) => React.ReactNode;
21
29
  };
22
30
  type SummaryItem = {
@@ -24,7 +32,7 @@ type SummaryItem = {
24
32
  currency: PaymentCurrency;
25
33
  method: PaymentMethod;
26
34
  };
27
- declare function OverdueInvoicePayment({ subscriptionId, mode, dialogProps, children, onPaid, inSubscriptionDetail, }: Props): import("react").JSX.Element | null;
35
+ declare function OverdueInvoicePayment({ subscriptionId, customerId, mode, dialogProps, children, onPaid, detailLinkOptions, successToast, }: Props): import("react").JSX.Element | null;
28
36
  declare namespace OverdueInvoicePayment {
29
37
  var defaultProps: {
30
38
  mode: string;
@@ -33,7 +41,12 @@ declare namespace OverdueInvoicePayment {
33
41
  open: boolean;
34
42
  };
35
43
  children: null;
36
- inSubscriptionDetail: boolean;
44
+ detailLinkOptions: {
45
+ enabled: boolean;
46
+ };
47
+ subscriptionId: undefined;
48
+ customerId: undefined;
49
+ successToast: boolean;
37
50
  };
38
51
  }
39
52
  export default OverdueInvoicePayment;
@@ -1,27 +1,41 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from "react";
3
- import { Button, Typography, Stack, CircularProgress, Alert } from "@mui/material";
3
+ import { Button, Typography, Stack, Alert } from "@mui/material";
4
4
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
5
5
  import Toast from "@arcblock/ux/lib/Toast";
6
6
  import { joinURL } from "ufo";
7
7
  import { useRequest } from "ahooks";
8
8
  import { Dialog } from "@arcblock/ux";
9
+ import { CheckCircle as CheckCircleIcon } from "@mui/icons-material";
10
+ import debounce from "lodash/debounce";
9
11
  import { usePaymentContext } from "../contexts/payment.js";
10
12
  import { formatAmount, formatError, getPrefix } from "../libs/util.js";
11
13
  import { useSubscription } from "../hooks/subscription.js";
12
14
  import api from "../libs/api.js";
13
- const fetchOverdueInvoices = async (subscriptionId) => {
14
- const res = await api.get(`/api/subscriptions/${subscriptionId}/overdue/invoices`);
15
+ import LoadingButton from "./loading-button.js";
16
+ const fetchOverdueInvoices = async (params) => {
17
+ if (!params.subscriptionId && !params.customerId) {
18
+ throw new Error("Either subscriptionId or customerId must be provided");
19
+ }
20
+ let url;
21
+ if (params.subscriptionId) {
22
+ url = `/api/subscriptions/${params.subscriptionId}/overdue/invoices`;
23
+ } else {
24
+ url = `/api/customers/${params.customerId}/overdue/invoices`;
25
+ }
26
+ const res = await api.get(url);
15
27
  return res.data;
16
28
  };
17
29
  function OverdueInvoicePayment({
18
30
  subscriptionId,
31
+ customerId,
19
32
  mode = "default",
20
33
  dialogProps = {},
21
34
  children,
22
35
  onPaid = () => {
23
36
  },
24
- inSubscriptionDetail = false
37
+ detailLinkOptions = { enabled: true },
38
+ successToast = true
25
39
  }) {
26
40
  const { t } = useLocaleContext();
27
41
  const { connect } = usePaymentContext();
@@ -29,42 +43,70 @@ function OverdueInvoicePayment({
29
43
  const [payLoading, setPayLoading] = useState(false);
30
44
  const [dialogOpen, setDialogOpen] = useState(dialogProps.open || false);
31
45
  const [processedCurrencies, setProcessedCurrencies] = useState({});
46
+ const [paymentStatus, setPaymentStatus] = useState({});
47
+ const sourceType = subscriptionId ? "subscription" : "customer";
48
+ const sourceId = subscriptionId || customerId;
32
49
  const {
33
50
  data = {
34
- subscription: {},
35
51
  summary: {},
36
52
  invoices: []
37
53
  },
38
54
  error,
39
55
  loading,
40
56
  runAsync: refresh
41
- } = useRequest(() => fetchOverdueInvoices(subscriptionId));
42
- const subscriptionUrl = joinURL(getPrefix(), `/customer/subscription/${subscriptionId}`);
57
+ } = useRequest(() => fetchOverdueInvoices({ subscriptionId, customerId }), {
58
+ ready: !!subscriptionId || !!customerId
59
+ });
60
+ const detailUrl = useMemo(() => {
61
+ if (subscriptionId) {
62
+ return joinURL(getPrefix(), `/customer/subscription/${subscriptionId}`);
63
+ }
64
+ if (customerId) {
65
+ return joinURL(getPrefix(), "/customer/invoice/past-due");
66
+ }
67
+ return "";
68
+ }, [subscriptionId, customerId]);
43
69
  const summaryList = useMemo(() => {
44
70
  if (!data?.summary) {
45
71
  return [];
46
72
  }
47
73
  return Object.values(data.summary);
48
74
  }, [data?.summary]);
75
+ const debouncedHandleInvoicePaid = debounce(
76
+ async (currencyId) => {
77
+ if (successToast) {
78
+ Toast.close();
79
+ Toast.success(t("payment.customer.invoice.paySuccess"));
80
+ }
81
+ setPayLoading(false);
82
+ const res = await refresh();
83
+ if (res.invoices?.length === 0) {
84
+ setDialogOpen(false);
85
+ onPaid(sourceId, currencyId, sourceType);
86
+ }
87
+ },
88
+ 1e3,
89
+ {
90
+ leading: false,
91
+ trailing: true,
92
+ maxWait: 5e3
93
+ }
94
+ );
49
95
  const subscription = useSubscription("events");
50
96
  useEffect(() => {
51
97
  if (subscription) {
52
98
  subscription.on("invoice.paid", ({ response }) => {
53
- const uniqueKey = `${response.subscription_id}-${response.currency_id}`;
54
- if (response.subscription_id === subscriptionId && !processedCurrencies[uniqueKey]) {
55
- Toast.success(t("payment.customer.invoice.paySuccess"));
56
- setPayLoading(false);
57
- setProcessedCurrencies({ ...processedCurrencies, [uniqueKey]: 1 });
58
- refresh().then((res) => {
59
- if (res.invoices?.length === 0) {
60
- setDialogOpen(false);
61
- onPaid(subscriptionId, response.currency_id);
62
- }
63
- });
99
+ const relevantId = subscriptionId || response.customer_id;
100
+ const uniqueKey = `${relevantId}-${response.currency_id}`;
101
+ if (subscriptionId && response.subscription_id === subscriptionId || customerId && response.customer_id === customerId) {
102
+ if (!processedCurrencies[uniqueKey]) {
103
+ setProcessedCurrencies((prev) => ({ ...prev, [uniqueKey]: 1 }));
104
+ debouncedHandleInvoicePaid(response.currency_id);
105
+ }
64
106
  }
65
107
  });
66
108
  }
67
- }, [subscription]);
109
+ }, [subscription, subscriptionId, customerId]);
68
110
  const handlePay = (item) => {
69
111
  const { currency, method } = item;
70
112
  if (method.type === "stripe") {
@@ -76,15 +118,30 @@ function OverdueInvoicePayment({
76
118
  }
77
119
  setSelectCurrencyId(currency.id);
78
120
  setPayLoading(true);
121
+ setPaymentStatus((prev) => ({
122
+ ...prev,
123
+ [currency.id]: "idle"
124
+ }));
79
125
  if (["arcblock", "ethereum", "base"].includes(method.type)) {
126
+ const extraParams = { currencyId: currency.id };
127
+ if (subscriptionId) {
128
+ extraParams.subscriptionId = subscriptionId;
129
+ } else if (customerId) {
130
+ extraParams.customerId = customerId;
131
+ }
80
132
  connect.open({
81
133
  containerEl: void 0,
82
134
  saveConnect: false,
83
135
  action: "collect-batch",
84
136
  prefix: joinURL(getPrefix(), "/api/did"),
85
- extraParams: { currencyId: currency.id, subscriptionId },
137
+ extraParams,
86
138
  onSuccess: () => {
87
139
  connect.close();
140
+ setPayLoading(false);
141
+ setPaymentStatus((prev) => ({
142
+ ...prev,
143
+ [currency.id]: "success"
144
+ }));
88
145
  },
89
146
  onClose: () => {
90
147
  connect.close();
@@ -92,6 +149,10 @@ function OverdueInvoicePayment({
92
149
  },
93
150
  onError: (err) => {
94
151
  Toast.error(formatError(err));
152
+ setPaymentStatus((prev) => ({
153
+ ...prev,
154
+ [currency.id]: "error"
155
+ }));
95
156
  setPayLoading(false);
96
157
  }
97
158
  });
@@ -102,7 +163,10 @@ function OverdueInvoicePayment({
102
163
  dialogProps.onClose?.();
103
164
  };
104
165
  const handleViewDetailClick = (e) => {
105
- if (inSubscriptionDetail) {
166
+ if (detailLinkOptions.onClick) {
167
+ e.preventDefault();
168
+ detailLinkOptions.onClick(e);
169
+ } else if (!detailLinkOptions.enabled) {
106
170
  e.preventDefault();
107
171
  handleClose();
108
172
  }
@@ -110,22 +174,111 @@ function OverdueInvoicePayment({
110
174
  if (loading) {
111
175
  return null;
112
176
  }
113
- const renderPayButton = (item, props) => {
114
- const isPayLoading = payLoading && item.currency.id === selectCurrencyId;
177
+ const getDetailLinkText = () => {
178
+ if (detailLinkOptions.title) {
179
+ return detailLinkOptions.title;
180
+ }
181
+ if (subscriptionId) {
182
+ return t("payment.subscription.overdue.view");
183
+ }
184
+ return t("payment.customer.pastDue.view");
185
+ };
186
+ const renderPayButton = (item, primaryButton = true, props = {
187
+ variant: "contained"
188
+ }) => {
189
+ const { currency } = item;
190
+ const inProcess = payLoading && selectCurrencyId === currency.id;
191
+ const status = paymentStatus[currency.id] || "idle";
192
+ if (status === "success") {
193
+ return /* @__PURE__ */ jsx(
194
+ Button,
195
+ {
196
+ variant: props?.variant || "contained",
197
+ size: "small",
198
+ ...primaryButton ? {} : {
199
+ color: "success",
200
+ startIcon: /* @__PURE__ */ jsx(CheckCircleIcon, {})
201
+ },
202
+ children: t("payment.subscription.overdue.paid")
203
+ }
204
+ );
205
+ }
206
+ if (status === "error") {
207
+ return /* @__PURE__ */ jsx(Button, { variant: "contained", size: "small", onClick: () => handlePay(item), ...props, children: t("payment.subscription.overdue.retry") });
208
+ }
115
209
  if (item.method.type === "stripe") {
116
- return /* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: () => window.open(subscriptionUrl, "_blank"), ...props, children: t("payment.subscription.overdue.viewNow") });
210
+ return /* @__PURE__ */ jsx(Button, { variant: "contained", color: "primary", onClick: () => window.open(detailUrl, "_blank"), ...props, children: t("payment.subscription.overdue.viewNow") });
211
+ }
212
+ return /* @__PURE__ */ jsx(
213
+ LoadingButton,
214
+ {
215
+ variant: "contained",
216
+ size: "small",
217
+ disabled: inProcess,
218
+ loading: inProcess,
219
+ onClick: () => handlePay(item),
220
+ ...props,
221
+ children: t("payment.subscription.overdue.payNow")
222
+ }
223
+ );
224
+ };
225
+ const getMethodText = (method) => {
226
+ if (method.name && method.type !== "arcblock") {
227
+ return ` (${method.name})`;
228
+ }
229
+ return "";
230
+ };
231
+ const getOverdueTitle = () => {
232
+ if (subscriptionId && data.subscription) {
233
+ if (summaryList.length === 1) {
234
+ return t("payment.subscription.overdue.title", {
235
+ name: data.subscription?.description,
236
+ count: data.invoices?.length,
237
+ total: formatAmount(summaryList[0]?.amount, summaryList[0]?.currency?.decimal),
238
+ symbol: summaryList[0]?.currency?.symbol,
239
+ method: getMethodText(summaryList[0]?.method)
240
+ });
241
+ }
242
+ return t("payment.subscription.overdue.simpleTitle", {
243
+ name: data.subscription?.description,
244
+ count: data.invoices?.length
245
+ });
246
+ }
247
+ if (customerId) {
248
+ if (summaryList.length === 1) {
249
+ return t("payment.customer.overdue.title", {
250
+ subscriptionCount: data.subscriptionCount || 0,
251
+ count: data.invoices?.length,
252
+ total: formatAmount(summaryList[0]?.amount, summaryList[0]?.currency?.decimal),
253
+ symbol: summaryList[0]?.currency?.symbol,
254
+ method: getMethodText(summaryList[0]?.method)
255
+ });
256
+ }
257
+ return t("payment.customer.overdue.simpleTitle", {
258
+ subscriptionCount: data.subscriptionCount || 0,
259
+ count: data.invoices?.length
260
+ });
261
+ }
262
+ return "";
263
+ };
264
+ const getEmptyStateMessage = () => {
265
+ if (subscriptionId && data.subscription) {
266
+ return t("payment.subscription.overdue.empty", {
267
+ name: data.subscription?.description
268
+ });
269
+ }
270
+ if (customerId) {
271
+ return t("payment.customer.overdue.empty");
117
272
  }
118
- return /* @__PURE__ */ jsxs(Button, { variant: "contained", color: "primary", onClick: () => handlePay(item), ...props, disabled: isPayLoading, children: [
119
- isPayLoading && /* @__PURE__ */ jsx(CircularProgress, { size: 14, sx: { mr: 1, color: "text.lighter" } }),
120
- t("payment.subscription.overdue.payNow")
121
- ] });
273
+ return "";
122
274
  };
123
275
  if (mode === "custom" && children && typeof children === "function") {
124
276
  return /* @__PURE__ */ jsx(Stack, { children: children(handlePay, {
125
277
  subscription: data?.subscription,
126
- subscriptionUrl,
127
278
  summary: data?.summary,
128
- invoices: data?.invoices
279
+ invoices: data?.invoices,
280
+ subscriptionCount: data?.subscriptionCount,
281
+ detailUrl
129
282
  }) });
130
283
  }
131
284
  return /* @__PURE__ */ jsx(
@@ -141,34 +294,27 @@ function OverdueInvoicePayment({
141
294
  onClose: handleClose,
142
295
  children: error ? /* @__PURE__ */ jsx(Alert, { severity: "error", children: error.message }) : /* @__PURE__ */ jsxs(Stack, { gap: 1, children: [
143
296
  summaryList.length === 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
144
- /* @__PURE__ */ jsx(Alert, { severity: "success", children: t("payment.subscription.overdue.empty", {
145
- // @ts-ignore
146
- name: data?.subscription?.description
147
- }) }),
297
+ /* @__PURE__ */ jsx(Alert, { severity: "success", children: getEmptyStateMessage() }),
148
298
  /* @__PURE__ */ jsx(Stack, { direction: "row", justifyContent: "flex-end", mt: 2, children: /* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", onClick: handleClose, sx: { width: "fit-content" }, children: t("common.know") }) })
149
299
  ] }),
150
300
  summaryList.length === 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
151
301
  /* @__PURE__ */ jsxs(Typography, { color: "text.secondary", variant: "body1", children: [
152
- t("payment.subscription.overdue.title", {
153
- // @ts-ignore
154
- name: data?.subscription?.description,
155
- count: data?.invoices?.length,
156
- total: formatAmount(summaryList[0]?.amount, summaryList[0]?.currency?.decimal),
157
- symbol: summaryList[0]?.currency?.symbol
158
- }),
159
- /* @__PURE__ */ jsx("br", {}),
160
- t("payment.subscription.overdue.description"),
161
- /* @__PURE__ */ jsx(
162
- "a",
163
- {
164
- href: subscriptionUrl,
165
- target: "_blank",
166
- onClick: handleViewDetailClick,
167
- rel: "noreferrer",
168
- style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
169
- children: t("payment.subscription.overdue.view")
170
- }
171
- )
302
+ getOverdueTitle(),
303
+ detailLinkOptions.enabled && /* @__PURE__ */ jsxs(Fragment, { children: [
304
+ /* @__PURE__ */ jsx("br", {}),
305
+ t("payment.subscription.overdue.description"),
306
+ /* @__PURE__ */ jsx(
307
+ "a",
308
+ {
309
+ href: detailUrl,
310
+ target: "_blank",
311
+ onClick: handleViewDetailClick,
312
+ rel: "noreferrer",
313
+ style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
314
+ children: getDetailLinkText()
315
+ }
316
+ )
317
+ ] })
172
318
  ] }),
173
319
  /* @__PURE__ */ jsxs(Stack, { direction: "row", justifyContent: "flex-end", gap: 2, mt: 2, children: [
174
320
  /* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", onClick: handleClose, children: t("common.cancel") }),
@@ -177,24 +323,22 @@ function OverdueInvoicePayment({
177
323
  ] }),
178
324
  summaryList.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
179
325
  /* @__PURE__ */ jsxs(Typography, { color: "text.secondary", variant: "body1", children: [
180
- t("payment.subscription.overdue.simpleTitle", {
181
- // @ts-ignore
182
- name: data?.subscription?.description,
183
- count: data?.invoices?.length
184
- }),
185
- /* @__PURE__ */ jsx("br", {}),
186
- t("payment.subscription.overdue.description"),
187
- /* @__PURE__ */ jsx(
188
- "a",
189
- {
190
- href: subscriptionUrl,
191
- target: "_blank",
192
- rel: "noreferrer",
193
- onClick: handleViewDetailClick,
194
- style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
195
- children: t("payment.subscription.overdue.view")
196
- }
197
- )
326
+ getOverdueTitle(),
327
+ detailLinkOptions.enabled && /* @__PURE__ */ jsxs(Fragment, { children: [
328
+ /* @__PURE__ */ jsx("br", {}),
329
+ t("payment.subscription.overdue.description"),
330
+ /* @__PURE__ */ jsx(
331
+ "a",
332
+ {
333
+ href: detailUrl,
334
+ target: "_blank",
335
+ rel: "noreferrer",
336
+ onClick: handleViewDetailClick,
337
+ style: { color: "var(--foregrounds-fg-interactive, 0086FF)" },
338
+ children: getDetailLinkText()
339
+ }
340
+ )
341
+ ] })
198
342
  ] }),
199
343
  /* @__PURE__ */ jsx(Typography, { color: "text.secondary", variant: "body1", children: t("payment.subscription.overdue.list") }),
200
344
  /* @__PURE__ */ jsx(Stack, { children: summaryList.map((item) => /* @__PURE__ */ jsxs(
@@ -215,9 +359,10 @@ function OverdueInvoicePayment({
215
359
  children: [
216
360
  /* @__PURE__ */ jsx(Typography, { children: t("payment.subscription.overdue.total", {
217
361
  total: formatAmount(item?.amount, item?.currency?.decimal),
218
- currency: item?.currency?.symbol
362
+ currency: item?.currency?.symbol,
363
+ method: getMethodText(item?.method)
219
364
  }) }),
220
- renderPayButton(item, {
365
+ renderPayButton(item, false, {
221
366
  variant: "text",
222
367
  sx: {
223
368
  color: "text.link"
@@ -240,6 +385,9 @@ OverdueInvoicePayment.defaultProps = {
240
385
  open: true
241
386
  },
242
387
  children: null,
243
- inSubscriptionDetail: false
388
+ detailLinkOptions: { enabled: true },
389
+ subscriptionId: void 0,
390
+ customerId: void 0,
391
+ successToast: true
244
392
  };
245
393
  export default OverdueInvoicePayment;
@@ -5,6 +5,19 @@ import { createContext, useContext, useState } from "react";
5
5
  import api from "../libs/api.js";
6
6
  import { getPrefix } from "../libs/util.js";
7
7
  import { CachedRequest } from "../libs/cached-request.js";
8
+ const formatData = (data) => {
9
+ if (!data) {
10
+ return {
11
+ paymentMethods: [],
12
+ baseCurrency: {}
13
+ };
14
+ }
15
+ return {
16
+ ...data,
17
+ paymentMethods: data.paymentMethods || [],
18
+ baseCurrency: data.baseCurrency || {}
19
+ };
20
+ };
8
21
  const PaymentContext = createContext({ api });
9
22
  const { Provider, Consumer } = PaymentContext;
10
23
  const getSettings = (forceRefresh = false) => {
@@ -52,7 +65,7 @@ function PaymentProvider({ session, connect, children, baseUrl }) {
52
65
  connect,
53
66
  prefix,
54
67
  livemode: !!livemode,
55
- settings: data,
68
+ settings: formatData(data),
56
69
  getCurrency: (currencyId) => getCurrency(currencyId, data?.paymentMethods || []),
57
70
  getMethod: (methodId) => getMethod(methodId, data?.paymentMethods || []),
58
71
  refresh: run,
@@ -11,6 +11,7 @@ type Props = {
11
11
  action?: string;
12
12
  type?: 'list' | 'table';
13
13
  onTableDataChange?: Function;
14
+ relatedSubscription?: boolean;
14
15
  };
15
16
  declare function CustomerInvoiceList(props: Props): JSX.Element;
16
17
  declare namespace CustomerInvoiceList {
@@ -26,6 +27,7 @@ declare namespace CustomerInvoiceList {
26
27
  action: string;
27
28
  type: string;
28
29
  onTableDataChange: () => void;
30
+ relatedSubscription: boolean;
29
31
  };
30
32
  }
31
33
  export default CustomerInvoiceList;