@selfcommunity/react-ui 0.10.5-payments.143 → 0.10.5-payments.147
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/lib/cjs/components/BuyButton/BuyButton.js +38 -3
- package/lib/cjs/components/Checkout/Checkout.js +9 -51
- package/lib/cjs/components/CheckoutReturnDialog/CheckoutReturnDialog.js +21 -11
- package/lib/cjs/components/GroupHeader/GroupHeader.js +3 -1
- package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +13 -0
- package/lib/cjs/components/PaymentDetailDialog/PaymentDetailDialog.js +6 -0
- package/lib/cjs/components/PaymentOrders/PaymentOrders.d.ts +4 -0
- package/lib/cjs/components/PaymentOrders/PaymentOrders.js +121 -0
- package/lib/cjs/components/PaymentOrders/index.d.ts +3 -0
- package/lib/cjs/components/PaymentOrders/index.js +5 -0
- package/lib/cjs/components/PaymentProduct/PaymentProduct.d.ts +3 -1
- package/lib/cjs/components/PaymentProduct/PaymentProduct.js +8 -2
- package/lib/cjs/components/PaymentProductPrice/PaymentProductPrice.d.ts +2 -1
- package/lib/cjs/components/PaymentProductPrice/PaymentProductPrice.js +11 -4
- package/lib/cjs/components/PaymentProducts/PaymentProducts.d.ts +3 -1
- package/lib/cjs/components/PaymentProducts/PaymentProducts.js +9 -3
- package/lib/cjs/components/PaymentProductsDialog/PaymentProductsDialog.js +6 -0
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +3 -3
- package/lib/esm/components/BuyButton/BuyButton.js +40 -5
- package/lib/esm/components/Checkout/Checkout.js +11 -53
- package/lib/esm/components/CheckoutReturnDialog/CheckoutReturnDialog.js +20 -10
- package/lib/esm/components/GroupHeader/GroupHeader.js +5 -3
- package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +14 -1
- package/lib/esm/components/PaymentDetailDialog/PaymentDetailDialog.js +6 -0
- package/lib/esm/components/PaymentOrders/PaymentOrders.d.ts +4 -0
- package/lib/esm/components/PaymentOrders/PaymentOrders.js +118 -0
- package/lib/esm/components/PaymentOrders/index.d.ts +3 -0
- package/lib/esm/components/PaymentOrders/index.js +2 -0
- package/lib/esm/components/PaymentProduct/PaymentProduct.d.ts +3 -1
- package/lib/esm/components/PaymentProduct/PaymentProduct.js +8 -2
- package/lib/esm/components/PaymentProductPrice/PaymentProductPrice.d.ts +2 -1
- package/lib/esm/components/PaymentProductPrice/PaymentProductPrice.js +13 -6
- package/lib/esm/components/PaymentProducts/PaymentProducts.d.ts +3 -1
- package/lib/esm/components/PaymentProducts/PaymentProducts.js +10 -4
- package/lib/esm/components/PaymentProductsDialog/PaymentProductsDialog.js +6 -0
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
- package/lib/cjs/components/PaymentInvoices/PaymentInvoices.d.ts +0 -4
- package/lib/cjs/components/PaymentInvoices/PaymentInvoices.js +0 -159
- package/lib/cjs/components/PaymentInvoices/index.d.ts +0 -3
- package/lib/cjs/components/PaymentInvoices/index.js +0 -5
- package/lib/esm/components/PaymentInvoices/PaymentInvoices.d.ts +0 -4
- package/lib/esm/components/PaymentInvoices/PaymentInvoices.js +0 -156
- package/lib/esm/components/PaymentInvoices/index.d.ts +0 -3
- package/lib/esm/components/PaymentInvoices/index.js +0 -2
|
@@ -73,6 +73,7 @@ function BuyButton(inProps) {
|
|
|
73
73
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
74
74
|
// CONST
|
|
75
75
|
const [purchased, setPurchased] = (0, react_1.useState)(null);
|
|
76
|
+
const [paymentOrder, setPaymentOrder] = (0, react_1.useState)(null);
|
|
76
77
|
const [btnLabel, setBtnLabel] = (0, react_1.useState)((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: `ui.buyButton.buy${contentType}`, id: `ui.buyButton.buy${(0, utils_1.capitalize)(contentType)}` }));
|
|
77
78
|
// HANDLERS
|
|
78
79
|
const handleClose = (0, react_1.useCallback)(() => {
|
|
@@ -88,6 +89,13 @@ function BuyButton(inProps) {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
}, [scUserContext.user, open, scContext.settings]);
|
|
92
|
+
/**
|
|
93
|
+
* Handle update order
|
|
94
|
+
* Price param is the new price selected
|
|
95
|
+
*/
|
|
96
|
+
const handleUpdatePaymentOrder = (0, react_1.useCallback)((price) => {
|
|
97
|
+
// TODO: update order/subscription when will be recurring payment
|
|
98
|
+
}, [paymentOrder, purchased]);
|
|
91
99
|
/**
|
|
92
100
|
* Get current status
|
|
93
101
|
*/
|
|
@@ -101,6 +109,9 @@ function BuyButton(inProps) {
|
|
|
101
109
|
if (data.subscription_status === types_1.SCEventSubscriptionStatusType.GOING) {
|
|
102
110
|
setBtnLabel((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.buyButton.purchased", id: "ui.buyButton.purchased" }));
|
|
103
111
|
}
|
|
112
|
+
if (data.payment_order) {
|
|
113
|
+
setPaymentOrder(data.payment_order);
|
|
114
|
+
}
|
|
104
115
|
setPurchased(data.subscription_status === types_1.SCEventSubscriptionStatusType.GOING);
|
|
105
116
|
}
|
|
106
117
|
});
|
|
@@ -111,6 +122,9 @@ function BuyButton(inProps) {
|
|
|
111
122
|
if (data.followed) {
|
|
112
123
|
setBtnLabel((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.buyButton.subscribed", id: "ui.buyButton.subscribed" }));
|
|
113
124
|
}
|
|
125
|
+
if (data.payment_order) {
|
|
126
|
+
setPaymentOrder(data.payment_order);
|
|
127
|
+
}
|
|
114
128
|
setPurchased(data.followed);
|
|
115
129
|
});
|
|
116
130
|
break;
|
|
@@ -122,22 +136,43 @@ function BuyButton(inProps) {
|
|
|
122
136
|
if (data.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
|
|
123
137
|
setBtnLabel((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.buyButton.subscribed", id: "ui.buyButton.subscribed" }));
|
|
124
138
|
}
|
|
139
|
+
if (data.payment_order) {
|
|
140
|
+
setPaymentOrder(data.payment_order);
|
|
141
|
+
}
|
|
125
142
|
setPurchased(data.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED);
|
|
126
143
|
}
|
|
127
144
|
});
|
|
128
145
|
break;
|
|
146
|
+
case types_1.SCContentType.COURSE:
|
|
147
|
+
// Get status course joined
|
|
148
|
+
api_services_1.CourseApiClient.getCourseStatus(contentId ? contentId : content.id).then((data) => {
|
|
149
|
+
var _a;
|
|
150
|
+
if (scUserContext.user && ((_a = data === null || data === void 0 ? void 0 : data.managed_by) === null || _a === void 0 ? void 0 : _a.id) !== scUserContext.user.id) {
|
|
151
|
+
if (data.subscription_status === types_1.SCCourseJoinStatusType.JOINED) {
|
|
152
|
+
setBtnLabel((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.buyButton.subscribed", id: "ui.buyButton.subscribed" }));
|
|
153
|
+
}
|
|
154
|
+
if (data.payment_order) {
|
|
155
|
+
setPaymentOrder(data.payment_order);
|
|
156
|
+
}
|
|
157
|
+
setPurchased(data.subscription_status === types_1.SCCourseJoinStatusType.JOINED);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
break;
|
|
129
161
|
default:
|
|
130
162
|
break;
|
|
131
163
|
}
|
|
132
164
|
};
|
|
133
165
|
(0, react_1.useEffect)(() => {
|
|
134
|
-
if ((contentId || content) && contentType) {
|
|
166
|
+
if ((contentId || content) && contentType && scUserContext.user) {
|
|
135
167
|
getStatus();
|
|
136
168
|
}
|
|
137
|
-
|
|
169
|
+
else if (scUserContext.user === null) {
|
|
170
|
+
setPurchased(false);
|
|
171
|
+
}
|
|
172
|
+
}, [contentId, content, contentType, scUserContext.user]);
|
|
138
173
|
if (!contentId && !content) {
|
|
139
174
|
return null;
|
|
140
175
|
}
|
|
141
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(RequestRoot, Object.assign({ className: (0, classnames_1.default)(classes.requestRoot, className), variant: "contained", color: purchased ? 'inherit' : 'secondary', size: "small", startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "card_giftcard" }), loading: scUserContext.user === undefined || purchased === null, onClick: handleOpen }, rest, { children: btnLabel })), open && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: true, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: purchased ? ((0, jsx_runtime_1.jsx)(PaymentDetailDialog_1.default, { open: true, disableInitialTransition: true, onClose: handleClose })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", component: "div", marginBottom: 2 }, { children: (0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentProductsDialog.title", defaultMessage: "ui.paymentProductsDialog.title" }) }) })), (0, jsx_runtime_1.jsx)(PaymentProducts_1.default, Object.assign({ contentType: contentType }, (content ? { content } : { contentId })))] })) }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: purchased ? ((0, jsx_runtime_1.jsx)(PaymentDetailDialog_1.default, { open: true, onClose: handleClose })) : ((0, jsx_runtime_1.jsx)(PaymentProductsDialog_1.default, { open: true, onClose: handleClose, PaymentProductsComponentProps: Object.assign({ contentType }, (content ? { content } : { contentId })) })) })) }))] }));
|
|
176
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(RequestRoot, Object.assign({ className: (0, classnames_1.default)(classes.requestRoot, className), variant: "contained", color: purchased ? 'inherit' : 'secondary', size: "small", startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "card_giftcard" }), loading: scUserContext.user === undefined || purchased === null, onClick: handleOpen }, rest, { children: btnLabel })), open && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: true, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: purchased ? ((0, jsx_runtime_1.jsx)(PaymentDetailDialog_1.default, { open: true, disableInitialTransition: true, onClose: handleClose })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", component: "div", marginBottom: 2 }, { children: (0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentProductsDialog.title", defaultMessage: "ui.paymentProductsDialog.title" }) }) })), (0, jsx_runtime_1.jsx)(PaymentProducts_1.default, Object.assign({ contentType: contentType }, (content ? { content } : { contentId }), (paymentOrder && { paymentOrder: paymentOrder, onUpdatePaymentOrder: handleUpdatePaymentOrder })))] })) }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: purchased ? ((0, jsx_runtime_1.jsx)(PaymentDetailDialog_1.default, { open: true, onClose: handleClose })) : ((0, jsx_runtime_1.jsx)(PaymentProductsDialog_1.default, { open: true, onClose: handleClose, PaymentProductsComponentProps: Object.assign(Object.assign({ contentType }, (content ? { content } : { contentId })), (paymentOrder && { paymentOrder: paymentOrder, onUpdatePaymentOrder: handleUpdatePaymentOrder })) })) })) }))] }));
|
|
142
177
|
}
|
|
143
178
|
exports.default = BuyButton;
|
|
@@ -22,6 +22,7 @@ const Course_1 = tslib_1.__importDefault(require("../Course"));
|
|
|
22
22
|
const Group_1 = tslib_1.__importDefault(require("../Group"));
|
|
23
23
|
const event_1 = require("../../types/event");
|
|
24
24
|
const course_1 = require("../../types/course");
|
|
25
|
+
const react_core_2 = require("@selfcommunity/react-core");
|
|
25
26
|
const classes = {
|
|
26
27
|
root: `${constants_1.PREFIX}-root`,
|
|
27
28
|
content: `${constants_1.PREFIX}-content`,
|
|
@@ -33,48 +34,7 @@ const classes = {
|
|
|
33
34
|
const Root = (0, styles_1.styled)(material_1.Box, {
|
|
34
35
|
slot: 'Root',
|
|
35
36
|
name: constants_1.PREFIX
|
|
36
|
-
})(({ theme }) => ({
|
|
37
|
-
position: 'relative',
|
|
38
|
-
backgroundColor: theme.palette.background.paper,
|
|
39
|
-
display: 'flex',
|
|
40
|
-
flexDirection: 'column',
|
|
41
|
-
justifyContent: 'space-between',
|
|
42
|
-
alignItems: 'center',
|
|
43
|
-
[`& .${classes.content}`]: {
|
|
44
|
-
width: '100%',
|
|
45
|
-
maxWidth: 860,
|
|
46
|
-
display: 'grid',
|
|
47
|
-
gridTemplateColumns: '1fr 1fr',
|
|
48
|
-
gap: 0,
|
|
49
|
-
[theme.breakpoints.down(1034)]: {
|
|
50
|
-
display: 'flex',
|
|
51
|
-
flexDirection: 'column',
|
|
52
|
-
justifyContent: 'space-between',
|
|
53
|
-
alignItems: 'center'
|
|
54
|
-
},
|
|
55
|
-
[`& .${classes.contentObject}`]: {
|
|
56
|
-
display: 'flex',
|
|
57
|
-
flexDirection: 'column',
|
|
58
|
-
justifyContent: 'center',
|
|
59
|
-
alignItems: 'flex-start'
|
|
60
|
-
},
|
|
61
|
-
[`& .${classes.contentDesc}`]: {
|
|
62
|
-
[theme.breakpoints.down(1034)]: {
|
|
63
|
-
display: 'none'
|
|
64
|
-
},
|
|
65
|
-
maxWidth: 600,
|
|
66
|
-
padding: theme.spacing(4)
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
[`& .${classes.checkout}`]: {
|
|
70
|
-
width: '100%',
|
|
71
|
-
bottom: theme.spacing(2)
|
|
72
|
-
},
|
|
73
|
-
[`& .${classes.object}`]: {
|
|
74
|
-
marginTop: theme.spacing(2),
|
|
75
|
-
minWidth: 395
|
|
76
|
-
}
|
|
77
|
-
}));
|
|
37
|
+
})(({ theme }) => ({}));
|
|
78
38
|
function Checkout(inProps) {
|
|
79
39
|
// PROPS
|
|
80
40
|
const props = (0, system_1.useThemeProps)({
|
|
@@ -82,18 +42,14 @@ function Checkout(inProps) {
|
|
|
82
42
|
name: constants_1.PREFIX
|
|
83
43
|
});
|
|
84
44
|
const { className, contentType, contentId, content, priceId } = props, rest = tslib_1.__rest(props, ["className", "contentType", "contentId", "content", "priceId"]);
|
|
85
|
-
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
86
45
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
87
46
|
const [initialized, setInitialized] = (0, react_1.useState)(false);
|
|
88
47
|
// CONTEXT
|
|
89
48
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
90
49
|
const intl = (0, react_intl_1.useIntl)();
|
|
91
|
-
//
|
|
92
|
-
const stripePublicKey = (0,
|
|
93
|
-
const
|
|
94
|
-
react_core_1.SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID in preferences &&
|
|
95
|
-
preferences[react_core_1.SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID].value, [preferences]);
|
|
96
|
-
const stripePromise = stripePublicKey && stripeConnectedAccountId && stripe_js_1.loadStripe
|
|
50
|
+
// HOOKS
|
|
51
|
+
const { isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId } = (0, react_core_2.useSCPaymentsEnabled)();
|
|
52
|
+
const stripePromise = isPaymentsEnabled && stripePublicKey && stripeConnectedAccountId && stripe_js_1.loadStripe
|
|
97
53
|
? (0, stripe_js_1.loadStripe)(stripePublicKey, { stripeAccount: stripeConnectedAccountId, locale: (0, payment_1.getDefaultLocale)(intl).locale })
|
|
98
54
|
: null;
|
|
99
55
|
// STATE
|
|
@@ -101,7 +57,6 @@ function Checkout(inProps) {
|
|
|
101
57
|
const isContentObject = (0, react_1.useMemo)(() => contentType && contentId !== undefined, [contentType, contentId]);
|
|
102
58
|
const fetchClientSecret = (0, react_1.useCallback)(() => {
|
|
103
59
|
// Create a Checkout Session
|
|
104
|
-
// TODO: During session create check customer_email or customer to force email prefilled and disabled changes
|
|
105
60
|
if (!loading) {
|
|
106
61
|
console.log('fetching client secret...');
|
|
107
62
|
setInitialized(true);
|
|
@@ -131,6 +86,9 @@ function Checkout(inProps) {
|
|
|
131
86
|
};
|
|
132
87
|
}
|
|
133
88
|
}, [scUserContext.user, clientSecret, stripePromise, contentType, contentId, content, priceId, loading, initialized]);
|
|
89
|
+
if (!isPaymentsEnabled) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
134
92
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
135
93
|
if (!stripePromise || !clientSecret || !scUserContext.user) {
|
|
136
94
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
@@ -155,6 +113,6 @@ function Checkout(inProps) {
|
|
|
155
113
|
}
|
|
156
114
|
return _c;
|
|
157
115
|
};
|
|
158
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [isContentObject && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: renderContentObject() })), (0, jsx_runtime_1.
|
|
116
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [isContentObject && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: renderContentObject() })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.contentDesc }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", mb: 1 }, { children: (0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkout.contentDesc.title", defaultMessage: "ui.checkout.contentDesc.title" }) }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", color: "textSecondary" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkout.contentDesc.subTitle", defaultMessage: "ui.checkout.contentDesc.subTitle" }) }))] }))] }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ id: "checkout", className: classes.checkout }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckoutProvider, Object.assign({ stripe: stripePromise, options: { clientSecret } }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckout, {}) })) }))] })));
|
|
159
117
|
}
|
|
160
118
|
exports.default = Checkout;
|
|
@@ -11,6 +11,7 @@ const react_intl_1 = require("react-intl");
|
|
|
11
11
|
const types_1 = require("@selfcommunity/types");
|
|
12
12
|
const clapping_1 = require("../../assets/courses/clapping");
|
|
13
13
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
14
|
+
const react_core_2 = require("@selfcommunity/react-core");
|
|
14
15
|
const Event_1 = tslib_1.__importDefault(require("../Event"));
|
|
15
16
|
const event_1 = require("../../types/event");
|
|
16
17
|
const course_1 = require("../../types/course");
|
|
@@ -20,10 +21,12 @@ const Errors_1 = require("../../constants/Errors");
|
|
|
20
21
|
const Category_1 = tslib_1.__importDefault(require("../Category"));
|
|
21
22
|
const Course_1 = tslib_1.__importDefault(require("../Course"));
|
|
22
23
|
const Group_1 = tslib_1.__importDefault(require("../Group"));
|
|
23
|
-
const
|
|
24
|
+
const Grow_1 = tslib_1.__importDefault(require("@mui/material/Grow"));
|
|
25
|
+
const PREFIX = 'SCCheckoutReturnDialog';
|
|
24
26
|
const classes = {
|
|
25
27
|
root: `${PREFIX}-root`,
|
|
26
28
|
img: `${PREFIX}-img`,
|
|
29
|
+
contentObject: `${PREFIX}-content-object`,
|
|
27
30
|
object: `${PREFIX}-object`,
|
|
28
31
|
btn: `${PREFIX}-btn`
|
|
29
32
|
};
|
|
@@ -48,9 +51,10 @@ function CheckoutReturnDialog(inProps) {
|
|
|
48
51
|
const [contentType, setContentType] = (0, react_1.useState)(null);
|
|
49
52
|
const [contentId, setContentId] = (0, react_1.useState)(null);
|
|
50
53
|
// HOOKS
|
|
54
|
+
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
51
55
|
const intl = (0, react_intl_1.useIntl)();
|
|
52
56
|
// CONTEXT
|
|
53
|
-
const scRoutingContext = (0,
|
|
57
|
+
const scRoutingContext = (0, react_core_2.useSCRouting)();
|
|
54
58
|
(0, react_1.useEffect)(() => {
|
|
55
59
|
api_services_1.PaymentApiClient.getCheckoutSession({ session_id: checkoutSessionId })
|
|
56
60
|
.then((r) => {
|
|
@@ -70,24 +74,30 @@ function CheckoutReturnDialog(inProps) {
|
|
|
70
74
|
});
|
|
71
75
|
}, []);
|
|
72
76
|
const renderTitle = () => {
|
|
73
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !loading && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.
|
|
77
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !loading && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.title", defaultMessage: "ui.checkoutReturnDialog.title" }) });
|
|
74
78
|
};
|
|
75
79
|
const renderContent = () => {
|
|
76
|
-
let
|
|
80
|
+
let footer;
|
|
77
81
|
if (contentType === types_1.SCContentType.EVENT) {
|
|
78
|
-
|
|
82
|
+
footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Event_1.default, { eventId: contentId, template: event_1.SCEventTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.EVENT_ROUTE_NAME, { id: contentId }), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.event.button", defaultMessage: "ui.checkoutReturnDialog.event.button" }) }))] }));
|
|
79
83
|
}
|
|
80
84
|
else if (contentType === types_1.SCContentType.CATEGORY) {
|
|
81
|
-
|
|
85
|
+
footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Category_1.default, { categoryId: contentId, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.CATEGORY_ROUTE_NAME, { id: contentId }), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.category.button", defaultMessage: "ui.checkoutReturnDialog.category.button" }) }))] }));
|
|
82
86
|
}
|
|
83
87
|
else if (contentType === types_1.SCContentType.COURSE) {
|
|
84
|
-
|
|
88
|
+
footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Course_1.default, { courseId: contentId, template: course_1.SCCourseTemplateType.PREVIEW, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.COURSE_ROUTE_NAME, { id: contentId }), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.course.button", defaultMessage: "ui.checkoutReturnDialog.course.button" }) }))] }));
|
|
85
89
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
else if (contentType === types_1.SCContentType.GROUP) {
|
|
91
|
+
footer = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.contentObject }, { children: (0, jsx_runtime_1.jsx)(Group_1.default, { courseId: contentId, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), hideEventParticipants: true, hideEventPlanner: true, variant: "outlined", className: classes.object }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "medium", variant: 'contained', to: scRoutingContext.url(react_core_2.SCRoutes.GROUP_ROUTE_NAME, { id: contentId }), component: react_core_2.Link, className: classes.btn }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.category.button", defaultMessage: "ui.checkoutReturnDialog.category.button" }) }))] }));
|
|
92
|
+
}
|
|
93
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ spacing: 2, justifyContent: "center", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(Grow_1.default, Object.assign({ in: true, style: { transitionDelay: '300ms' } }, { children: (0, jsx_runtime_1.jsx)("img", { src: clapping_1.CLAPPING, className: classes.img, alt: intl.formatMessage({
|
|
94
|
+
id: 'ui.checkoutReturnDialog.buy',
|
|
95
|
+
defaultMessage: 'ui.checkoutReturnDialog.buy'
|
|
96
|
+
}), width: 100, height: 100 }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", color: "textSecondary" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.checkoutReturnDialog.buy", defaultMessage: "ui.checkoutReturnDialog.buy" }) })), footer] })));
|
|
90
97
|
};
|
|
98
|
+
if (!isPaymentsEnabled) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
91
101
|
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ maxWidth: 'sm', fullWidth: true, scroll: 'paper', open: true }, (disableInitialTransition ? { TransitionComponent: NoTransition } : { TransitionComponent: Transition }), { className: (0, classnames_1.default)(classes.root, className), TransitionComponent: Transition }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: renderTitle() }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: loading ? (0, jsx_runtime_1.jsx)(material_1.CircularProgress, {}) : renderContent() })] })));
|
|
92
102
|
}
|
|
93
103
|
exports.default = CheckoutReturnDialog;
|
|
@@ -22,6 +22,7 @@ const GroupInviteButton_1 = tslib_1.__importDefault(require("../GroupInviteButto
|
|
|
22
22
|
const PubSub_1 = require("../../constants/PubSub");
|
|
23
23
|
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
24
24
|
const GroupActionsMenu_1 = tslib_1.__importDefault(require("../GroupActionsMenu"));
|
|
25
|
+
const BuyButton_1 = tslib_1.__importDefault(require("../BuyButton"));
|
|
25
26
|
const classes = {
|
|
26
27
|
root: `${constants_1.PREFIX}-root`,
|
|
27
28
|
cover: `${constants_1.PREFIX}-cover`,
|
|
@@ -89,6 +90,7 @@ function GroupHeader(inProps) {
|
|
|
89
90
|
const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
90
91
|
const theme = (0, material_1.useTheme)();
|
|
91
92
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
93
|
+
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
92
94
|
// REFS
|
|
93
95
|
const updatesSubscription = (0, react_1.useRef)(null);
|
|
94
96
|
// CONST
|
|
@@ -153,6 +155,6 @@ function GroupHeader(inProps) {
|
|
|
153
155
|
: { background: `url('${scPreferences.preferences[react_core_1.SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
|
|
154
156
|
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.avatar }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { children: (0, jsx_runtime_1.jsx)("img", { alt: "group", src: scGroup.image_big ? scGroup.image_big : '' }) }) })), isGroupAdmin && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ChangeGroupPicture_1.default, Object.assign({ groupId: scGroup.id, onChange: handleChangeAvatar, className: classes.changePicture }, ChangePictureProps)), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.changeCover }, { children: (0, jsx_runtime_1.jsx)(ChangeGroupCover_1.default, Object.assign({ groupId: scGroup.id, onChange: handleChangeCover }, ChangeCoverProps)) }))] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.info }, { children: [isGroupAdmin && !isMobile && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EditGroupButton_1.default, { group: scGroup, groupId: scGroup.id, onEditSuccess: (data) => setSCGroup(data) }), (0, jsx_runtime_1.jsx)(GroupActionsMenu_1.default, Object.assign({ group: scGroup, onEditSuccess: (data) => setSCGroup(data) }, GroupActionsProps))] }))), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scGroup.name })), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [privateEnabled && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.public", defaultMessage: "ui.groupHeader.visibility.public" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.private", defaultMessage: "ui.groupHeader.visibility.private" })] }))) })), visibilityEnabled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [privateEnabled && (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), scGroup.visible ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "visibility" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "visibility_off" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })] })))] }))] }))), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: ((scGroup && scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC) ||
|
|
155
157
|
scGroup.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED ||
|
|
156
|
-
isGroupAdmin) && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.members }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.membersCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } }) })), (0, jsx_runtime_1.jsx)(GroupMembersButton_1.default, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps), scGroup.subscribers_counter)] }))) }), isGroupAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(GroupInviteButton_1.default, { group: scGroup, groupId: scGroup.id }), isMobile && (0, jsx_runtime_1.jsx)(GroupActionsMenu_1.default, Object.assign({ group: scGroup, onEditSuccess: (data) => setSCGroup(data) }, GroupActionsProps))] })) : ((0, jsx_runtime_1.jsx)(GroupSubscribeButton_1.default, Object.assign({ group: scGroup, onSubscribe: handleSubscribe }, GroupSubscribeButtonProps)))] }))] })));
|
|
158
|
+
isGroupAdmin) && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.members }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.membersCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } }) })), (0, jsx_runtime_1.jsx)(GroupMembersButton_1.default, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps), scGroup.subscribers_counter)] }))) }), isGroupAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(GroupInviteButton_1.default, { group: scGroup, groupId: scGroup.id }), isMobile && (0, jsx_runtime_1.jsx)(GroupActionsMenu_1.default, Object.assign({ group: scGroup, onEditSuccess: (data) => setSCGroup(data) }, GroupActionsProps))] })) : isPaymentsEnabled ? ((0, jsx_runtime_1.jsx)(BuyButton_1.default, { contentType: types_1.SCContentType.GROUP, content: scGroup })) : ((0, jsx_runtime_1.jsx)(GroupSubscribeButton_1.default, Object.assign({ group: scGroup, onSubscribe: handleSubscribe }, GroupSubscribeButtonProps)))] }))] })));
|
|
157
159
|
}
|
|
158
160
|
exports.default = GroupHeader;
|
|
@@ -92,6 +92,7 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
92
92
|
PREFERENCES.map((p) => (_preferences[p] = p in scPreferences.preferences ? scPreferences.preferences[p].value : null));
|
|
93
93
|
return _preferences;
|
|
94
94
|
}, [scPreferences.preferences]);
|
|
95
|
+
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
95
96
|
// HANDLERS
|
|
96
97
|
const handleOpen = (event) => {
|
|
97
98
|
setAnchorEl(event.currentTarget);
|
|
@@ -161,6 +162,12 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
161
162
|
]
|
|
162
163
|
: []),
|
|
163
164
|
(0, jsx_runtime_1.jsx)(material_1.ListItem, Object.assign({ className: classes.item }, { children: (0, jsx_runtime_1.jsx)(material_1.ListItemButton, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_SETTINGS_ROUTE_NAME, scUserContext.user) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.settings", defaultMessage: "ui.navigationSettingsIconButton.settings" }) })) }), "settings"),
|
|
165
|
+
...(isPaymentsEnabled
|
|
166
|
+
? [
|
|
167
|
+
(0, jsx_runtime_1.jsx)(material_1.Divider, {}, "payments_divider"),
|
|
168
|
+
(0, jsx_runtime_1.jsx)(material_1.ListItem, Object.assign({ className: classes.item }, { children: (0, jsx_runtime_1.jsx)(material_1.ListItemButton, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME, scUserContext.user) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.historyOrders", defaultMessage: "ui.navigationSettingsIconButton.historyOrders" }) })) }), "paymentsHistoryOrder")
|
|
169
|
+
]
|
|
170
|
+
: []),
|
|
164
171
|
(0, jsx_runtime_1.jsx)(material_1.Divider, {}, "divider"),
|
|
165
172
|
(0, jsx_runtime_1.jsx)(material_1.ListItem, Object.assign({ className: classes.item }, { children: (0, jsx_runtime_1.jsx)(material_1.ListItemButton, Object.assign({ onClick: handleLogout }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.logout", defaultMessage: "ui.navigationSettingsIconButton.logout" }) })) }), "logout")
|
|
166
173
|
];
|
|
@@ -192,6 +199,12 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
192
199
|
]
|
|
193
200
|
: []),
|
|
194
201
|
(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ className: classes.item, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_SETTINGS_ROUTE_NAME, scUserContext.user) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.settings", defaultMessage: "ui.navigationSettingsIconButton.settings" }) }), "settings"),
|
|
202
|
+
...(isPaymentsEnabled
|
|
203
|
+
? [
|
|
204
|
+
(0, jsx_runtime_1.jsx)(material_1.Divider, {}, "payments_divider"),
|
|
205
|
+
(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ className: classes.item, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME, scUserContext.user) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.historyOrders", defaultMessage: "ui.navigationSettingsIconButton.historyOrders" }) }), "historyOrders")
|
|
206
|
+
]
|
|
207
|
+
: []),
|
|
195
208
|
(0, jsx_runtime_1.jsx)(material_1.Divider, {}, "divider"),
|
|
196
209
|
(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: handleLogout }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.logout", defaultMessage: "ui.navigationSettingsIconButton.logout" }) }), "logout")
|
|
197
210
|
];
|
|
@@ -7,6 +7,7 @@ const material_1 = require("@mui/material");
|
|
|
7
7
|
const styles_1 = require("@mui/material/styles");
|
|
8
8
|
const system_1 = require("@mui/system");
|
|
9
9
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
10
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
10
11
|
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
11
12
|
const react_intl_1 = require("react-intl");
|
|
12
13
|
const PREFIX = 'SCPaymentProductsDialog';
|
|
@@ -30,6 +31,11 @@ function PaymentDetailDialog(inProps) {
|
|
|
30
31
|
name: PREFIX
|
|
31
32
|
});
|
|
32
33
|
const { className, disableInitialTransition = false } = props, rest = tslib_1.__rest(props, ["className", "disableInitialTransition"]);
|
|
34
|
+
// HOOKS
|
|
35
|
+
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
36
|
+
if (!isPaymentsEnabled) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
33
39
|
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ maxWidth: 'sm', fullWidth: true, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentDetailDialog.title", defaultMessage: "ui.paymentDetailDialog.title" }), scroll: 'paper', open: true }, (disableInitialTransition ? { TransitionComponent: NoTransition } : { TransitionComponent: Transition }), { className: (0, classnames_1.default)(classes.root, className), TransitionComponent: Transition }, rest, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentDetailDialog.content", defaultMessage: "ui.paymentDetailDialog.content" }) })));
|
|
34
40
|
}
|
|
35
41
|
exports.default = PaymentDetailDialog;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const styles_1 = require("@mui/material/styles");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const LoadingButton_1 = tslib_1.__importDefault(require("@mui/lab/LoadingButton"));
|
|
10
|
+
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
11
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
12
|
+
const system_1 = require("@mui/system");
|
|
13
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
14
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
15
|
+
const PREFIX = 'SCPaymentOrders';
|
|
16
|
+
const classes = {
|
|
17
|
+
root: `${PREFIX}-root`,
|
|
18
|
+
content: `${PREFIX}-content`,
|
|
19
|
+
headline: `${PREFIX}-headline`,
|
|
20
|
+
btnSave: `${PREFIX}-btn-save`
|
|
21
|
+
};
|
|
22
|
+
const Root = (0, styles_1.styled)(material_1.Box, {
|
|
23
|
+
slot: 'Root',
|
|
24
|
+
name: PREFIX
|
|
25
|
+
})(({ theme }) => ({
|
|
26
|
+
[`& .${classes.content}`]: {
|
|
27
|
+
position: 'relative',
|
|
28
|
+
padding: '30px 10px'
|
|
29
|
+
},
|
|
30
|
+
[`& .${classes.headline}`]: {
|
|
31
|
+
margin: '40px 0',
|
|
32
|
+
display: 'flex',
|
|
33
|
+
flexWrap: 'wrap',
|
|
34
|
+
justifyContent: 'space-between'
|
|
35
|
+
},
|
|
36
|
+
[`& .${classes.btnSave}`]: {
|
|
37
|
+
margin: '30px 0'
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
function PaymentOrders(inProps) {
|
|
41
|
+
// PROPS
|
|
42
|
+
const props = (0, system_1.useThemeProps)({
|
|
43
|
+
props: inProps,
|
|
44
|
+
name: PREFIX
|
|
45
|
+
});
|
|
46
|
+
const { className } = props, rest = tslib_1.__rest(props, ["className"]);
|
|
47
|
+
// STATE
|
|
48
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
49
|
+
const [orders, setInvoices] = (0, react_1.useState)([]);
|
|
50
|
+
const [hasMore, setHasMore] = (0, react_1.useState)(true);
|
|
51
|
+
const [next, setNext] = (0, react_1.useState)(null);
|
|
52
|
+
const [isLoadingPage, setIsLoadingPage] = (0, react_1.useState)(false);
|
|
53
|
+
// HOOKS
|
|
54
|
+
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
55
|
+
const { ref, inView } = (0, react_intersection_observer_1.useInView)({ triggerOnce: false });
|
|
56
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
57
|
+
/**
|
|
58
|
+
* Infinite load more orders
|
|
59
|
+
*/
|
|
60
|
+
const loadMore = (0, react_1.useCallback)(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const loadItems = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
try {
|
|
63
|
+
const res = yield api_services_1.PaymentService.getPaymentsOrder({ offset: orders.length });
|
|
64
|
+
if (res) {
|
|
65
|
+
setHasMore(res.next !== null);
|
|
66
|
+
setNext(res.next);
|
|
67
|
+
setInvoices(orders.concat(res.results));
|
|
68
|
+
setIsLoadingPage(false);
|
|
69
|
+
setIsLoading(false);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.error(error);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (hasMore && !isLoadingPage) {
|
|
77
|
+
setIsLoadingPage(true);
|
|
78
|
+
yield loadItems();
|
|
79
|
+
}
|
|
80
|
+
}), [orders, isLoadingPage, isLoading, hasMore, next]);
|
|
81
|
+
/**
|
|
82
|
+
* Load more orders
|
|
83
|
+
*/
|
|
84
|
+
(0, react_1.useEffect)(() => {
|
|
85
|
+
if (inView) {
|
|
86
|
+
loadMore();
|
|
87
|
+
}
|
|
88
|
+
}, [inView]);
|
|
89
|
+
/**
|
|
90
|
+
* Initial load
|
|
91
|
+
*/
|
|
92
|
+
(0, react_1.useEffect)(() => {
|
|
93
|
+
loadMore();
|
|
94
|
+
}, []);
|
|
95
|
+
if (!isPaymentsEnabled) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Render skeleton
|
|
100
|
+
*/
|
|
101
|
+
const skeleton = () => {
|
|
102
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.TableRow, Object.assign({ ref: ref }, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 110 }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 60 }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 130 }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 150 }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 65 }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 65 }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 65 }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", height: 40, width: 65 }) }))] })));
|
|
103
|
+
};
|
|
104
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.content }, { children: !isLoading ? ((0, jsx_runtime_1.jsx)(material_1.TableContainer, Object.assign({ style: { margin: 'auto', borderRadius: 0 }, component: material_1.Paper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Table, Object.assign({ sx: { minWidth: 650 }, "aria-label": "simple table", stickyHeader: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.TableHead, { children: (0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: "5%" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.number", defaultMessage: "ui.paymentOrders.number" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: "10%" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.contentType", defaultMessage: "ui.paymentOrders.contentType" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: "20%" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.content", defaultMessage: "ui.paymentOrders.content" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: "10%" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.price", defaultMessage: "ui.paymentOrders.price" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: "15%" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.createdAt", defaultMessage: "ui.paymentOrders.createdAt" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: "15%" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.expired_at", defaultMessage: "ui.paymentOrders.expired_at" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ width: "10%" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.status", defaultMessage: "ui.paymentOrders.status" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.actions", defaultMessage: "ui.paymentOrders.actions" }) })] }) }), (0, jsx_runtime_1.jsxs)(material_1.TableBody, { children: [orders.map((order, index) => ((0, jsx_runtime_1.jsxs)(material_1.TableRow, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: (0, jsx_runtime_1.jsx)("b", { children: order.id }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: order.content_type })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: order.content_name })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: order.payment_price })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: order.created_at &&
|
|
105
|
+
intl.formatDate(new Date(order.created_at), {
|
|
106
|
+
year: 'numeric',
|
|
107
|
+
month: 'numeric',
|
|
108
|
+
day: 'numeric',
|
|
109
|
+
hour: 'numeric',
|
|
110
|
+
minute: 'numeric'
|
|
111
|
+
}) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: order.expired_at
|
|
112
|
+
? intl.formatDate(new Date(order.expired_at), {
|
|
113
|
+
year: 'numeric',
|
|
114
|
+
month: 'numeric',
|
|
115
|
+
day: 'numeric',
|
|
116
|
+
hour: 'numeric',
|
|
117
|
+
minute: 'numeric'
|
|
118
|
+
})
|
|
119
|
+
: '-' })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Chip, { variant: 'outlined', label: "Pagata", color: "success", size: "small" }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ scope: "row" }, { children: (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "left", alignItems: "center", spacing: 2 }, { children: Boolean(!order.paid && order.billing_reason === 'subscription_create') && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, Object.assign({ size: "small", variant: "contained", disabled: true }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.pay", defaultMessage: "ui.paymentOrders.pay" }) }))) })) }))] }, index))), orders.length < 1 && ((0, jsx_runtime_1.jsx)(material_1.TableRow, { children: (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ align: "left", colSpan: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paymentOrders.noOrders", defaultMessage: "ui.paymentOrders.noOrders" }) }) })) })) })), hasMore && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: skeleton() })] })] })) }))) : ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, {})) })) })));
|
|
120
|
+
}
|
|
121
|
+
exports.default = PaymentOrders;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SCPaymentProduct, SCContentType, SCPurchasableContent } from '@selfcommunity/types';
|
|
1
|
+
import { SCPaymentProduct, SCContentType, SCPurchasableContent, SCPaymentOrder, SCPaymentPrice } from '@selfcommunity/types';
|
|
2
2
|
export interface PaymentProductProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
id?: number | string;
|
|
@@ -6,5 +6,7 @@ export interface PaymentProductProps {
|
|
|
6
6
|
contentType?: SCContentType;
|
|
7
7
|
contentId?: number | string;
|
|
8
8
|
content?: SCPurchasableContent;
|
|
9
|
+
paymentOrder?: SCPaymentOrder;
|
|
10
|
+
onUpdatePaymentOrder?: (price: SCPaymentPrice, contentType?: SCContentType, contentId?: string | number) => void;
|
|
9
11
|
}
|
|
10
12
|
export default function PaymentProduct(inProps: PaymentProductProps): JSX.Element;
|
|
@@ -6,6 +6,7 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const styles_1 = require("@mui/material/styles");
|
|
7
7
|
const system_1 = require("@mui/system");
|
|
8
8
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
9
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
10
|
const constants_1 = require("./constants");
|
|
10
11
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
11
12
|
const Accordion_1 = tslib_1.__importDefault(require("@mui/material/Accordion"));
|
|
@@ -23,10 +24,15 @@ function PaymentProduct(inProps) {
|
|
|
23
24
|
props: inProps,
|
|
24
25
|
name: constants_1.PREFIX
|
|
25
26
|
});
|
|
26
|
-
const { className, id, product, contentType, contentId, content } = props, rest = tslib_1.__rest(props, ["className", "id", "product", "contentType", "contentId", "content"]);
|
|
27
|
+
const { className, id, product, contentType, contentId, content, paymentOrder, onUpdatePaymentOrder } = props, rest = tslib_1.__rest(props, ["className", "id", "product", "contentType", "contentId", "content", "paymentOrder", "onUpdatePaymentOrder"]);
|
|
28
|
+
// HOOKS
|
|
29
|
+
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
30
|
+
if (!isPaymentsEnabled) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
27
33
|
if (!product) {
|
|
28
34
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
29
35
|
}
|
|
30
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ defaultExpanded: true, square: true, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.AccordionSummary, Object.assign({ "aria-controls": "panel1-content", id: "panel1-header" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", component: "div" }, { children: (0, jsx_runtime_1.jsx)("b", { children: product.name }) })), product.description && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", component: "div" }, { children: product.description })))] })), (0, jsx_runtime_1.jsx)(material_1.AccordionDetails, { children: product.payment_prices.map((price, index) => ((0, jsx_runtime_1.jsx)(PaymentProductPrice_1.default, Object.assign({ price: price, contentType: contentType }, (content ? { content } : { contentId })), index))) })] })));
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ defaultExpanded: true, square: true, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.AccordionSummary, Object.assign({ "aria-controls": "panel1-content", id: "panel1-header" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", component: "div" }, { children: (0, jsx_runtime_1.jsx)("b", { children: product.name }) })), product.description && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", component: "div" }, { children: product.description })))] })), (0, jsx_runtime_1.jsx)(material_1.AccordionDetails, { children: product.payment_prices.map((price, index) => ((0, jsx_runtime_1.jsx)(PaymentProductPrice_1.default, Object.assign({ price: price, contentType: contentType }, (content ? { content } : { contentId }), (paymentOrder && { paymentOrder, onHandleActionBuy: onUpdatePaymentOrder })), index))) })] })));
|
|
31
37
|
}
|
|
32
38
|
exports.default = PaymentProduct;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SCContentType, SCPaymentPrice, SCPurchasableContent } from '@selfcommunity/types';
|
|
2
|
+
import { SCContentType, SCPaymentOrder, SCPaymentPrice, SCPurchasableContent } from '@selfcommunity/types';
|
|
3
3
|
export interface PaymentProductPriceProps {
|
|
4
4
|
className?: string;
|
|
5
5
|
id?: number | string;
|
|
@@ -8,6 +8,7 @@ export interface PaymentProductPriceProps {
|
|
|
8
8
|
contentId?: number | string;
|
|
9
9
|
content?: SCPurchasableContent;
|
|
10
10
|
actions?: React.ReactNode;
|
|
11
|
+
paymentOrder?: SCPaymentOrder;
|
|
11
12
|
onHandleActionBuy?: (price: SCPaymentPrice, contentType?: SCContentType, contentId?: string | number) => void;
|
|
12
13
|
}
|
|
13
14
|
export default function PaymentProductPrice(inProps: PaymentProductPriceProps): JSX.Element;
|