@blocklet/payment-react 1.13.233 → 1.13.234

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.
@@ -11,6 +11,7 @@ import {
11
11
  Hidden,
12
12
  Stack,
13
13
  Table,
14
+ TableBody,
14
15
  TableCell,
15
16
  TableRow,
16
17
  Typography
@@ -21,7 +22,7 @@ import uniqBy from "lodash/unionBy";
21
22
  import { useEffect } from "react";
22
23
  import api from "../api.js";
23
24
  import TxLink from "../components/blockchain/tx.js";
24
- import { formatAmount, formatDateTime, formatError } from "../util.js";
25
+ import { formatBNStr, formatDateTime, formatError } from "../util.js";
25
26
  import CheckoutForm from "./form.js";
26
27
  const donationCache = {};
27
28
  const createOrUpdateDonation = (settings, livemode = true) => {
@@ -84,11 +85,15 @@ function SupporterTable({ supporters = [], total = 0, currency, method }) {
84
85
  const { t } = useLocaleContext();
85
86
  return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", alignItems: "center", sx: { width: "100%" }, gap: { xs: 0.5, sm: 1 }, children: [
86
87
  /* @__PURE__ */ jsx(Typography, { component: "p", color: "text.secondary", children: t("payment.checkout.donation.summary", { total }) }),
87
- /* @__PURE__ */ jsx(Table, { size: "small", sx: { width: "100%", overflow: "hidden" }, children: supporters.map((x) => /* @__PURE__ */ jsxs(
88
+ /* @__PURE__ */ jsx(Table, { size: "small", sx: { width: "100%", overflow: "hidden" }, children: /* @__PURE__ */ jsx(TableBody, { children: supporters.map((x) => /* @__PURE__ */ jsxs(
88
89
  TableRow,
89
90
  {
90
91
  sx: {
91
- "> td": { padding: "8px 16px 8px 0", borderTop: "1px solid #e0e0e0", borderBottom: "1px solid #e0e0e0" }
92
+ "> td": {
93
+ padding: "8px 16px 8px 0",
94
+ borderTop: "1px solid #e0e0e0",
95
+ borderBottom: "1px solid #e0e0e0"
96
+ }
92
97
  },
93
98
  children: [
94
99
  /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, children: [
@@ -104,7 +109,7 @@ function SupporterTable({ supporters = [], total = 0, currency, method }) {
104
109
  /* @__PURE__ */ jsx(Hidden, { smDown: true, children: /* @__PURE__ */ jsx(Typography, { children: x.customer?.name }) })
105
110
  ] }) }),
106
111
  /* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 0.5, children: [
107
- /* @__PURE__ */ jsx(Typography, { fontWeight: 500, component: "strong", children: formatAmount(x.amount_total, currency.decimal) }),
112
+ /* @__PURE__ */ jsx(Typography, { fontWeight: 500, component: "strong", children: formatBNStr(x.amount_total, currency.decimal) }),
108
113
  /* @__PURE__ */ jsx(Typography, { component: "span", children: currency.symbol })
109
114
  ] }) }),
110
115
  /* @__PURE__ */ jsx(Hidden, { smDown: true, children: /* @__PURE__ */ jsx(TableCell, { align: "right", children: /* @__PURE__ */ jsx(Typography, { children: formatDateTime(x.created_at) }) }) }),
@@ -112,7 +117,7 @@ function SupporterTable({ supporters = [], total = 0, currency, method }) {
112
117
  ]
113
118
  },
114
119
  x.id
115
- )) })
120
+ )) }) })
116
121
  ] });
117
122
  }
118
123
  export default function CheckoutDonate({ settings, livemode, onPaid, onError }) {
@@ -20,10 +20,12 @@ export default function ProductDonation({
20
20
  useEffect(() => {
21
21
  if (settings.amount.preset) {
22
22
  setState({ selected: settings.amount.preset, custom: false });
23
+ onChange({ priceId: item.price_id, amount: settings.amount.preset });
23
24
  } else if (settings.amount.presets && settings.amount.presets.length > 0) {
24
25
  setState({ selected: settings.amount.presets[0], custom: false });
26
+ onChange({ priceId: item.price_id, amount: settings.amount.presets[0] });
25
27
  }
26
- }, [settings.amount.preset, settings.amount.presets, setState]);
28
+ }, [settings.amount.preset, settings.amount.presets]);
27
29
  const handleSelect = (amount) => {
28
30
  setState({ selected: amount, custom: false, error: "" });
29
31
  onChange({ priceId: item.price_id, amount });
@@ -120,67 +120,69 @@ function SupporterTable({
120
120
  width: "100%",
121
121
  overflow: "hidden"
122
122
  },
123
- children: supporters.map(x => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.TableRow, {
124
- sx: {
125
- "> td": {
126
- padding: "8px 16px 8px 0",
127
- borderTop: "1px solid #e0e0e0",
128
- borderBottom: "1px solid #e0e0e0"
129
- }
130
- },
131
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
132
- children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
133
- direction: "row",
134
- alignItems: "center",
135
- spacing: 0.5,
136
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
137
- src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
138
- variant: "circular",
139
- sx: {
140
- width: 24,
141
- height: 24
142
- }
143
- }, x.id), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
144
- smDown: true,
123
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableBody, {
124
+ children: supporters.map(x => /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.TableRow, {
125
+ sx: {
126
+ "> td": {
127
+ padding: "8px 16px 8px 0",
128
+ borderTop: "1px solid #e0e0e0",
129
+ borderBottom: "1px solid #e0e0e0"
130
+ }
131
+ },
132
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
133
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
134
+ direction: "row",
135
+ alignItems: "center",
136
+ spacing: 0.5,
137
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Avatar, {
138
+ src: `/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`,
139
+ variant: "circular",
140
+ sx: {
141
+ width: 24,
142
+ height: 24
143
+ }
144
+ }, x.id), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
145
+ smDown: true,
146
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
147
+ children: x.customer?.name
148
+ })
149
+ })]
150
+ })
151
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
152
+ align: "right",
153
+ children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
154
+ direction: "row",
155
+ alignItems: "center",
156
+ justifyContent: "flex-end",
157
+ spacing: 0.5,
158
+ children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
159
+ fontWeight: 500,
160
+ component: "strong",
161
+ children: (0, _util.formatBNStr)(x.amount_total, currency.decimal)
162
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
163
+ component: "span",
164
+ children: currency.symbol
165
+ })]
166
+ })
167
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
168
+ smDown: true,
169
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
170
+ align: "right",
145
171
  children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
146
- children: x.customer?.name
172
+ children: (0, _util.formatDateTime)(x.created_at)
147
173
  })
148
- })]
149
- })
150
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
151
- align: "right",
152
- children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
153
- direction: "row",
154
- alignItems: "center",
155
- justifyContent: "flex-end",
156
- spacing: 0.5,
157
- children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
158
- fontWeight: 500,
159
- component: "strong",
160
- children: (0, _util.formatAmount)(x.amount_total, currency.decimal)
161
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
162
- component: "span",
163
- children: currency.symbol
164
- })]
165
- })
166
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Hidden, {
167
- smDown: true,
168
- children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
174
+ })
175
+ }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
169
176
  align: "right",
170
- children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
171
- children: (0, _util.formatDateTime)(x.created_at)
177
+ children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
178
+ method,
179
+ details: x.payment_details,
180
+ mode: "customer",
181
+ align: "right"
172
182
  })
173
- })
174
- }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.TableCell, {
175
- align: "right",
176
- children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_tx.default, {
177
- method,
178
- details: x.payment_details,
179
- mode: "customer",
180
- align: "right"
181
- })
182
- })]
183
- }, x.id))
183
+ })]
184
+ }, x.id))
185
+ })
184
186
  })]
185
187
  });
186
188
  }
@@ -32,13 +32,21 @@ function ProductDonation({
32
32
  selected: settings.amount.preset,
33
33
  custom: false
34
34
  });
35
+ onChange({
36
+ priceId: item.price_id,
37
+ amount: settings.amount.preset
38
+ });
35
39
  } else if (settings.amount.presets && settings.amount.presets.length > 0) {
36
40
  setState({
37
41
  selected: settings.amount.presets[0],
38
42
  custom: false
39
43
  });
44
+ onChange({
45
+ priceId: item.price_id,
46
+ amount: settings.amount.presets[0]
47
+ });
40
48
  }
41
- }, [settings.amount.preset, settings.amount.presets, setState]);
49
+ }, [settings.amount.preset, settings.amount.presets]);
42
50
  const handleSelect = amount => {
43
51
  setState({
44
52
  selected: amount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/payment-react",
3
- "version": "1.13.233",
3
+ "version": "1.13.234",
4
4
  "description": "Reusable react components for payment kit v2",
5
5
  "keywords": [
6
6
  "react",
@@ -90,7 +90,7 @@
90
90
  "@babel/core": "^7.24.4",
91
91
  "@babel/preset-env": "^7.24.4",
92
92
  "@babel/preset-react": "^7.24.1",
93
- "@blocklet/payment-types": "1.13.233",
93
+ "@blocklet/payment-types": "1.13.234",
94
94
  "@storybook/addon-essentials": "^7.6.17",
95
95
  "@storybook/addon-interactions": "^7.6.17",
96
96
  "@storybook/addon-links": "^7.6.17",
@@ -119,5 +119,5 @@
119
119
  "vite-plugin-babel": "^1.2.0",
120
120
  "vite-plugin-node-polyfills": "^0.21.0"
121
121
  },
122
- "gitHead": "854b8c4502657675e5d08279d2efca31bafa0a88"
122
+ "gitHead": "7b34eb52c3c96ab9124d80da66777fcd88f023ce"
123
123
  }
@@ -18,6 +18,7 @@ import {
18
18
  Hidden,
19
19
  Stack,
20
20
  Table,
21
+ TableBody,
21
22
  TableCell,
22
23
  TableRow,
23
24
  Typography,
@@ -30,7 +31,7 @@ import { useEffect } from 'react';
30
31
  import api from '../api';
31
32
  import TxLink from '../components/blockchain/tx';
32
33
  import { CheckoutProps } from '../types';
33
- import { formatAmount, formatDateTime, formatError } from '../util';
34
+ import { formatBNStr, formatDateTime, formatError } from '../util';
34
35
  import CheckoutForm from './form';
35
36
 
36
37
  export type DonateHistory = {
@@ -122,43 +123,49 @@ function SupporterTable({ supporters = [], total = 0, currency, method }: Donate
122
123
  {t('payment.checkout.donation.summary', { total })}
123
124
  </Typography>
124
125
  <Table size="small" sx={{ width: '100%', overflow: 'hidden' }}>
125
- {supporters.map((x) => (
126
- <TableRow
127
- key={x.id}
128
- sx={{
129
- '> td': { padding: '8px 16px 8px 0', borderTop: '1px solid #e0e0e0', borderBottom: '1px solid #e0e0e0' },
130
- }}>
131
- <TableCell>
132
- <Stack direction="row" alignItems="center" spacing={0.5}>
133
- <Avatar
134
- key={x.id}
135
- src={`/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`}
136
- variant="circular"
137
- sx={{ width: 24, height: 24 }}
138
- />
139
- <Hidden smDown>
140
- <Typography>{x.customer?.name}</Typography>
141
- </Hidden>
142
- </Stack>
143
- </TableCell>
144
- <TableCell align="right">
145
- <Stack direction="row" alignItems="center" justifyContent="flex-end" spacing={0.5}>
146
- <Typography fontWeight={500} component="strong">
147
- {formatAmount(x.amount_total, currency.decimal)}
148
- </Typography>
149
- <Typography component="span">{currency.symbol}</Typography>
150
- </Stack>
151
- </TableCell>
152
- <Hidden smDown>
126
+ <TableBody>
127
+ {supporters.map((x) => (
128
+ <TableRow
129
+ key={x.id}
130
+ sx={{
131
+ '> td': {
132
+ padding: '8px 16px 8px 0',
133
+ borderTop: '1px solid #e0e0e0',
134
+ borderBottom: '1px solid #e0e0e0',
135
+ },
136
+ }}>
137
+ <TableCell>
138
+ <Stack direction="row" alignItems="center" spacing={0.5}>
139
+ <Avatar
140
+ key={x.id}
141
+ src={`/.well-known/service/user/avatar/${x.customer?.did}?imageFilter=resize&w=48&h=48`}
142
+ variant="circular"
143
+ sx={{ width: 24, height: 24 }}
144
+ />
145
+ <Hidden smDown>
146
+ <Typography>{x.customer?.name}</Typography>
147
+ </Hidden>
148
+ </Stack>
149
+ </TableCell>
153
150
  <TableCell align="right">
154
- <Typography>{formatDateTime(x.created_at)}</Typography>
151
+ <Stack direction="row" alignItems="center" justifyContent="flex-end" spacing={0.5}>
152
+ <Typography fontWeight={500} component="strong">
153
+ {formatBNStr(x.amount_total, currency.decimal)}
154
+ </Typography>
155
+ <Typography component="span">{currency.symbol}</Typography>
156
+ </Stack>
155
157
  </TableCell>
156
- </Hidden>
157
- <TableCell align="right">
158
- <TxLink method={method} details={x.payment_details as PaymentDetails} mode="customer" align="right" />
159
- </TableCell>
160
- </TableRow>
161
- ))}
158
+ <Hidden smDown>
159
+ <TableCell align="right">
160
+ <Typography>{formatDateTime(x.created_at)}</Typography>
161
+ </TableCell>
162
+ </Hidden>
163
+ <TableCell align="right">
164
+ <TxLink method={method} details={x.payment_details as PaymentDetails} mode="customer" align="right" />
165
+ </TableCell>
166
+ </TableRow>
167
+ ))}
168
+ </TableBody>
162
169
  </Table>
163
170
  </Box>
164
171
  );
@@ -28,10 +28,12 @@ export default function ProductDonation({
28
28
  useEffect(() => {
29
29
  if (settings.amount.preset) {
30
30
  setState({ selected: settings.amount.preset, custom: false });
31
+ onChange({ priceId: item.price_id, amount: settings.amount.preset });
31
32
  } else if (settings.amount.presets && settings.amount.presets.length > 0) {
32
33
  setState({ selected: settings.amount.presets[0], custom: false });
34
+ onChange({ priceId: item.price_id, amount: settings.amount.presets[0] });
33
35
  }
34
- }, [settings.amount.preset, settings.amount.presets, setState]);
36
+ }, [settings.amount.preset, settings.amount.presets]); // eslint-disable-line
35
37
 
36
38
  const handleSelect = (amount: string) => {
37
39
  setState({ selected: amount, custom: false, error: '' });