@blocklet/payment-react 1.20.19 → 1.20.21
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/components/table.js +37 -13
- package/es/payment/form/index.js +9 -2
- package/es/payment/summary.js +90 -97
- package/lib/components/table.js +30 -20
- package/lib/payment/form/index.js +11 -4
- package/lib/payment/summary.js +8 -6
- package/package.json +3 -3
- package/src/components/table.tsx +46 -12
- package/src/payment/form/index.tsx +9 -2
- package/src/payment/summary.tsx +6 -9
package/es/components/table.js
CHANGED
|
@@ -9,7 +9,16 @@ function EmptyStub() {
|
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
const Table = React.memo(
|
|
12
|
-
({
|
|
12
|
+
({
|
|
13
|
+
options,
|
|
14
|
+
columns,
|
|
15
|
+
toolbar = true,
|
|
16
|
+
footer = true,
|
|
17
|
+
hasRowLink = false,
|
|
18
|
+
emptyNodeText = "",
|
|
19
|
+
bordered = true,
|
|
20
|
+
...rest
|
|
21
|
+
}) => {
|
|
13
22
|
const { locale, t } = useLocaleContext();
|
|
14
23
|
const { isMobile } = useMobile();
|
|
15
24
|
const defaultOptions = {
|
|
@@ -45,7 +54,8 @@ const Table = React.memo(
|
|
|
45
54
|
...rest,
|
|
46
55
|
components,
|
|
47
56
|
hasRowLink,
|
|
48
|
-
isMobile
|
|
57
|
+
isMobile,
|
|
58
|
+
bordered
|
|
49
59
|
}
|
|
50
60
|
);
|
|
51
61
|
}
|
|
@@ -55,19 +65,23 @@ const Wrapped = styled(Datatable)`
|
|
|
55
65
|
font-size: 0.875rem !important;
|
|
56
66
|
}` : ""}
|
|
57
67
|
.MuiPaper-root {
|
|
58
|
-
border-radius: 8px;
|
|
68
|
+
border-radius: ${(props) => props?.bordered ? "8px" : "0"};
|
|
59
69
|
overflow: hidden;
|
|
60
70
|
}
|
|
61
71
|
table.MuiTable-root {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
${(props) => props?.bordered ? `
|
|
73
|
+
outline: 1px solid;
|
|
74
|
+
outline-color: ${props.theme.palette.divider};
|
|
75
|
+
border-radius: ${2 * props.theme.shape.borderRadius}px;
|
|
76
|
+
` : ""}
|
|
65
77
|
overflow: hidden;
|
|
66
78
|
}
|
|
67
79
|
[class*='MUIDataTable-responsiveBase'] {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
${(props) => props?.bordered ? `
|
|
81
|
+
outline: 1px solid;
|
|
82
|
+
outline-color: ${props.theme.palette.divider};
|
|
83
|
+
border-radius: ${2 * props.theme.shape.borderRadius}px;
|
|
84
|
+
` : ""}
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
th.MuiTableCell-head {
|
|
@@ -76,11 +90,11 @@ const Wrapped = styled(Datatable)`
|
|
|
76
90
|
background: ${({ theme }) => theme.palette.grey[50]};
|
|
77
91
|
border-bottom: none;
|
|
78
92
|
&:first-of-type {
|
|
79
|
-
border-top-left-radius: 8px;
|
|
93
|
+
${(props) => props?.bordered ? "border-top-left-radius: 8px;" : ""}
|
|
80
94
|
padding-left: 20px;
|
|
81
95
|
}
|
|
82
96
|
&:last-of-type {
|
|
83
|
-
border-top-right-radius: 8px;
|
|
97
|
+
${(props) => props?.bordered ? "border-top-right-radius: 8px;" : ""}
|
|
84
98
|
}
|
|
85
99
|
}
|
|
86
100
|
|
|
@@ -88,11 +102,11 @@ const Wrapped = styled(Datatable)`
|
|
|
88
102
|
background: ${({ theme }) => theme.palette.grey[100]};
|
|
89
103
|
}
|
|
90
104
|
tr.MuiTableRow-root:last-of-type td:first-of-type {
|
|
91
|
-
border-bottom-left-radius: 8px;
|
|
105
|
+
${(props) => props?.bordered ? "border-bottom-left-radius: 8px;" : ""}
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
tr.MuiTableRow-root:last-of-type td:last-of-type {
|
|
95
|
-
border-bottom-right-radius: 8px;
|
|
109
|
+
${(props) => props?.bordered ? "border-bottom-right-radius: 8px;" : ""}
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
tr.MuiTableRow-root:nth-of-type(even) {
|
|
@@ -191,6 +205,16 @@ const Wrapped = styled(Datatable)`
|
|
|
191
205
|
[class*='MUIDataTable-responsiveBase'] tr:not([class*='responsiveSimple']) td.MuiTableCell-body > div {
|
|
192
206
|
width: inherit;
|
|
193
207
|
}
|
|
208
|
+
${({ mobileTDFlexDirection }) => mobileTDFlexDirection === "row" ? `
|
|
209
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
210
|
+
align-items: center;
|
|
211
|
+
padding: 4px 0;
|
|
212
|
+
> div {
|
|
213
|
+
width: fit-content;
|
|
214
|
+
flex: inherit;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
` : ""}
|
|
194
218
|
}
|
|
195
219
|
`;
|
|
196
220
|
export default Table;
|
package/es/payment/form/index.js
CHANGED
|
@@ -495,8 +495,15 @@ export default function PaymentForm({
|
|
|
495
495
|
setState({ stripePaying: false, paying: true });
|
|
496
496
|
await handleConnected();
|
|
497
497
|
};
|
|
498
|
-
const onStripeCancel = () => {
|
|
499
|
-
|
|
498
|
+
const onStripeCancel = async () => {
|
|
499
|
+
try {
|
|
500
|
+
await api.post(`/api/checkout-sessions/${checkoutSession.id}/abort-stripe`);
|
|
501
|
+
} catch (err) {
|
|
502
|
+
console.error(err);
|
|
503
|
+
Toast.error(formatError(err));
|
|
504
|
+
} finally {
|
|
505
|
+
setState({ stripePaying: false });
|
|
506
|
+
}
|
|
500
507
|
};
|
|
501
508
|
useEffect(() => {
|
|
502
509
|
const handleKeyDown = (e) => {
|
package/es/payment/summary.js
CHANGED
|
@@ -189,6 +189,7 @@ export default function PaymentSummary({
|
|
|
189
189
|
setState({ loading: false });
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
|
+
const hasSubTotal = +staking > 0 || allowPromotionCodes;
|
|
192
193
|
const ProductCardList = /* @__PURE__ */ jsxs(
|
|
193
194
|
Stack,
|
|
194
195
|
{
|
|
@@ -353,7 +354,7 @@ export default function PaymentSummary({
|
|
|
353
354
|
/* @__PURE__ */ jsx(Collapse, { in: state.expanded || !isMobile, timeout: "auto", unmountOnExit: true, children: ProductCardList })
|
|
354
355
|
] }) : ProductCardList,
|
|
355
356
|
/* @__PURE__ */ jsx(Divider, { sx: { mt: 2.5, mb: 2.5 } }),
|
|
356
|
-
+staking > 0 && /* @__PURE__ */ jsxs(
|
|
357
|
+
+staking > 0 && /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
|
|
357
358
|
/* @__PURE__ */ jsxs(
|
|
358
359
|
Stack,
|
|
359
360
|
{
|
|
@@ -450,103 +451,95 @@ export default function PaymentSummary({
|
|
|
450
451
|
currencyId: currency.id
|
|
451
452
|
}
|
|
452
453
|
) }),
|
|
453
|
-
hasDiscounts && /* @__PURE__ */ jsx(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
sx: {
|
|
512
|
-
minWidth: "auto",
|
|
513
|
-
width: 16,
|
|
514
|
-
height: 16,
|
|
515
|
-
color: "text.secondary",
|
|
516
|
-
"&.Mui-disabled": {
|
|
517
|
-
color: "text.disabled"
|
|
518
|
-
}
|
|
519
|
-
},
|
|
520
|
-
children: /* @__PURE__ */ jsx(Close, { sx: { fontSize: 14 } })
|
|
454
|
+
hasDiscounts && /* @__PURE__ */ jsx(Box, { children: sessionDiscounts.map((discount) => {
|
|
455
|
+
const promotionCodeInfo = discount.promotion_code_details;
|
|
456
|
+
const couponInfo = discount.coupon_details;
|
|
457
|
+
const discountDescription = couponInfo ? formatCouponTerms(couponInfo, discountCurrency, locale) : "";
|
|
458
|
+
const notSupported = discountDescription === t("payment.checkout.coupon.noDiscount");
|
|
459
|
+
return /* @__PURE__ */ jsxs(Stack, { children: [
|
|
460
|
+
/* @__PURE__ */ jsxs(
|
|
461
|
+
Stack,
|
|
462
|
+
{
|
|
463
|
+
direction: "row",
|
|
464
|
+
spacing: 1,
|
|
465
|
+
sx: {
|
|
466
|
+
justifyContent: "space-between",
|
|
467
|
+
alignItems: "center"
|
|
468
|
+
},
|
|
469
|
+
children: [
|
|
470
|
+
/* @__PURE__ */ jsxs(
|
|
471
|
+
Stack,
|
|
472
|
+
{
|
|
473
|
+
direction: "row",
|
|
474
|
+
spacing: 1,
|
|
475
|
+
sx: {
|
|
476
|
+
alignItems: "center",
|
|
477
|
+
backgroundColor: "grey.100",
|
|
478
|
+
width: "fit-content",
|
|
479
|
+
px: 1,
|
|
480
|
+
py: 1,
|
|
481
|
+
borderRadius: 1
|
|
482
|
+
},
|
|
483
|
+
children: [
|
|
484
|
+
/* @__PURE__ */ jsxs(
|
|
485
|
+
Typography,
|
|
486
|
+
{
|
|
487
|
+
sx: {
|
|
488
|
+
fontWeight: "medium",
|
|
489
|
+
display: "flex",
|
|
490
|
+
alignItems: "center",
|
|
491
|
+
gap: 0.5
|
|
492
|
+
},
|
|
493
|
+
children: [
|
|
494
|
+
/* @__PURE__ */ jsx(LocalOffer, { sx: { color: "warning.main", fontSize: "small" } }),
|
|
495
|
+
promotionCodeInfo?.code || discount.verification_data?.code || t("payment.checkout.discount")
|
|
496
|
+
]
|
|
497
|
+
}
|
|
498
|
+
),
|
|
499
|
+
!completed && /* @__PURE__ */ jsx(
|
|
500
|
+
Button,
|
|
501
|
+
{
|
|
502
|
+
size: "small",
|
|
503
|
+
disabled: paymentState.paying || paymentState.stripePaying,
|
|
504
|
+
onClick: () => handleRemovePromotion(checkoutSessionId),
|
|
505
|
+
sx: {
|
|
506
|
+
minWidth: "auto",
|
|
507
|
+
width: 16,
|
|
508
|
+
height: 16,
|
|
509
|
+
color: "text.secondary",
|
|
510
|
+
"&.Mui-disabled": {
|
|
511
|
+
color: "text.disabled"
|
|
521
512
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
513
|
+
},
|
|
514
|
+
children: /* @__PURE__ */ jsx(Close, { sx: { fontSize: 14 } })
|
|
515
|
+
}
|
|
516
|
+
)
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
/* @__PURE__ */ jsxs(Typography, { sx: { color: "text.secondary" }, children: [
|
|
521
|
+
"-",
|
|
522
|
+
formatAmount(discount.discount_amount || "0", discountCurrency.decimal),
|
|
523
|
+
" ",
|
|
524
|
+
discountCurrency.symbol
|
|
525
|
+
] })
|
|
526
|
+
]
|
|
527
|
+
}
|
|
528
|
+
),
|
|
529
|
+
discountDescription && /* @__PURE__ */ jsx(
|
|
530
|
+
Typography,
|
|
531
|
+
{
|
|
532
|
+
sx: {
|
|
533
|
+
fontSize: "small",
|
|
534
|
+
color: notSupported ? "error.main" : "text.secondary",
|
|
535
|
+
mt: 0.5
|
|
536
|
+
},
|
|
537
|
+
children: discountDescription
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
] }, discount.promotion_code || discount.coupon || `discount-${discount.discount_amount}`);
|
|
541
|
+
}) }),
|
|
542
|
+
hasSubTotal && /* @__PURE__ */ jsx(Divider, { sx: { my: 1 } }),
|
|
550
543
|
/* @__PURE__ */ jsxs(
|
|
551
544
|
Stack,
|
|
552
545
|
{
|
package/lib/components/table.js
CHANGED
|
@@ -22,6 +22,7 @@ const Table = _react.default.memo(({
|
|
|
22
22
|
footer = true,
|
|
23
23
|
hasRowLink = false,
|
|
24
24
|
emptyNodeText = "",
|
|
25
|
+
bordered = true,
|
|
25
26
|
...rest
|
|
26
27
|
}) => {
|
|
27
28
|
const {
|
|
@@ -67,7 +68,8 @@ const Table = _react.default.memo(({
|
|
|
67
68
|
...rest,
|
|
68
69
|
components,
|
|
69
70
|
hasRowLink,
|
|
70
|
-
isMobile
|
|
71
|
+
isMobile,
|
|
72
|
+
bordered
|
|
71
73
|
});
|
|
72
74
|
});
|
|
73
75
|
const Wrapped = (0, _system.styled)(_Datatable.default)`
|
|
@@ -75,27 +77,23 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
|
|
|
75
77
|
font-size: 0.875rem !important;
|
|
76
78
|
}` : ""}
|
|
77
79
|
.MuiPaper-root {
|
|
78
|
-
border-radius: 8px;
|
|
80
|
+
border-radius: ${props => props?.bordered ? "8px" : "0"};
|
|
79
81
|
overflow: hidden;
|
|
80
82
|
}
|
|
81
83
|
table.MuiTable-root {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
theme
|
|
88
|
-
}) => `${2 * theme.shape.borderRadius}px`};
|
|
84
|
+
${props => props?.bordered ? `
|
|
85
|
+
outline: 1px solid;
|
|
86
|
+
outline-color: ${props.theme.palette.divider};
|
|
87
|
+
border-radius: ${2 * props.theme.shape.borderRadius}px;
|
|
88
|
+
` : ""}
|
|
89
89
|
overflow: hidden;
|
|
90
90
|
}
|
|
91
91
|
[class*='MUIDataTable-responsiveBase'] {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
theme
|
|
98
|
-
}) => `${2 * theme.shape.borderRadius}px`};
|
|
92
|
+
${props => props?.bordered ? `
|
|
93
|
+
outline: 1px solid;
|
|
94
|
+
outline-color: ${props.theme.palette.divider};
|
|
95
|
+
border-radius: ${2 * props.theme.shape.borderRadius}px;
|
|
96
|
+
` : ""}
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
th.MuiTableCell-head {
|
|
@@ -106,11 +104,11 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
|
|
|
106
104
|
}) => theme.palette.grey[50]};
|
|
107
105
|
border-bottom: none;
|
|
108
106
|
&:first-of-type {
|
|
109
|
-
border-top-left-radius: 8px;
|
|
107
|
+
${props => props?.bordered ? "border-top-left-radius: 8px;" : ""}
|
|
110
108
|
padding-left: 20px;
|
|
111
109
|
}
|
|
112
110
|
&:last-of-type {
|
|
113
|
-
border-top-right-radius: 8px;
|
|
111
|
+
${props => props?.bordered ? "border-top-right-radius: 8px;" : ""}
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
|
|
@@ -120,11 +118,11 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
|
|
|
120
118
|
}) => theme.palette.grey[100]};
|
|
121
119
|
}
|
|
122
120
|
tr.MuiTableRow-root:last-of-type td:first-of-type {
|
|
123
|
-
border-bottom-left-radius: 8px;
|
|
121
|
+
${props => props?.bordered ? "border-bottom-left-radius: 8px;" : ""}
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
tr.MuiTableRow-root:last-of-type td:last-of-type {
|
|
127
|
-
border-bottom-right-radius: 8px;
|
|
125
|
+
${props => props?.bordered ? "border-bottom-right-radius: 8px;" : ""}
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
tr.MuiTableRow-root:nth-of-type(even) {
|
|
@@ -239,6 +237,18 @@ const Wrapped = (0, _system.styled)(_Datatable.default)`
|
|
|
239
237
|
[class*='MUIDataTable-responsiveBase'] tr:not([class*='responsiveSimple']) td.MuiTableCell-body > div {
|
|
240
238
|
width: inherit;
|
|
241
239
|
}
|
|
240
|
+
${({
|
|
241
|
+
mobileTDFlexDirection
|
|
242
|
+
}) => mobileTDFlexDirection === "row" ? `
|
|
243
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
244
|
+
align-items: center;
|
|
245
|
+
padding: 4px 0;
|
|
246
|
+
> div {
|
|
247
|
+
width: fit-content;
|
|
248
|
+
flex: inherit;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
` : ""}
|
|
242
252
|
}
|
|
243
253
|
`;
|
|
244
254
|
module.exports = Table;
|
|
@@ -577,10 +577,17 @@ function PaymentForm({
|
|
|
577
577
|
});
|
|
578
578
|
await handleConnected();
|
|
579
579
|
};
|
|
580
|
-
const onStripeCancel = () => {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
})
|
|
580
|
+
const onStripeCancel = async () => {
|
|
581
|
+
try {
|
|
582
|
+
await _api.default.post(`/api/checkout-sessions/${checkoutSession.id}/abort-stripe`);
|
|
583
|
+
} catch (err) {
|
|
584
|
+
console.error(err);
|
|
585
|
+
_Toast.default.error((0, _util2.formatError)(err));
|
|
586
|
+
} finally {
|
|
587
|
+
setState({
|
|
588
|
+
stripePaying: false
|
|
589
|
+
});
|
|
590
|
+
}
|
|
584
591
|
};
|
|
585
592
|
(0, _react.useEffect)(() => {
|
|
586
593
|
const handleKeyDown = e => {
|
package/lib/payment/summary.js
CHANGED
|
@@ -214,6 +214,7 @@ function PaymentSummary({
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
|
+
const hasSubTotal = +staking > 0 || allowPromotionCodes;
|
|
217
218
|
const ProductCardList = /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
218
219
|
className: "cko-product-list",
|
|
219
220
|
sx: {
|
|
@@ -368,7 +369,8 @@ function PaymentSummary({
|
|
|
368
369
|
mt: 2.5,
|
|
369
370
|
mb: 2.5
|
|
370
371
|
}
|
|
371
|
-
}), +staking > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(
|
|
372
|
+
}), +staking > 0 && /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
373
|
+
spacing: 1,
|
|
372
374
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
373
375
|
direction: "row",
|
|
374
376
|
spacing: 1,
|
|
@@ -469,9 +471,6 @@ function PaymentSummary({
|
|
|
469
471
|
currencyId: currency.id
|
|
470
472
|
})
|
|
471
473
|
}), hasDiscounts && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
472
|
-
sx: {
|
|
473
|
-
py: 1.5
|
|
474
|
-
},
|
|
475
474
|
children: sessionDiscounts.map(discount => {
|
|
476
475
|
const promotionCodeInfo = discount.promotion_code_details;
|
|
477
476
|
const couponInfo = discount.coupon_details;
|
|
@@ -493,13 +492,12 @@ function PaymentSummary({
|
|
|
493
492
|
backgroundColor: "grey.100",
|
|
494
493
|
width: "fit-content",
|
|
495
494
|
px: 1,
|
|
496
|
-
py:
|
|
495
|
+
py: 1,
|
|
497
496
|
borderRadius: 1
|
|
498
497
|
},
|
|
499
498
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
500
499
|
sx: {
|
|
501
500
|
fontWeight: "medium",
|
|
502
|
-
fontSize: "small",
|
|
503
501
|
display: "flex",
|
|
504
502
|
alignItems: "center",
|
|
505
503
|
gap: 0.5
|
|
@@ -545,6 +543,10 @@ function PaymentSummary({
|
|
|
545
543
|
})]
|
|
546
544
|
}, discount.promotion_code || discount.coupon || `discount-${discount.discount_amount}`);
|
|
547
545
|
})
|
|
546
|
+
}), hasSubTotal && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {
|
|
547
|
+
sx: {
|
|
548
|
+
my: 1
|
|
549
|
+
}
|
|
548
550
|
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
549
551
|
sx: {
|
|
550
552
|
display: "flex",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.21",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@babel/core": "^7.27.4",
|
|
95
95
|
"@babel/preset-env": "^7.27.2",
|
|
96
96
|
"@babel/preset-react": "^7.27.1",
|
|
97
|
-
"@blocklet/payment-types": "1.20.
|
|
97
|
+
"@blocklet/payment-types": "1.20.21",
|
|
98
98
|
"@storybook/addon-essentials": "^7.6.20",
|
|
99
99
|
"@storybook/addon-interactions": "^7.6.20",
|
|
100
100
|
"@storybook/addon-links": "^7.6.20",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"vite-plugin-babel": "^1.3.1",
|
|
126
126
|
"vite-plugin-node-polyfills": "^0.23.0"
|
|
127
127
|
},
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "43b26f9e7373a99000f6a14762fdab860a562967"
|
|
129
129
|
}
|
package/src/components/table.tsx
CHANGED
|
@@ -12,7 +12,16 @@ function EmptyStub() {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const Table = React.memo(
|
|
15
|
-
({
|
|
15
|
+
({
|
|
16
|
+
options,
|
|
17
|
+
columns,
|
|
18
|
+
toolbar = true,
|
|
19
|
+
footer = true,
|
|
20
|
+
hasRowLink = false,
|
|
21
|
+
emptyNodeText = '',
|
|
22
|
+
bordered = true,
|
|
23
|
+
...rest
|
|
24
|
+
}: any) => {
|
|
16
25
|
const { locale, t } = useLocaleContext();
|
|
17
26
|
const { isMobile } = useMobile();
|
|
18
27
|
|
|
@@ -52,6 +61,7 @@ const Table = React.memo(
|
|
|
52
61
|
components={components}
|
|
53
62
|
hasRowLink={hasRowLink}
|
|
54
63
|
isMobile={isMobile}
|
|
64
|
+
bordered={bordered}
|
|
55
65
|
/>
|
|
56
66
|
);
|
|
57
67
|
}
|
|
@@ -64,6 +74,7 @@ interface TableProps {
|
|
|
64
74
|
footer?: boolean;
|
|
65
75
|
hasRowLink?: boolean;
|
|
66
76
|
emptyNodeText?: string;
|
|
77
|
+
bordered?: boolean;
|
|
67
78
|
mobileTDFlexDirection?: string;
|
|
68
79
|
}
|
|
69
80
|
|
|
@@ -75,19 +86,29 @@ const Wrapped = styled(Datatable)`
|
|
|
75
86
|
}`
|
|
76
87
|
: ''}
|
|
77
88
|
.MuiPaper-root {
|
|
78
|
-
border-radius: 8px;
|
|
89
|
+
border-radius: ${(props: any) => (props?.bordered ? '8px' : '0')};
|
|
79
90
|
overflow: hidden;
|
|
80
91
|
}
|
|
81
92
|
table.MuiTable-root {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
${(props: any) =>
|
|
94
|
+
props?.bordered
|
|
95
|
+
? `
|
|
96
|
+
outline: 1px solid;
|
|
97
|
+
outline-color: ${props.theme.palette.divider};
|
|
98
|
+
border-radius: ${2 * (props.theme.shape.borderRadius as number)}px;
|
|
99
|
+
`
|
|
100
|
+
: ''}
|
|
85
101
|
overflow: hidden;
|
|
86
102
|
}
|
|
87
103
|
[class*='MUIDataTable-responsiveBase'] {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
104
|
+
${(props: any) =>
|
|
105
|
+
props?.bordered
|
|
106
|
+
? `
|
|
107
|
+
outline: 1px solid;
|
|
108
|
+
outline-color: ${props.theme.palette.divider};
|
|
109
|
+
border-radius: ${2 * (props.theme.shape.borderRadius as number)}px;
|
|
110
|
+
`
|
|
111
|
+
: ''}
|
|
91
112
|
}
|
|
92
113
|
|
|
93
114
|
th.MuiTableCell-head {
|
|
@@ -96,11 +117,11 @@ const Wrapped = styled(Datatable)`
|
|
|
96
117
|
background: ${({ theme }) => theme.palette.grey[50]};
|
|
97
118
|
border-bottom: none;
|
|
98
119
|
&:first-of-type {
|
|
99
|
-
border-top-left-radius: 8px;
|
|
120
|
+
${(props: any) => (props?.bordered ? 'border-top-left-radius: 8px;' : '')}
|
|
100
121
|
padding-left: 20px;
|
|
101
122
|
}
|
|
102
123
|
&:last-of-type {
|
|
103
|
-
border-top-right-radius: 8px;
|
|
124
|
+
${(props: any) => (props?.bordered ? 'border-top-right-radius: 8px;' : '')}
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
|
|
@@ -108,11 +129,11 @@ const Wrapped = styled(Datatable)`
|
|
|
108
129
|
background: ${({ theme }) => theme.palette.grey[100]};
|
|
109
130
|
}
|
|
110
131
|
tr.MuiTableRow-root:last-of-type td:first-of-type {
|
|
111
|
-
border-bottom-left-radius: 8px;
|
|
132
|
+
${(props: any) => (props?.bordered ? 'border-bottom-left-radius: 8px;' : '')}
|
|
112
133
|
}
|
|
113
134
|
|
|
114
135
|
tr.MuiTableRow-root:last-of-type td:last-of-type {
|
|
115
|
-
border-bottom-right-radius: 8px;
|
|
136
|
+
${(props: any) => (props?.bordered ? 'border-bottom-right-radius: 8px;' : '')}
|
|
116
137
|
}
|
|
117
138
|
|
|
118
139
|
tr.MuiTableRow-root:nth-of-type(even) {
|
|
@@ -214,6 +235,19 @@ const Wrapped = styled(Datatable)`
|
|
|
214
235
|
[class*='MUIDataTable-responsiveBase'] tr:not([class*='responsiveSimple']) td.MuiTableCell-body > div {
|
|
215
236
|
width: inherit;
|
|
216
237
|
}
|
|
238
|
+
${({ mobileTDFlexDirection }) =>
|
|
239
|
+
mobileTDFlexDirection === 'row'
|
|
240
|
+
? `
|
|
241
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
242
|
+
align-items: center;
|
|
243
|
+
padding: 4px 0;
|
|
244
|
+
> div {
|
|
245
|
+
width: fit-content;
|
|
246
|
+
flex: inherit;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
`
|
|
250
|
+
: ''}
|
|
217
251
|
}
|
|
218
252
|
`;
|
|
219
253
|
|
|
@@ -639,8 +639,15 @@ export default function PaymentForm({
|
|
|
639
639
|
await handleConnected();
|
|
640
640
|
};
|
|
641
641
|
|
|
642
|
-
const onStripeCancel = () => {
|
|
643
|
-
|
|
642
|
+
const onStripeCancel = async () => {
|
|
643
|
+
try {
|
|
644
|
+
await api.post(`/api/checkout-sessions/${checkoutSession.id}/abort-stripe`);
|
|
645
|
+
} catch (err) {
|
|
646
|
+
console.error(err);
|
|
647
|
+
Toast.error(formatError(err));
|
|
648
|
+
} finally {
|
|
649
|
+
setState({ stripePaying: false });
|
|
650
|
+
}
|
|
644
651
|
};
|
|
645
652
|
|
|
646
653
|
useEffect(() => {
|
package/src/payment/summary.tsx
CHANGED
|
@@ -275,6 +275,7 @@ export default function PaymentSummary({
|
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
|
|
278
|
+
const hasSubTotal = +staking > 0 || allowPromotionCodes;
|
|
278
279
|
const ProductCardList = (
|
|
279
280
|
<Stack
|
|
280
281
|
className="cko-product-list"
|
|
@@ -422,7 +423,7 @@ export default function PaymentSummary({
|
|
|
422
423
|
)}
|
|
423
424
|
<Divider sx={{ mt: 2.5, mb: 2.5 }} />
|
|
424
425
|
{+staking > 0 && (
|
|
425
|
-
|
|
426
|
+
<Stack spacing={1}>
|
|
426
427
|
<Stack
|
|
427
428
|
direction="row"
|
|
428
429
|
spacing={1}
|
|
@@ -465,7 +466,7 @@ export default function PaymentSummary({
|
|
|
465
466
|
{formatAmount(staking, discountCurrency.decimal)} {discountCurrency.symbol}
|
|
466
467
|
</Typography>
|
|
467
468
|
</Stack>
|
|
468
|
-
|
|
469
|
+
</Stack>
|
|
469
470
|
)}
|
|
470
471
|
{(allowPromotionCodes || hasDiscounts) && (
|
|
471
472
|
<Stack
|
|
@@ -502,10 +503,7 @@ export default function PaymentSummary({
|
|
|
502
503
|
|
|
503
504
|
{/* Promotion Code Details */}
|
|
504
505
|
{hasDiscounts && (
|
|
505
|
-
<Box
|
|
506
|
-
sx={{
|
|
507
|
-
py: 1.5,
|
|
508
|
-
}}>
|
|
506
|
+
<Box>
|
|
509
507
|
{sessionDiscounts.map((discount: any) => {
|
|
510
508
|
const promotionCodeInfo = discount.promotion_code_details;
|
|
511
509
|
const couponInfo = discount.coupon_details;
|
|
@@ -529,13 +527,12 @@ export default function PaymentSummary({
|
|
|
529
527
|
backgroundColor: 'grey.100',
|
|
530
528
|
width: 'fit-content',
|
|
531
529
|
px: 1,
|
|
532
|
-
py:
|
|
530
|
+
py: 1,
|
|
533
531
|
borderRadius: 1,
|
|
534
532
|
}}>
|
|
535
533
|
<Typography
|
|
536
534
|
sx={{
|
|
537
535
|
fontWeight: 'medium',
|
|
538
|
-
fontSize: 'small',
|
|
539
536
|
display: 'flex',
|
|
540
537
|
alignItems: 'center',
|
|
541
538
|
gap: 0.5,
|
|
@@ -582,7 +579,7 @@ export default function PaymentSummary({
|
|
|
582
579
|
})}
|
|
583
580
|
</Box>
|
|
584
581
|
)}
|
|
585
|
-
|
|
582
|
+
{hasSubTotal && <Divider sx={{ my: 1 }} />}
|
|
586
583
|
<Stack
|
|
587
584
|
sx={{
|
|
588
585
|
display: 'flex',
|