@blocklet/payment-react 1.15.4 → 1.15.6

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.
@@ -28,7 +28,8 @@ import {
28
28
  formatPriceAmount,
29
29
  formatRecurring,
30
30
  getPriceCurrencyOptions,
31
- getPriceUintAmountByCurrency
31
+ getPriceUintAmountByCurrency,
32
+ isMobileSafari
32
33
  } from "../libs/util.js";
33
34
  import Amount from "../payment/amount.js";
34
35
  import { useMobile } from "../hooks/mobile.js";
@@ -63,8 +64,19 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
63
64
  const { t, locale } = useLocaleContext();
64
65
  const { isMobile } = useMobile();
65
66
  const {
66
- settings: { paymentMethods = [] }
67
+ settings: { paymentMethods = [] },
68
+ livemode,
69
+ setLivemode,
70
+ refresh
67
71
  } = usePaymentContext();
72
+ const isMobileSafariEnv = isMobileSafari();
73
+ useEffect(() => {
74
+ if (table) {
75
+ if (livemode !== table.livemode) {
76
+ setLivemode(table.livemode);
77
+ }
78
+ }
79
+ }, [table, livemode, setLivemode, refresh]);
68
80
  const [currency, setCurrency] = useState(table.currency || {});
69
81
  const { recurring, grouped } = useMemo(() => groupItemsByRecurring(table.items, currency), [table.items, currency]);
70
82
  const recurringKeysList = useMemo(() => {
@@ -139,6 +151,13 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
139
151
  width: 100%;
140
152
  gap: 20px;
141
153
  }
154
+ .price-table-wrap {
155
+ scrollbar-width: none;
156
+ -ms-overflow-style: none;
157
+ &::-webkit-scrollbar {
158
+ display: none;
159
+ }
160
+ }
142
161
  @media (max-width: ${({ theme }) => theme.breakpoints.values.sm}px) {
143
162
  // .price-table-item {
144
163
  // width: 90% !important;
@@ -159,233 +178,259 @@ export default function PricingTable({ table, alignItems, interval, mode, onSele
159
178
  }
160
179
  }
161
180
  `;
162
- return /* @__PURE__ */ jsx(Root, { children: /* @__PURE__ */ jsxs(
163
- Stack,
181
+ return /* @__PURE__ */ jsx(
182
+ Root,
164
183
  {
165
- direction: "column",
166
- alignItems: alignItems === "center" ? "center" : "flex-start",
167
184
  sx: {
168
- gap: {
169
- xs: 3,
170
- sm: mode === "select" ? 3 : 5
171
- }
185
+ flex: 1,
186
+ overflow: {
187
+ xs: isMobileSafariEnv ? "visible" : "hidden",
188
+ md: "hidden"
189
+ },
190
+ display: "flex",
191
+ flexDirection: "column"
172
192
  },
173
- children: [
174
- /* @__PURE__ */ jsxs(Stack, { className: "btn-row", flexDirection: "row", children: [
175
- recurringKeysList.length > 0 && /* @__PURE__ */ jsx(Box, { children: isMobile && recurringKeysList.length > 1 ? /* @__PURE__ */ jsx(
176
- Select,
177
- {
178
- value: state.interval,
179
- onChange: (e) => setState({ interval: e.target.value }),
180
- size: "small",
181
- sx: { m: 1 },
182
- children: recurringKeysList.map((x) => /* @__PURE__ */ jsx(MenuItem, { value: x, children: /* @__PURE__ */ jsx(Typography, { color: x === state.interval ? "text.primary" : "text.secondary", children: formatRecurring(recurring[x], true, "", locale) }) }, x))
193
+ children: /* @__PURE__ */ jsxs(
194
+ Stack,
195
+ {
196
+ direction: "column",
197
+ alignItems: alignItems === "center" ? "center" : "flex-start",
198
+ sx: {
199
+ gap: {
200
+ xs: 3,
201
+ sm: mode === "select" ? 3 : 5
202
+ },
203
+ height: "100%",
204
+ overflow: {
205
+ xs: "auto",
206
+ md: "hidden"
183
207
  }
184
- ) : /* @__PURE__ */ jsx(
185
- ToggleButtonGroup,
186
- {
187
- size: "small",
188
- value: state.interval,
189
- sx: {
190
- padding: "4px",
191
- borderRadius: "36px",
192
- height: "40px",
193
- boxSizing: "border-box",
194
- backgroundColor: "#f1f3f5",
195
- border: 0
196
- },
197
- onChange: (_, value) => {
198
- if (value !== null) {
199
- setState({ interval: value });
208
+ },
209
+ children: [
210
+ /* @__PURE__ */ jsxs(Stack, { className: "btn-row", flexDirection: "row", children: [
211
+ recurringKeysList.length > 0 && /* @__PURE__ */ jsx(Box, { children: isMobile && recurringKeysList.length > 1 ? /* @__PURE__ */ jsx(
212
+ Select,
213
+ {
214
+ value: state.interval,
215
+ onChange: (e) => setState({ interval: e.target.value }),
216
+ size: "small",
217
+ sx: { m: 1 },
218
+ children: recurringKeysList.map((x) => /* @__PURE__ */ jsx(MenuItem, { value: x, children: /* @__PURE__ */ jsx(Typography, { color: x === state.interval ? "text.primary" : "text.secondary", children: formatRecurring(recurring[x], true, "", locale) }) }, x))
200
219
  }
201
- },
202
- exclusive: true,
203
- children: recurringKeysList.map((x) => /* @__PURE__ */ jsx(
204
- ToggleButton,
220
+ ) : /* @__PURE__ */ jsx(
221
+ ToggleButtonGroup,
205
222
  {
206
223
  size: "small",
207
- value: x,
224
+ value: state.interval,
208
225
  sx: {
209
- textTransform: "capitalize",
210
- padding: "5px 12px",
211
- fontSize: "13px",
212
- backgroundColor: x === state.interval ? "#fff !important" : "#f1f3f5 !important",
213
- border: "0px",
214
- "&.Mui-selected": {
215
- borderRadius: "9999px !important",
216
- border: "1px solid #e5e7eb"
226
+ padding: "4px",
227
+ borderRadius: "36px",
228
+ height: "40px",
229
+ boxSizing: "border-box",
230
+ backgroundColor: "#f1f3f5",
231
+ border: 0
232
+ },
233
+ onChange: (_, value) => {
234
+ if (value !== null) {
235
+ setState({ interval: value });
217
236
  }
218
237
  },
219
- children: formatRecurring(recurring[x], true, "", locale)
220
- },
221
- x
222
- ))
223
- }
224
- ) }),
225
- currencyList.length > 0 && /* @__PURE__ */ jsx(
226
- Select,
227
- {
228
- value: currency?.id,
229
- onChange: (e) => setCurrency(currencyList.find((v) => v?.id === e.target.value)),
230
- size: "small",
231
- sx: { m: 1, width: 120 },
232
- children: currencyList.map((x) => /* @__PURE__ */ jsx(MenuItem, { value: x?.id, children: /* @__PURE__ */ jsx(Typography, { color: x?.id === currency?.id ? "text.primary" : "text.secondary", children: x?.symbol }) }, x?.id))
233
- }
234
- )
235
- ] }),
236
- /* @__PURE__ */ jsx(
237
- Stack,
238
- {
239
- flexWrap: "wrap",
240
- direction: "row",
241
- gap: "20px",
242
- justifyContent: alignItems === "center" ? "center" : "flex-start",
243
- className: "price-table-wrap",
244
- children: productList?.map((x) => {
245
- let action = x.subscription_data?.trial_period_days ? t("payment.checkout.try") : t("payment.checkout.subscription");
246
- if (mode === "select") {
247
- action = x.is_selected ? t("payment.checkout.selected") : t("payment.checkout.select");
248
- }
249
- return /* @__PURE__ */ jsxs(
250
- Stack,
251
- {
252
- padding: 4,
253
- spacing: 2,
254
- direction: "column",
255
- alignItems: "flex-start",
256
- className: "price-table-item",
257
- justifyContent: "flex-start",
258
- sx: {
259
- cursor: "pointer",
260
- borderWidth: "1px",
261
- borderStyle: "solid",
262
- borderColor: mode === "select" && x.is_selected ? "primary.main" : "#eee",
263
- borderRadius: 2,
264
- transition: "border-color 0.3s ease 0s, box-shadow 0.3s ease 0s",
265
- boxShadow: "0px 0px 0px 1px rgba(3, 7, 18, 0.08), 0px 1px 2px -1px rgba(3, 7, 18, 0.08), 0px 2px 4px rgba(3, 7, 18, 0.04)",
266
- "&:hover": {
267
- borderColor: mode === "select" && x.is_selected ? "primary.main" : "#ddd",
268
- boxShadow: "0 8px 16px rgba(0, 0, 0, 20%)"
269
- },
270
- width: {
271
- xs: "100%",
272
- md: "320px"
238
+ exclusive: true,
239
+ children: recurringKeysList.map((x) => /* @__PURE__ */ jsx(
240
+ ToggleButton,
241
+ {
242
+ size: "small",
243
+ value: x,
244
+ sx: {
245
+ textTransform: "capitalize",
246
+ padding: "5px 12px",
247
+ fontSize: "13px",
248
+ backgroundColor: x === state.interval ? "#fff !important" : "#f1f3f5 !important",
249
+ border: "0px",
250
+ "&.Mui-selected": {
251
+ borderRadius: "9999px !important",
252
+ border: "1px solid #e5e7eb"
253
+ }
254
+ },
255
+ children: formatRecurring(recurring[x], true, "", locale)
273
256
  },
274
- maxWidth: "360px",
275
- padding: "20px",
276
- position: "relative"
277
- },
278
- children: [
279
- /* @__PURE__ */ jsx(Box, { textAlign: "center", children: /* @__PURE__ */ jsxs(
280
- Stack,
281
- {
282
- direction: "column",
283
- justifyContent: "center",
284
- alignItems: "flex-start",
285
- spacing: 1,
286
- sx: { gap: "12px" },
287
- children: [
288
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
289
- /* @__PURE__ */ jsx(
290
- Typography,
257
+ x
258
+ ))
259
+ }
260
+ ) }),
261
+ currencyList.length > 0 && /* @__PURE__ */ jsx(
262
+ Select,
263
+ {
264
+ value: currency?.id,
265
+ onChange: (e) => setCurrency(currencyList.find((v) => v?.id === e.target.value)),
266
+ size: "small",
267
+ sx: { m: 1, width: 120 },
268
+ children: currencyList.map((x) => /* @__PURE__ */ jsx(MenuItem, { value: x?.id, children: /* @__PURE__ */ jsx(Typography, { color: x?.id === currency?.id ? "text.primary" : "text.secondary", children: x?.symbol }) }, x?.id))
269
+ }
270
+ )
271
+ ] }),
272
+ /* @__PURE__ */ jsx(
273
+ Stack,
274
+ {
275
+ flexWrap: "wrap",
276
+ direction: "row",
277
+ gap: "20px",
278
+ justifyContent: alignItems === "center" ? "center" : "flex-start",
279
+ sx: {
280
+ flex: "0 1 auto",
281
+ overflow: "auto",
282
+ pb: 2.5
283
+ },
284
+ className: "price-table-wrap",
285
+ children: productList?.map((x) => {
286
+ let action = x.subscription_data?.trial_period_days ? t("payment.checkout.try") : t("payment.checkout.subscription");
287
+ if (mode === "select") {
288
+ action = x.is_selected ? t("payment.checkout.selected") : t("payment.checkout.select");
289
+ }
290
+ return /* @__PURE__ */ jsxs(
291
+ Stack,
292
+ {
293
+ padding: 4,
294
+ spacing: 2,
295
+ direction: "column",
296
+ alignItems: "flex-start",
297
+ className: "price-table-item",
298
+ justifyContent: "flex-start",
299
+ sx: {
300
+ cursor: "pointer",
301
+ borderWidth: "1px",
302
+ borderStyle: "solid",
303
+ borderColor: mode === "select" && x.is_selected ? "primary.main" : "#eee",
304
+ borderRadius: 2,
305
+ transition: "border-color 0.3s ease 0s, box-shadow 0.3s ease 0s",
306
+ boxShadow: "0px 0px 0px 1px rgba(3, 7, 18, 0.08), 0px 1px 2px -1px rgba(3, 7, 18, 0.08), 0px 2px 4px rgba(3, 7, 18, 0.04)",
307
+ "&:hover": {
308
+ borderColor: mode === "select" && x.is_selected ? "primary.main" : "#ddd",
309
+ boxShadow: "0 8px 16px rgba(0, 0, 0, 20%)"
310
+ },
311
+ width: {
312
+ xs: "100%",
313
+ md: "320px"
314
+ },
315
+ maxWidth: "360px",
316
+ minWidth: "300px",
317
+ padding: "20px",
318
+ position: "relative",
319
+ height: "fit-content"
320
+ },
321
+ children: [
322
+ /* @__PURE__ */ jsx(Box, { textAlign: "center", children: /* @__PURE__ */ jsxs(
323
+ Stack,
324
+ {
325
+ direction: "column",
326
+ justifyContent: "center",
327
+ alignItems: "flex-start",
328
+ spacing: 1,
329
+ sx: { gap: "12px" },
330
+ children: [
331
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
332
+ /* @__PURE__ */ jsx(
333
+ Typography,
334
+ {
335
+ color: "text.primary",
336
+ fontWeight: 600,
337
+ sx: {
338
+ fontSize: "18px !important",
339
+ fontWeight: "600"
340
+ },
341
+ children: /* @__PURE__ */ jsx(TruncatedText, { text: x.product.name, maxLength: 26, useWidth: true })
342
+ }
343
+ ),
344
+ x.is_highlight && /* @__PURE__ */ jsx(
345
+ Chip,
346
+ {
347
+ label: x.highlight_text,
348
+ color: "default",
349
+ size: "small",
350
+ sx: {
351
+ position: "absolute",
352
+ top: "20px",
353
+ right: "20px"
354
+ }
355
+ }
356
+ )
357
+ ] }),
358
+ /* @__PURE__ */ jsx(
359
+ Amount,
360
+ {
361
+ amount: formatPriceAmount(x.price, currency, x.product.unit_label),
362
+ sx: { my: 0, marginTop: "0px !important", fontSize: "48px", fontWeight: "bold" }
363
+ }
364
+ ),
365
+ /* @__PURE__ */ jsx(
366
+ Typography,
367
+ {
368
+ color: "text.secondary",
369
+ sx: {
370
+ marginTop: "0px !important",
371
+ fontWeight: "400",
372
+ fontSize: "16px",
373
+ textAlign: "left"
374
+ },
375
+ children: x.product.description
376
+ }
377
+ )
378
+ ]
379
+ }
380
+ ) }),
381
+ x.product.features.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsxs(List, { dense: true, sx: { display: "flex", flexDirection: "column", gap: "16px", padding: "0px" }, children: [
382
+ /* @__PURE__ */ jsx(
383
+ Box,
384
+ {
385
+ sx: {
386
+ width: "100%",
387
+ position: "relative",
388
+ borderTop: "1px solid #e5e7eb",
389
+ boxSizing: "border-box",
390
+ height: "1px"
391
+ }
392
+ }
393
+ ),
394
+ x.product.features.map((f) => /* @__PURE__ */ jsxs(ListItem, { disableGutters: true, disablePadding: true, sx: { fontSize: "16px !important" }, children: [
395
+ /* @__PURE__ */ jsx(ListItemIcon, { sx: { minWidth: 25, color: "#059669", fontSize: "64px" }, children: /* @__PURE__ */ jsx(
396
+ CheckOutlined,
291
397
  {
292
- color: "text.primary",
293
- fontWeight: 600,
398
+ color: "success",
399
+ fontSize: "small",
294
400
  sx: {
295
- fontSize: "18px !important",
296
- fontWeight: "600"
297
- },
298
- children: /* @__PURE__ */ jsx(TruncatedText, { text: x.product.name, maxLength: 26, useWidth: true })
401
+ color: "#059669",
402
+ fontSize: "18px"
403
+ }
299
404
  }
300
- ),
301
- x.is_highlight && /* @__PURE__ */ jsx(
302
- Chip,
405
+ ) }),
406
+ /* @__PURE__ */ jsx(
407
+ ListItemText,
303
408
  {
304
- label: x.highlight_text,
305
- color: "default",
306
- size: "small",
307
409
  sx: {
308
- position: "absolute",
309
- top: "20px",
310
- right: "20px"
311
- }
410
+ ".MuiListItemText-primary": {
411
+ fontSize: "16px",
412
+ color: "#030712",
413
+ fontWeight: "500"
414
+ }
415
+ },
416
+ primary: f.name
312
417
  }
313
418
  )
314
- ] }),
315
- /* @__PURE__ */ jsx(
316
- Amount,
317
- {
318
- amount: formatPriceAmount(x.price, currency, x.product.unit_label),
319
- sx: { my: 0, marginTop: "0px !important", fontSize: "48px", fontWeight: "bold" }
320
- }
321
- ),
322
- /* @__PURE__ */ jsx(
323
- Typography,
324
- {
325
- color: "text.secondary",
326
- sx: {
327
- marginTop: "0px !important",
328
- fontWeight: "400",
329
- fontSize: "16px",
330
- textAlign: "left"
331
- },
332
- children: x.product.description
333
- }
334
- )
335
- ]
336
- }
337
- ) }),
338
- x.product.features.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsxs(List, { dense: true, sx: { display: "flex", flexDirection: "column", gap: "16px", padding: "0px" }, children: [
339
- /* @__PURE__ */ jsx(
340
- Box,
341
- {
342
- sx: {
343
- width: "100%",
344
- position: "relative",
345
- borderTop: "1px solid #e5e7eb",
346
- boxSizing: "border-box",
347
- height: "1px"
348
- }
349
- }
350
- ),
351
- x.product.features.map((f) => /* @__PURE__ */ jsxs(ListItem, { disableGutters: true, disablePadding: true, sx: { fontSize: "16px !important" }, children: [
352
- /* @__PURE__ */ jsx(ListItemIcon, { sx: { minWidth: 25, color: "#059669", fontSize: "64px" }, children: /* @__PURE__ */ jsx(
353
- CheckOutlined,
354
- {
355
- color: "success",
356
- fontSize: "small",
357
- sx: {
358
- color: "#059669",
359
- fontSize: "18px"
360
- }
361
- }
362
- ) }),
363
- /* @__PURE__ */ jsx(
364
- ListItemText,
365
- {
366
- sx: {
367
- ".MuiListItemText-primary": {
368
- fontSize: "16px",
369
- color: "#030712",
370
- fontWeight: "500"
371
- }
372
- },
373
- primary: f.name
374
- }
375
- )
376
- ] }, f.name))
377
- ] }) }),
378
- /* @__PURE__ */ jsx(Subscribe, { x, action, onSelect, currencyId: currency?.id })
379
- ]
380
- },
381
- x?.price_id
382
- );
383
- })
384
- }
385
- )
386
- ]
419
+ ] }, f.name))
420
+ ] }) }),
421
+ /* @__PURE__ */ jsx(Subscribe, { x, action, onSelect, currencyId: currency?.id })
422
+ ]
423
+ },
424
+ x?.price_id
425
+ );
426
+ })
427
+ }
428
+ )
429
+ ]
430
+ }
431
+ )
387
432
  }
388
- ) });
433
+ );
389
434
  }
390
435
  function Subscribe({ x, action, onSelect, currencyId }) {
391
436
  const [state, setState] = useState({ loading: "", loaded: false });
@@ -8,13 +8,14 @@ const PaymentContext = createContext({ api });
8
8
  const { Provider, Consumer } = PaymentContext;
9
9
  let settingsPromise = null;
10
10
  const getSettings = () => {
11
- const cacheKey = `payment-settings-${window.location.pathname}`;
11
+ const livemode = localStorage.getItem("livemode") !== "false";
12
+ const cacheKey = `payment-settings-${window.location.pathname}-${livemode}`;
12
13
  const cachedData = sessionStorage.getItem(cacheKey);
13
14
  if (cachedData) {
14
15
  return JSON.parse(cachedData);
15
16
  }
16
17
  if (!settingsPromise) {
17
- settingsPromise = api.get("/api/settings").then(({ data }) => {
18
+ settingsPromise = api.get("/api/settings", { params: { livemode } }).then(({ data }) => {
18
19
  sessionStorage.setItem(cacheKey, JSON.stringify(data));
19
20
  return data;
20
21
  }).catch((error) => {
@@ -36,8 +37,10 @@ function PaymentProvider({ session, connect, children, baseUrl }) {
36
37
  if (baseUrl) {
37
38
  window.__PAYMENT_KIT_BASE_URL = baseUrl;
38
39
  }
39
- const { data, error, run, loading } = useRequest(getSettings);
40
40
  const [livemode, setLivemode] = useLocalStorageState("livemode", { defaultValue: true });
41
+ const { data, error, run, loading } = useRequest(getSettings, {
42
+ refreshDeps: [livemode]
43
+ });
41
44
  const prefix = getPrefix();
42
45
  const [payable, setPayable] = useState(true);
43
46
  if (error) {
@@ -10,6 +10,7 @@ type Props = {
10
10
  target?: string;
11
11
  action?: string;
12
12
  type?: 'list' | 'table';
13
+ onTableDataChange?: Function;
13
14
  };
14
15
  declare function CustomerInvoiceList(props: Props): JSX.Element;
15
16
  declare namespace CustomerInvoiceList {
@@ -24,6 +25,7 @@ declare namespace CustomerInvoiceList {
24
25
  target: string;
25
26
  action: string;
26
27
  type: string;
28
+ onTableDataChange: () => void;
27
29
  };
28
30
  }
29
31
  export default CustomerInvoiceList;
@@ -69,7 +69,8 @@ const InvoiceTable = React.memo((props) => {
69
69
  currency_id,
70
70
  subscription_id,
71
71
  include_staking,
72
- include_recovered_from
72
+ include_recovered_from,
73
+ onTableDataChange
73
74
  } = props;
74
75
  const listKey = "invoice-table";
75
76
  const { t, locale } = useLocaleContext();
@@ -77,7 +78,11 @@ const InvoiceTable = React.memo((props) => {
77
78
  pageSize: pageSize || 10,
78
79
  page: 1
79
80
  });
80
- const { loading, data = { list: [], count: 0 } } = useRequest(
81
+ const {
82
+ loading,
83
+ data = { list: [], count: 0 },
84
+ refresh
85
+ } = useRequest(
81
86
  () => fetchData({
82
87
  ...search,
83
88
  status,
@@ -92,6 +97,22 @@ const InvoiceTable = React.memo((props) => {
92
97
  refreshDeps: [search]
93
98
  }
94
99
  );
100
+ useEffect(() => {
101
+ if (onTableDataChange) {
102
+ onTableDataChange(data);
103
+ }
104
+ }, [data]);
105
+ const subscription = useSubscription("events");
106
+ useEffect(() => {
107
+ if (subscription && customer_id) {
108
+ subscription.on("invoice.paid", ({ response }) => {
109
+ if (response.customer_id === customer_id) {
110
+ Toast.success(t("payment.customer.invoice.paySuccess"));
111
+ refresh();
112
+ }
113
+ });
114
+ }
115
+ }, [subscription]);
95
116
  const columns = [
96
117
  {
97
118
  label: t("common.amount"),
@@ -226,7 +247,8 @@ const InvoiceList = React.memo((props) => {
226
247
  pageSize,
227
248
  target,
228
249
  action,
229
- onPay
250
+ onPay,
251
+ onTableDataChange
230
252
  } = props;
231
253
  const size = pageSize || 10;
232
254
  const subscription = useSubscription("events");
@@ -250,10 +272,16 @@ const InvoiceList = React.memo((props) => {
250
272
  reloadDeps: [customer_id, subscription_id, status, include_staking, include_recovered_from]
251
273
  }
252
274
  );
275
+ useEffect(() => {
276
+ if (onTableDataChange) {
277
+ onTableDataChange(data);
278
+ }
279
+ }, [data]);
253
280
  useEffect(() => {
254
281
  if (subscription && customer_id) {
255
282
  subscription.on("invoice.paid", async ({ response }) => {
256
283
  if (response.customer_id === customer_id) {
284
+ Toast.success(t("payment.customer.invoice.paySuccess"));
257
285
  await reloadAsync();
258
286
  }
259
287
  });
@@ -384,7 +412,9 @@ CustomerInvoiceList.defaultProps = {
384
412
  pageSize: 10,
385
413
  target: "_self",
386
414
  action: "",
387
- type: "list"
415
+ type: "list",
416
+ onTableDataChange: () => {
417
+ }
388
418
  };
389
419
  const Root = styled(Stack)`
390
420
  @media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
package/es/libs/util.js CHANGED
@@ -839,5 +839,6 @@ export function truncateText(text, maxLength, useWidth = false) {
839
839
  return `${truncated}...`;
840
840
  }
841
841
  export function getCustomerAvatar(did, updated_at, imageSize = 48) {
842
- return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated_at || dayjs().unix()}`;
842
+ const updated = typeof updated_at === "number" ? updated_at : dayjs(updated_at).unix();
843
+ return `/.well-known/service/user/avatar/${did}?imageFilter=resize&w=${imageSize}&h=${imageSize}&updateAt=${updated || dayjs().unix()}`;
843
844
  }
@@ -260,9 +260,6 @@ export default function Payment({
260
260
  if (checkoutSession) {
261
261
  if (livemode !== checkoutSession.livemode) {
262
262
  setLivemode(checkoutSession.livemode);
263
- setTimeout(() => {
264
- refresh();
265
- }, 10);
266
263
  }
267
264
  }
268
265
  }, [checkoutSession, livemode, setLivemode, refresh]);