@selfcommunity/react-ui 0.10.5-payments.182 → 0.10.5-payments.183
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.d.ts +10 -0
- package/lib/cjs/components/BuyButton/BuyButton.js +4 -3
- package/lib/cjs/components/CourseDashboard/Student.js +9 -3
- package/lib/cjs/components/CourseForm/CourseForm.js +16 -7
- package/lib/cjs/components/EventForm/EventForm.js +18 -9
- package/lib/cjs/components/EventForm/types.d.ts +3 -1
- package/lib/cjs/components/EventHeader/EventHeader.js +1 -9
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +8 -1
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +15 -3
- package/lib/cjs/components/GroupForm/GroupForm.js +14 -9
- package/lib/cjs/components/GroupHeader/GroupHeader.js +2 -5
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +21 -1
- package/lib/cjs/components/PaymentOrder/PaymentOrder.d.ts +7 -0
- package/lib/cjs/components/PaymentOrder/PaymentOrder.js +81 -0
- package/lib/cjs/components/PaymentOrder/Skeleton.d.ts +30 -0
- package/lib/cjs/components/PaymentOrder/Skeleton.js +63 -0
- package/lib/cjs/components/PaymentOrder/constants.d.ts +1 -0
- package/lib/cjs/components/PaymentOrder/constants.js +4 -0
- package/lib/cjs/components/PaymentOrder/index.d.ts +3 -0
- package/lib/cjs/components/PaymentOrder/index.js +5 -0
- package/lib/cjs/components/PaymentOrderPdfButton/PaymentOrderPdfButton.d.ts +52 -0
- package/lib/cjs/components/PaymentOrderPdfButton/PaymentOrderPdfButton.js +75 -0
- package/lib/cjs/components/PaymentOrderPdfButton/index.d.ts +3 -0
- package/lib/cjs/components/PaymentOrderPdfButton/index.js +5 -0
- package/lib/cjs/components/PaymentOrders/PaymentOrders.js +1 -1
- package/lib/cjs/components/PaywallsConfigurator/PaywallsConfigurator.d.ts +2 -1
- package/lib/cjs/components/PaywallsConfigurator/PaywallsConfigurator.js +4 -4
- package/lib/cjs/components/PaywallsConfigurator/constants.d.ts +4 -4
- package/lib/cjs/components/PaywallsConfigurator/constants.js +5 -4
- package/lib/cjs/components/PdfPreview/PdfPreview.d.ts +9 -0
- package/lib/cjs/components/PdfPreview/PdfPreview.js +106 -0
- package/lib/cjs/components/PdfPreview/Skeleton.d.ts +5 -0
- package/lib/cjs/components/PdfPreview/Skeleton.js +39 -0
- package/lib/cjs/components/PdfPreview/index.d.ts +3 -0
- package/lib/cjs/components/PdfPreview/index.js +5 -0
- package/lib/cjs/components/PdfPreviewDialog/PdfPreviewDialog.d.ts +11 -0
- package/lib/cjs/components/PdfPreviewDialog/PdfPreviewDialog.js +42 -0
- package/lib/cjs/components/PdfPreviewDialog/index.d.ts +3 -0
- package/lib/cjs/components/PdfPreviewDialog/index.js +5 -0
- package/lib/cjs/index.d.ts +5 -1
- package/lib/cjs/index.js +9 -1
- package/lib/esm/components/BuyButton/BuyButton.d.ts +10 -0
- package/lib/esm/components/BuyButton/BuyButton.js +4 -3
- package/lib/esm/components/CourseDashboard/Student.js +9 -3
- package/lib/esm/components/CourseForm/CourseForm.js +16 -7
- package/lib/esm/components/EventForm/EventForm.js +18 -9
- package/lib/esm/components/EventForm/types.d.ts +3 -1
- package/lib/esm/components/EventHeader/EventHeader.js +3 -11
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +8 -1
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +17 -5
- package/lib/esm/components/GroupForm/GroupForm.js +14 -9
- package/lib/esm/components/GroupHeader/GroupHeader.js +4 -7
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +23 -3
- package/lib/esm/components/PaymentOrder/PaymentOrder.d.ts +7 -0
- package/lib/esm/components/PaymentOrder/PaymentOrder.js +78 -0
- package/lib/esm/components/PaymentOrder/Skeleton.d.ts +30 -0
- package/lib/esm/components/PaymentOrder/Skeleton.js +60 -0
- package/lib/esm/components/PaymentOrder/constants.d.ts +1 -0
- package/lib/esm/components/PaymentOrder/constants.js +1 -0
- package/lib/esm/components/PaymentOrder/index.d.ts +3 -0
- package/lib/esm/components/PaymentOrder/index.js +2 -0
- package/lib/esm/components/PaymentOrderPdfButton/PaymentOrderPdfButton.d.ts +52 -0
- package/lib/esm/components/PaymentOrderPdfButton/PaymentOrderPdfButton.js +72 -0
- package/lib/esm/components/PaymentOrderPdfButton/index.d.ts +3 -0
- package/lib/esm/components/PaymentOrderPdfButton/index.js +2 -0
- package/lib/esm/components/PaymentOrders/PaymentOrders.js +1 -1
- package/lib/esm/components/PaywallsConfigurator/PaywallsConfigurator.d.ts +2 -1
- package/lib/esm/components/PaywallsConfigurator/PaywallsConfigurator.js +4 -4
- package/lib/esm/components/PaywallsConfigurator/constants.d.ts +4 -4
- package/lib/esm/components/PaywallsConfigurator/constants.js +5 -4
- package/lib/esm/components/PdfPreview/PdfPreview.d.ts +9 -0
- package/lib/esm/components/PdfPreview/PdfPreview.js +102 -0
- package/lib/esm/components/PdfPreview/Skeleton.d.ts +5 -0
- package/lib/esm/components/PdfPreview/Skeleton.js +36 -0
- package/lib/esm/components/PdfPreview/index.d.ts +3 -0
- package/lib/esm/components/PdfPreview/index.js +2 -0
- package/lib/esm/components/PdfPreviewDialog/PdfPreviewDialog.d.ts +11 -0
- package/lib/esm/components/PdfPreviewDialog/PdfPreviewDialog.js +39 -0
- package/lib/esm/components/PdfPreviewDialog/index.d.ts +3 -0
- package/lib/esm/components/PdfPreviewDialog/index.js +2 -0
- package/lib/esm/index.d.ts +5 -1
- package/lib/esm/index.js +5 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +11 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SCPaymentProduct, SCContentType, SCPurchasableContent } from '@selfcommunity/types';
|
|
2
|
+
import { PaymentOrderPdfButtonProps } from '../PaymentOrderPdfButton';
|
|
2
3
|
export interface BuyButtonProps {
|
|
3
4
|
/**
|
|
4
5
|
* Overrides or extends the styles applied to the component.
|
|
@@ -27,6 +28,15 @@ export interface BuyButtonProps {
|
|
|
27
28
|
* @param joined
|
|
28
29
|
*/
|
|
29
30
|
onPurchase?: (contentType: SCContentType, id: number) => any;
|
|
31
|
+
/**
|
|
32
|
+
* show ticket button if content is already paid
|
|
33
|
+
*/
|
|
34
|
+
showTicket?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Props to spread to the PaymentOrderPdfButton component
|
|
37
|
+
* @default {}
|
|
38
|
+
*/
|
|
39
|
+
PaymentOrderPdfButtonComponentProps?: PaymentOrderPdfButtonProps;
|
|
30
40
|
/**
|
|
31
41
|
* Others properties
|
|
32
42
|
*/
|
|
@@ -15,6 +15,7 @@ const PaywallsDialog_1 = tslib_1.__importDefault(require("../PaywallsDialog"));
|
|
|
15
15
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
16
16
|
const utils_1 = require("@selfcommunity/utils");
|
|
17
17
|
const Paywalls_1 = tslib_1.__importDefault(require("../Paywalls"));
|
|
18
|
+
const PaymentOrderPdfButton_1 = tslib_1.__importDefault(require("../PaymentOrderPdfButton"));
|
|
18
19
|
const PREFIX = 'SCBuyButton';
|
|
19
20
|
const classes = {
|
|
20
21
|
requestRoot: `${PREFIX}-request-root`,
|
|
@@ -62,7 +63,7 @@ function BuyButton(inProps) {
|
|
|
62
63
|
props: inProps,
|
|
63
64
|
name: PREFIX
|
|
64
65
|
});
|
|
65
|
-
const { className, contentId, contentType, content, disabled, onPurchase } = props, rest = tslib_1.__rest(props, ["className", "contentId", "contentType", "content", "disabled", "onPurchase"]);
|
|
66
|
+
const { className, contentId, contentType, content, disabled, onPurchase, showTicket = false, PaymentOrderPdfButtonComponentProps = {} } = props, rest = tslib_1.__rest(props, ["className", "contentId", "contentType", "content", "disabled", "onPurchase", "showTicket", "PaymentOrderPdfButtonComponentProps"]);
|
|
66
67
|
// STATE
|
|
67
68
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
68
69
|
// CONTEXT
|
|
@@ -94,7 +95,7 @@ function BuyButton(inProps) {
|
|
|
94
95
|
* Price param is the new price selected
|
|
95
96
|
*/
|
|
96
97
|
const handleUpdatePaymentOrder = (0, react_1.useCallback)((price) => {
|
|
97
|
-
//
|
|
98
|
+
// update order/subscription when will be recurring payment
|
|
98
99
|
}, [paymentOrder, purchased]);
|
|
99
100
|
/**
|
|
100
101
|
* Get current status
|
|
@@ -185,7 +186,7 @@ function BuyButton(inProps) {
|
|
|
185
186
|
if (!contentId && !content) {
|
|
186
187
|
return null;
|
|
187
188
|
}
|
|
188
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: disabled ? (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.buyButton.disabled", defaultMessage: "ui.buyButton.disabled" }) : '' }, { 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, disabled: disabled }, 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: (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: paymentOrder ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paywallssDialog.title.purchased", defaultMessage: "ui.paymentProductsDialog.title.purchased" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paywallssDialog.title", defaultMessage: "ui.paymentProductsDialog.title" })) }) })), (0, jsx_runtime_1.jsx)(Paywalls_1.default, Object.assign({ contentType: contentType }, (content ? { content } : { contentId }), { prefetchedPaymentContentStatus: {
|
|
189
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: disabled ? (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.buyButton.disabled", defaultMessage: "ui.buyButton.disabled" }) : '' }, { 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, disabled: disabled || (!paymentOrder && purchased) }, rest, { children: !paymentOrder && purchased ? (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.buyButton.free", defaultMessage: "ui.buyButton.free" }) : btnLabel })) })), paymentOrder && showTicket && (0, jsx_runtime_1.jsx)(PaymentOrderPdfButton_1.default, Object.assign({}, PaymentOrderPdfButtonComponentProps, { paymentOrder: paymentOrder })), 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: (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: paymentOrder ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paywallssDialog.title.purchased", defaultMessage: "ui.paymentProductsDialog.title.purchased" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.paywallssDialog.title", defaultMessage: "ui.paymentProductsDialog.title" })) }) })), (0, jsx_runtime_1.jsx)(Paywalls_1.default, Object.assign({ contentType: contentType }, (content ? { content } : { contentId }), { prefetchedPaymentContentStatus: {
|
|
189
190
|
paywalls: products,
|
|
190
191
|
payment_order: paymentOrder
|
|
191
192
|
}, onUpdatePaymentOrder: handleUpdatePaymentOrder }))] }) }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(PaywallsDialog_1.default, { open: true, onClose: handleClose, PaywallsComponentProps: Object.assign(Object.assign({ contentType }, (content ? { content } : { contentId })), { prefetchedPaymentContentStatus: {
|
|
@@ -175,14 +175,20 @@ function Student(inProps) {
|
|
|
175
175
|
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(scCourse.join_status === types_1.SCCourseJoinStatusType.CREATOR || scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: BUTTON_MESSAGES.dashboard, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_DASHBOARD_ROUTE_NAME, scCourse), color: "inherit", variant: "outlined" })), (((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE || scCourse.privacy === types_1.SCCoursePrivacyType.SECRET) &&
|
|
176
176
|
(scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER || scCourse.join_status === types_1.SCCourseJoinStatusType.JOINED)) ||
|
|
177
177
|
(scCourse.privacy === types_1.SCCoursePrivacyType.OPEN && scCourse.join_status !== types_1.SCCourseJoinStatusType.CREATOR)) &&
|
|
178
|
-
(!isPaymentsEnabled ||
|
|
178
|
+
(!isPaymentsEnabled ||
|
|
179
|
+
!((_a = scCourse.paywalls) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
180
|
+
(isPaymentsEnabled &&
|
|
181
|
+
((_b = scCourse.paywalls) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
182
|
+
(scCourse.join_status === types_1.SCCourseJoinStatusType.JOINED || scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER))) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: scCourse.join_status === null
|
|
179
183
|
? BUTTON_MESSAGES.signUp
|
|
180
184
|
: scCourse.user_completion_rate === 0
|
|
181
185
|
? BUTTON_MESSAGES.start
|
|
182
186
|
: scCourse.user_completion_rate === 100
|
|
183
187
|
? BUTTON_MESSAGES.review
|
|
184
|
-
: BUTTON_MESSAGES.continue, to: scCourse.join_status !== null ? scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) : undefined, disabled: scCourse.join_status !== null ? getIsNextLessonLocked(scCourse) : undefined, color: scCourse.user_completion_rate === 100 ? 'inherit' : undefined, variant: scCourse.user_completion_rate === 100 ? 'outlined' : undefined, loading: scCourse.join_status === null ? loadingRequest : undefined, onClick: !scUserContext.user ? handleAnonymousAction : scCourse.join_status === null ? handleRequest : undefined })),
|
|
185
|
-
(scCourse.join_status === null || scCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED)
|
|
188
|
+
: BUTTON_MESSAGES.continue, to: scCourse.join_status !== null ? scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) : undefined, disabled: scCourse.join_status !== null ? getIsNextLessonLocked(scCourse) : undefined, color: scCourse.user_completion_rate === 100 ? 'inherit' : undefined, variant: scCourse.user_completion_rate === 100 ? 'outlined' : undefined, loading: scCourse.join_status === null ? loadingRequest : undefined, onClick: !scUserContext.user ? handleAnonymousAction : scCourse.join_status === null ? handleRequest : undefined })), scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
189
|
+
(scCourse.join_status === null || scCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED) ? ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: sentRequest ? BUTTON_MESSAGES.cancel : BUTTON_MESSAGES.request, color: "inherit", variant: "outlined", loading: loadingRequest, onClick: handleRequest })) : (isPaymentsEnabled &&
|
|
190
|
+
((_c = scCourse.paywalls) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
|
|
191
|
+
!(scCourse.join_status === types_1.SCCourseJoinStatusType.CREATOR || scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER) && ((0, jsx_runtime_1.jsx)(BuyButton_1.default, { contentType: types_1.SCContentType.COURSE, content: scCourse })))] })));
|
|
186
192
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
187
193
|
if (!scCourse) {
|
|
188
194
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
@@ -23,6 +23,7 @@ const CategoryAutocomplete_1 = tslib_1.__importDefault(require("../CategoryAutoc
|
|
|
23
23
|
const Edit_1 = tslib_1.__importDefault(require("./Edit"));
|
|
24
24
|
const Dialog_1 = tslib_1.__importDefault(require("./Dialog"));
|
|
25
25
|
const PaywallsConfigurator_1 = tslib_1.__importDefault(require("../PaywallsConfigurator"));
|
|
26
|
+
const constants_2 = require("../PaywallsConfigurator/constants");
|
|
26
27
|
const messages = (0, react_intl_1.defineMessages)({
|
|
27
28
|
name: {
|
|
28
29
|
id: 'ui.courseForm.name.placeholder',
|
|
@@ -103,7 +104,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
103
104
|
* @param inProps
|
|
104
105
|
*/
|
|
105
106
|
function CourseForm(inProps) {
|
|
106
|
-
var _a, _b, _c, _d;
|
|
107
|
+
var _a, _b, _c, _d, _e;
|
|
107
108
|
//PROPS
|
|
108
109
|
const props = (0, system_1.useThemeProps)({
|
|
109
110
|
props: inProps,
|
|
@@ -120,7 +121,8 @@ function CourseForm(inProps) {
|
|
|
120
121
|
description: course ? course.description : '',
|
|
121
122
|
categories: course ? course.categories : [],
|
|
122
123
|
privacy: course ? course.privacy : '',
|
|
123
|
-
|
|
124
|
+
productIds: ((_a = course === null || course === void 0 ? void 0 : course.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
|
|
125
|
+
contentAccessType: ((_b = course === null || course === void 0 ? void 0 : course.paywalls) === null || _b === void 0 ? void 0 : _b.length) ? constants_2.ContentAccessType.PAID : constants_2.ContentAccessType.FREE,
|
|
124
126
|
isSubmitting: false
|
|
125
127
|
};
|
|
126
128
|
// STATE
|
|
@@ -212,8 +214,8 @@ function CourseForm(inProps) {
|
|
|
212
214
|
formData.append(key, field.categories[key]);
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
|
-
if (field.
|
|
216
|
-
field.
|
|
217
|
+
if (field.productIds && field.contentAccessType === constants_2.ContentAccessType.PAID && (isStaff || (course && ((_a = course.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
|
|
218
|
+
field.productIds.forEach((p, i) => {
|
|
217
219
|
formData.append(`product_ids[${i}]`, p.toString());
|
|
218
220
|
});
|
|
219
221
|
}
|
|
@@ -258,12 +260,19 @@ function CourseForm(inProps) {
|
|
|
258
260
|
setError(error);
|
|
259
261
|
}
|
|
260
262
|
}, [setField, error]);
|
|
263
|
+
/**
|
|
264
|
+
* Handle change content access tyoe
|
|
265
|
+
* @param type
|
|
266
|
+
*/
|
|
267
|
+
const handleChangeContentAccessType = (type) => {
|
|
268
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { contentAccessType: type })));
|
|
269
|
+
};
|
|
261
270
|
/**
|
|
262
271
|
* Handle change payment products
|
|
263
272
|
* @param products
|
|
264
273
|
*/
|
|
265
274
|
const handleChangePaymentsProducts = (products) => {
|
|
266
|
-
setField((prev) => (Object.assign(Object.assign({}, prev), {
|
|
275
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
|
|
267
276
|
};
|
|
268
277
|
/**
|
|
269
278
|
* Handles for closing confirm dialog
|
|
@@ -277,8 +286,8 @@ function CourseForm(inProps) {
|
|
|
277
286
|
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: _step === Course_1.SCCourseFormStepType.GENERAL ? classes.stepOne : classes.stepTwo }, { children: [_step === Course_1.SCCourseFormStepType.GENERAL && ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: Object.values(types_1.SCCourseTypologyType).map((option, index) => ((0, jsx_runtime_1.jsx)(material_1.Card, Object.assign({ className: (0, classnames_1.default)(classes.card, { [classes.selected]: option === field.type }, { [classes.disabled]: !courseAdvancedEnabled && option !== types_1.SCCourseTypologyType.SELF }) }, { children: (0, jsx_runtime_1.jsx)(material_1.CardActionArea, Object.assign({ onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['type']: option }))) }, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ variant: "subtitle2", className: classes.cardTitle }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.courseForm.${option}.title`, defaultMessage: `ui.courseForm.${option}.title` }), !courseAdvancedEnabled && option !== types_1.SCCourseTypologyType.SELF && ((0, jsx_runtime_1.jsx)(material_1.Chip, { variant: "outlined", color: "warning", size: "small", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.comingSoon.chip", defaultMessage: "ui.courseForm.comingSoon.chip" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.courseForm.${option}.info`, defaultMessage: `ui.courseForm.${option}.info` }) }))] }) })) }), index))) })), _step === Course_1.SCCourseFormStepType.CUSTOMIZATION && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [course && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.contrastColor }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.edit.title.general", defaultMessage: "ui.courseForm.edit.title.general" }) }))), (0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: (0, classnames_1.default)(classes.form, _step === Course_1.SCCourseFormStepType.CUSTOMIZATION && course ? classes.stepCustomization : undefined) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadCourseCover_1.default, { isUploading: field.isSubmitting, onChange: handleChangeCover }) })), (0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
278
287
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Course_1.COURSE_TITLE_MAX_LENGTH - field.name.length }))
|
|
279
288
|
}, error: Boolean((!!course && !field.name) || field.name.length > Course_1.COURSE_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: !!course && !field.name ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : field.name.length > Course_1.COURSE_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.name.error.maxLength", defaultMessage: "ui.courseForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
280
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((
|
|
281
|
-
}, error: Boolean((!!field.privacy && !field.description) || ((
|
|
289
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) ? Course_1.COURSE_DESCRIPTION_MAX_LENGTH - field.description.length : Course_1.COURSE_DESCRIPTION_MAX_LENGTH })))
|
|
290
|
+
}, error: Boolean((!!field.privacy && !field.description) || ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Course_1.COURSE_DESCRIPTION_MAX_LENGTH), helperText: !!field.privacy && !field.description ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : (((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) > Course_1.COURSE_DESCRIPTION_MAX_LENGTH && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.description.error.maxLength", defaultMessage: "ui.courseForm.description.error.maxLength" }))) }), (0, jsx_runtime_1.jsx)(CategoryAutocomplete_1.default, { defaultValue: field.categories, TextFieldProps: { label: intl.formatMessage(Object.keys(field.categories).length ? messages.category : messages.categoryEmpty) }, multiple: true, onChange: handleOnChangeCategory }), course && (0, jsx_runtime_1.jsx)(Edit_1.default, { course: course, onPrivacyChange: (privacy) => setField((prev) => (Object.assign(Object.assign({}, prev), { ['privacy']: privacy }))) }), isPaymentsEnabled && isStaff && !hidePaywalls && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.paywallsConfiguratorWrap }, { children: (0, jsx_runtime_1.jsx)(PaywallsConfigurator_1.default, Object.assign({}, (course && { contentId: course.id }), { contentType: types_1.SCContentType.COURSE, onChangeContentAccessType: handleChangeContentAccessType, onChangePaymentProducts: handleChangePaymentsProducts })) })))] }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: (0, classnames_1.default)(classes.actions, _step === Course_1.SCCourseFormStepType.CUSTOMIZATION && course ? classes.stepCustomization : undefined) }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ size: "small", loading: field.isSubmitting, disabled: _step === Course_1.SCCourseFormStepType.GENERAL
|
|
282
291
|
? !field.type || Object.keys(error).length !== 0
|
|
283
292
|
: _step === Course_1.SCCourseFormStepType.CUSTOMIZATION &&
|
|
284
293
|
(!field.name ||
|
|
@@ -28,6 +28,7 @@ const utils_2 = require("./utils");
|
|
|
28
28
|
const constants_2 = require("../LiveStreamForm/constants");
|
|
29
29
|
const deafultCover_1 = tslib_1.__importDefault(require("../../assets/deafultCover"));
|
|
30
30
|
const PaywallsConfigurator_1 = tslib_1.__importDefault(require("../PaywallsConfigurator"));
|
|
31
|
+
const constants_3 = require("../PaywallsConfigurator/constants");
|
|
31
32
|
const messages = (0, react_intl_1.defineMessages)({
|
|
32
33
|
name: {
|
|
33
34
|
id: 'ui.eventForm.name.placeholder',
|
|
@@ -123,7 +124,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
123
124
|
* @param inProps
|
|
124
125
|
*/
|
|
125
126
|
function EventForm(inProps) {
|
|
126
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
127
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
127
128
|
//PROPS
|
|
128
129
|
const props = (0, system_1.useThemeProps)({
|
|
129
130
|
props: inProps,
|
|
@@ -164,7 +165,8 @@ function EventForm(inProps) {
|
|
|
164
165
|
link: (event === null || event === void 0 ? void 0 : event.link) || '',
|
|
165
166
|
liveStreamSettings: (event === null || event === void 0 ? void 0 : event.live_stream) ? event === null || event === void 0 ? void 0 : event.live_stream.settings : null,
|
|
166
167
|
recurring: (event === null || event === void 0 ? void 0 : event.recurring) || types_1.SCEventRecurrenceType.NEVER,
|
|
167
|
-
|
|
168
|
+
productIds: ((_b = event === null || event === void 0 ? void 0 : event.paywalls) === null || _b === void 0 ? void 0 : _b.map((p) => p.id)) || [],
|
|
169
|
+
contentAccessType: ((_c = event === null || event === void 0 ? void 0 : event.paywalls) === null || _c === void 0 ? void 0 : _c.length) ? constants_3.ContentAccessType.PAID : constants_3.ContentAccessType.FREE,
|
|
168
170
|
isPublic: (event === null || event === void 0 ? void 0 : event.privacy) ? event.privacy === types_1.SCEventPrivacyType.PUBLIC : true,
|
|
169
171
|
isSubmitting: false
|
|
170
172
|
};
|
|
@@ -179,7 +181,7 @@ function EventForm(inProps) {
|
|
|
179
181
|
scPreferences.features.includes(types_1.SCFeatureName.LIVE_STREAM) &&
|
|
180
182
|
react_core_1.SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED in scPreferences.preferences &&
|
|
181
183
|
scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
|
|
182
|
-
const canCreateLiveStream = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(
|
|
184
|
+
const canCreateLiveStream = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_d = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _d === void 0 ? void 0 : _d.permission]);
|
|
183
185
|
const privateEnabled = (0, react_1.useMemo)(() => scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED].value, [scPreferences.preferences]);
|
|
184
186
|
const visibilityEnabled = (0, react_1.useMemo)(() => scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED].value, [scPreferences.preferences]);
|
|
185
187
|
const disablePastStartTime = (0, react_1.useMemo)(() => field.startDate.getDate() === (0, utils_2.getNewDate)().getDate(), [field]);
|
|
@@ -262,8 +264,8 @@ function EventForm(inProps) {
|
|
|
262
264
|
if (visibilityEnabled) {
|
|
263
265
|
formData.append('visible', 'true');
|
|
264
266
|
}
|
|
265
|
-
if (field.
|
|
266
|
-
field.
|
|
267
|
+
if (field.productIds && field.contentAccessType === constants_3.ContentAccessType.PAID && (isStaff || (event && ((_a = event.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
|
|
268
|
+
field.productIds.forEach((p, i) => {
|
|
267
269
|
formData.append(`product_ids[${i}]`, p.toString());
|
|
268
270
|
});
|
|
269
271
|
}
|
|
@@ -332,12 +334,19 @@ function EventForm(inProps) {
|
|
|
332
334
|
}
|
|
333
335
|
setGenericError(null);
|
|
334
336
|
}, [error, setField, setGenericError]);
|
|
337
|
+
/**
|
|
338
|
+
* Handle change content access tyoe
|
|
339
|
+
* @param type
|
|
340
|
+
*/
|
|
341
|
+
const handleChangeContentAccessType = (type) => {
|
|
342
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { contentAccessType: type })));
|
|
343
|
+
};
|
|
335
344
|
/**
|
|
336
345
|
* Handle change payment products
|
|
337
346
|
* @param products
|
|
338
347
|
*/
|
|
339
348
|
const handleChangePaymentsProducts = (products) => {
|
|
340
|
-
setField((prev) => (Object.assign(Object.assign({}, prev), {
|
|
349
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
|
|
341
350
|
};
|
|
342
351
|
const shouldDisableDate = (0, react_1.useCallback)((date) => {
|
|
343
352
|
let disabled = false;
|
|
@@ -421,7 +430,7 @@ function EventForm(inProps) {
|
|
|
421
430
|
start_date: field.startDate,
|
|
422
431
|
location: field.location,
|
|
423
432
|
geolocation: field.geolocation,
|
|
424
|
-
live_stream: Object.assign(Object.assign({ title: field.name || `${intl.formatMessage(messages.name)}` }, (event && ((
|
|
433
|
+
live_stream: Object.assign(Object.assign({ title: field.name || `${intl.formatMessage(messages.name)}` }, (event && ((_e = event.live_stream) === null || _e === void 0 ? void 0 : _e.created_at) && { created_at: field.startDate })), { settings: field.liveStreamSettings })
|
|
425
434
|
}) }, EventAddressComponentProps)), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: (event === null || event === void 0 ? void 0 : event.privacy) === types_1.SCEventPrivacyType.PRIVATE }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
426
435
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
427
436
|
// @ts-ignores
|
|
@@ -431,8 +440,8 @@ function EventForm(inProps) {
|
|
|
431
440
|
// @ts-ignore
|
|
432
441
|
b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
|
|
433
442
|
} })) }))] }))), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
434
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((
|
|
435
|
-
}, error: Boolean(((
|
|
443
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_f = field.description) === null || _f === void 0 ? void 0 : _f.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH })))
|
|
444
|
+
}, error: Boolean(((_g = field.description) === null || _g === void 0 ? void 0 : _g.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_h = field.description) === null || _h === void 0 ? void 0 : _h.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), isPaymentsEnabled && isStaff && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.paywallsConfiguratorWrap }, { children: (0, jsx_runtime_1.jsx)(PaywallsConfigurator_1.default, Object.assign({}, (event && { contentId: event.id }), { contentType: types_1.SCContentType.EVENT, onChangeContentAccessType: handleChangeContentAccessType, onChangePaymentProducts: handleChangePaymentsProducts })) }))), genericError && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.genericError }, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
|
|
436
445
|
!field.startDate ||
|
|
437
446
|
!field.startTime ||
|
|
438
447
|
!field.endDate ||
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SCEventLocationType, SCEventRecurrenceType, SCLiveStreamSettingsType } from '@selfcommunity/types';
|
|
2
|
+
import { ContentAccessType } from '../PaywallsConfigurator/constants';
|
|
2
3
|
export declare type Place = {
|
|
3
4
|
description: string;
|
|
4
5
|
id?: string;
|
|
@@ -23,7 +24,8 @@ export declare type InitialFieldState = Geolocation & {
|
|
|
23
24
|
description: string;
|
|
24
25
|
isPublic: boolean;
|
|
25
26
|
isSubmitting: boolean;
|
|
26
|
-
|
|
27
|
+
productIds: number[];
|
|
28
|
+
contentAccessType: ContentAccessType;
|
|
27
29
|
};
|
|
28
30
|
export declare type FieldStateKeys = keyof InitialFieldState;
|
|
29
31
|
export declare type FieldStateValues = InitialFieldState[FieldStateKeys];
|
|
@@ -20,7 +20,6 @@ const EventSubscribeButton_1 = tslib_1.__importDefault(require("../EventSubscrib
|
|
|
20
20
|
const User_1 = tslib_1.__importDefault(require("../User"));
|
|
21
21
|
const constants_1 = require("./constants");
|
|
22
22
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
23
|
-
const BuyButton_1 = tslib_1.__importDefault(require("../BuyButton"));
|
|
24
23
|
const utils_1 = require("@selfcommunity/utils");
|
|
25
24
|
const classes = {
|
|
26
25
|
root: `${constants_1.PREFIX}-root`,
|
|
@@ -76,7 +75,6 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
76
75
|
* @param inProps
|
|
77
76
|
*/
|
|
78
77
|
function EventHeader(inProps) {
|
|
79
|
-
var _a;
|
|
80
78
|
// PROPS
|
|
81
79
|
const props = (0, system_1.useThemeProps)({
|
|
82
80
|
props: inProps,
|
|
@@ -96,8 +94,6 @@ function EventHeader(inProps) {
|
|
|
96
94
|
// CONST
|
|
97
95
|
const isEventAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && scEvent && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by]);
|
|
98
96
|
const isEventFinished = (0, react_1.useMemo)(() => (0, events_1.checkEventFinished)(scEvent), [scEvent]);
|
|
99
|
-
// PAYMENTS
|
|
100
|
-
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
101
97
|
/**
|
|
102
98
|
* Handles callback subscribe/unsubscribe event
|
|
103
99
|
*/
|
|
@@ -146,10 +142,6 @@ function EventHeader(inProps) {
|
|
|
146
142
|
month: 'long'
|
|
147
143
|
}),
|
|
148
144
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
149
|
-
} })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scEvent.privacy === types_1.SCEventPrivacyType.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.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.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.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { className: classes.planner, userId: scEvent.managed_by.id, secondary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isEventAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, disabled: isEventFinished }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [!isMobile && ((0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, onEditSuccess: setSCEvent, disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [
|
|
150
|
-
((_a = scEvent.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
151
|
-
(scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ||
|
|
152
|
-
(scEvent.privacy === types_1.SCEventPrivacyType.PRIVATE &&
|
|
153
|
-
(!scEvent.subscription_status || scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.REQUESTED))) ? ((0, jsx_runtime_1.jsx)(BuyButton_1.default, { contentType: types_1.SCContentType.EVENT, content: scEvent })) : ((0, jsx_runtime_1.jsx)(EventSubscribeButton_1.default, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished }))), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: setSCEvent }, EventActionsProps))] })) }) })] }))] })));
|
|
145
|
+
} })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scEvent.privacy === types_1.SCEventPrivacyType.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.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.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.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { className: classes.planner, userId: scEvent.managed_by.id, secondary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isEventAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, disabled: isEventFinished }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [!isMobile && ((0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, onEditSuccess: setSCEvent, disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(EventSubscribeButton_1.default, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: setSCEvent }, EventActionsProps))] })) }) })] }))] })));
|
|
154
146
|
}
|
|
155
147
|
exports.default = EventHeader;
|
|
@@ -86,7 +86,14 @@ function EventInfoWidget(inProps) {
|
|
|
86
86
|
types_1.SCEventSubscriptionStatusType.NOT_GOING
|
|
87
87
|
].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1) ||
|
|
88
88
|
(((_d = scEvent.paywalls) === null || _d === void 0 ? void 0 : _d.length) &&
|
|
89
|
-
((scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation) === types_1.SCEventLocationType.PERSON
|
|
89
|
+
(((scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation) === types_1.SCEventLocationType.PERSON &&
|
|
90
|
+
[
|
|
91
|
+
types_1.SCEventSubscriptionStatusType.INVITED,
|
|
92
|
+
types_1.SCEventSubscriptionStatusType.SUBSCRIBED,
|
|
93
|
+
types_1.SCEventSubscriptionStatusType.GOING,
|
|
94
|
+
types_1.SCEventSubscriptionStatusType.NOT_GOING
|
|
95
|
+
].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1) ||
|
|
96
|
+
(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) === types_1.SCEventSubscriptionStatusType.GOING)))));
|
|
90
97
|
}, [scEvent]);
|
|
91
98
|
const description = (0, react_1.useMemo)(() => (expanded ? scEvent === null || scEvent === void 0 ? void 0 : scEvent.description : getTruncatedText(scEvent === null || scEvent === void 0 ? void 0 : scEvent.description, 220)), [expanded, scEvent]);
|
|
92
99
|
/**
|
|
@@ -15,6 +15,7 @@ const react_1 = require("react");
|
|
|
15
15
|
const react_intl_1 = require("react-intl");
|
|
16
16
|
const Errors_1 = require("../../constants/Errors");
|
|
17
17
|
const PubSub_1 = require("../../constants/PubSub");
|
|
18
|
+
const BuyButton_1 = tslib_1.__importDefault(require("../BuyButton"));
|
|
18
19
|
const PREFIX = 'SCEventSubscribeButton';
|
|
19
20
|
const classes = {
|
|
20
21
|
requestRoot: `${PREFIX}-request-root`,
|
|
@@ -48,6 +49,10 @@ const SwipeableDrawerRoot = (0, styles_1.styled)(material_1.SwipeableDrawer, {
|
|
|
48
49
|
name: PREFIX,
|
|
49
50
|
slot: 'DrawerRoot'
|
|
50
51
|
})(() => ({}));
|
|
52
|
+
const BuyButtonRoot = (0, styles_1.styled)(BuyButton_1.default, {
|
|
53
|
+
name: PREFIX,
|
|
54
|
+
slot: 'BuyButtonRoot'
|
|
55
|
+
})(() => ({}));
|
|
51
56
|
const MenuRoot = (0, styles_1.styled)(material_1.Menu, {
|
|
52
57
|
name: PREFIX,
|
|
53
58
|
slot: 'MenuRoot'
|
|
@@ -75,7 +80,7 @@ const MenuRoot = (0, styles_1.styled)(material_1.Menu, {
|
|
|
75
80
|
* @param inProps
|
|
76
81
|
*/
|
|
77
82
|
function EventSubscribeButton(inProps) {
|
|
78
|
-
var _a;
|
|
83
|
+
var _a, _b;
|
|
79
84
|
// PROPS
|
|
80
85
|
const props = (0, system_1.useThemeProps)({
|
|
81
86
|
props: inProps,
|
|
@@ -93,6 +98,8 @@ function EventSubscribeButton(inProps) {
|
|
|
93
98
|
const scEventsManager = scUserContext.managers.events;
|
|
94
99
|
const theme = (0, material_1.useTheme)();
|
|
95
100
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
101
|
+
// PAYMENTS
|
|
102
|
+
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
96
103
|
// CONST
|
|
97
104
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
98
105
|
const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({
|
|
@@ -174,7 +181,12 @@ function EventSubscribeButton(inProps) {
|
|
|
174
181
|
if (!scEvent || (isEventAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) || (isEventAdmin && !(user === null || user === void 0 ? void 0 : user.id))) {
|
|
175
182
|
return null;
|
|
176
183
|
}
|
|
177
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children:
|
|
178
|
-
|
|
184
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isPaymentsEnabled &&
|
|
185
|
+
((_b = scEvent.paywalls) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
186
|
+
(scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ||
|
|
187
|
+
(scEvent.privacy === types_1.SCEventPrivacyType.PRIVATE &&
|
|
188
|
+
status &&
|
|
189
|
+
status !== types_1.SCEventSubscriptionStatusType.REQUESTED)) ? ((0, jsx_runtime_1.jsx)(BuyButtonRoot, { contentType: types_1.SCContentType.EVENT, content: scEvent, showTicket: true })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === types_1.SCEventPrivacyType.PRIVATE && (!status || status === types_1.SCEventSubscriptionStatusType.REQUESTED) ? ((0, jsx_runtime_1.jsx)(RequestRoot, Object.assign({ className: (0, classnames_1.default)(classes.requestRoot, className), variant: "outlined", size: "small", loading: scUserContext.user ? scEventsManager.isLoading(scEvent) : null, onClick: handleToggleAction }, rest, { children: getStatus }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SelectRoot, Object.assign({ className: (0, classnames_1.default)(classes.selectRoot, className, { [classes.going]: status && status === types_1.SCEventSubscriptionStatusType.GOING }, { [classes.notGoing]: status && status === types_1.SCEventSubscriptionStatusType.NOT_GOING }), onClick: handleOpen, endIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: open ? 'expand_less' : 'expand_more' }), startIcon: status &&
|
|
190
|
+
status !== types_1.SCEventSubscriptionStatusType.SUBSCRIBED && ((0, jsx_runtime_1.jsx)(material_1.Icon, { children: status === types_1.SCEventSubscriptionStatusType.GOING ? 'circle_checked' : 'circle_closed' })) }, rest, { children: getStatus })), 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: renderMenuItems() }))) : ((0, jsx_runtime_1.jsx)(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: true, onClose: handleClose }, { children: renderMenuItems() }))) }))] })) })) }));
|
|
179
191
|
}
|
|
180
192
|
exports.default = EventSubscribeButton;
|
|
@@ -23,6 +23,7 @@ const api_services_1 = require("@selfcommunity/api-services");
|
|
|
23
23
|
const utils_1 = require("@selfcommunity/utils");
|
|
24
24
|
const PubSub_1 = require("../../constants/PubSub");
|
|
25
25
|
const PaywallsConfigurator_1 = tslib_1.__importDefault(require("../PaywallsConfigurator"));
|
|
26
|
+
const constants_2 = require("../PaywallsConfigurator/constants");
|
|
26
27
|
const messages = (0, react_intl_1.defineMessages)({
|
|
27
28
|
name: {
|
|
28
29
|
id: 'ui.groupForm.name.placeholder',
|
|
@@ -95,7 +96,7 @@ const Root = (0, styles_1.styled)(BaseDialog_1.default, {
|
|
|
95
96
|
* @param inProps
|
|
96
97
|
*/
|
|
97
98
|
function GroupForm(inProps) {
|
|
98
|
-
var _a, _b, _c, _d, _e, _f;
|
|
99
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
99
100
|
//PROPS
|
|
100
101
|
const props = (0, system_1.useThemeProps)({
|
|
101
102
|
props: inProps,
|
|
@@ -113,7 +114,8 @@ function GroupForm(inProps) {
|
|
|
113
114
|
isVisible: group ? group.visible : true,
|
|
114
115
|
invitedUsers: null,
|
|
115
116
|
isSubmitting: false,
|
|
116
|
-
|
|
117
|
+
productIds: ((_a = group === null || group === void 0 ? void 0 : group.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
|
|
118
|
+
contentAccessType: ((_b = group === null || group === void 0 ? void 0 : group.paywalls) === null || _b === void 0 ? void 0 : _b.length) ? constants_2.ContentAccessType.PAID : constants_2.ContentAccessType.FREE
|
|
117
119
|
};
|
|
118
120
|
// CONTEXT
|
|
119
121
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
@@ -191,8 +193,8 @@ function GroupForm(inProps) {
|
|
|
191
193
|
if (field.emotionalImageOriginalFile) {
|
|
192
194
|
formData.append('emotional_image_original', field.emotionalImageOriginalFile);
|
|
193
195
|
}
|
|
194
|
-
if (field.
|
|
195
|
-
field.
|
|
196
|
+
if (field.productIds && field.contentAccessType === constants_2.ContentAccessType.PAID && (isStaff || (group && ((_a = group.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
|
|
197
|
+
field.productIds.forEach((p, i) => {
|
|
196
198
|
formData.append(`product_ids[${i}]`, p.toString());
|
|
197
199
|
});
|
|
198
200
|
}
|
|
@@ -232,8 +234,11 @@ function GroupForm(inProps) {
|
|
|
232
234
|
setError(error);
|
|
233
235
|
}
|
|
234
236
|
};
|
|
237
|
+
const handleChangeContentAccessType = (type) => {
|
|
238
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { contentAccessType: type })));
|
|
239
|
+
};
|
|
235
240
|
const handleChangePaymentsProducts = (products) => {
|
|
236
|
-
setField((prev) => (Object.assign(Object.assign({}, prev), {
|
|
241
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
|
|
237
242
|
};
|
|
238
243
|
const handleClose = (_event, reason) => {
|
|
239
244
|
if (reason === 'backdropClick' || reason === 'escapeKeyDown') {
|
|
@@ -249,9 +254,9 @@ function GroupForm(inProps) {
|
|
|
249
254
|
field.name.length > Group_1.GROUP_TITLE_MAX_LENGTH ||
|
|
250
255
|
field.name.description > Group_1.GROUP_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: group ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupForm.button.edit", defaultMessage: "ui.groupForm.button.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupForm.button.create", defaultMessage: "ui.groupForm.button.create" })) })) }, rest, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { 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: field.imageOriginal ? (0, jsx_runtime_1.jsx)("img", { src: field.imageOriginal, alt: "avatar" }) : (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "icon_image" }) }) })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ChangeGroupPicture_1.default, { isCreationMode: true, onChange: handleChangeAvatar }), (0, jsx_runtime_1.jsx)(ChangeGroupCover_1.default, { isCreationMode: true, onChange: handleChangeCover })] })] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.header, { [classes.error]: error.emotionalImageOriginalError || error.imageOriginalError }), align: "center" }, { children: error.emotionalImageOriginalError || error.imageOriginalError ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupForm.header.error", defaultMessage: "ui.groupForm.header.error" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupForm.header", defaultMessage: "ui.groupForm.header" })) }))] }), (0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
251
256
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Group_1.GROUP_TITLE_MAX_LENGTH - field.name.length }))
|
|
252
|
-
}, error: Boolean(((
|
|
253
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((
|
|
254
|
-
}, error: Boolean(((
|
|
257
|
+
}, error: Boolean(((_c = field === null || field === void 0 ? void 0 : field.name) === null || _c === void 0 ? void 0 : _c.length) > Group_1.GROUP_TITLE_MAX_LENGTH), helperText: ((_d = field === null || field === void 0 ? void 0 : field.name) === null || _d === void 0 ? void 0 : _d.length) > Group_1.GROUP_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupForm.name.error.maxLength", defaultMessage: "ui.groupForm.name.error.maxLength" })) : null }), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
258
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) ? Group_1.GROUP_DESCRIPTION_MAX_LENGTH - field.description.length : Group_1.GROUP_DESCRIPTION_MAX_LENGTH })))
|
|
259
|
+
}, error: Boolean(((_f = field.description) === null || _f === void 0 ? void 0 : _f.length) > Group_1.GROUP_DESCRIPTION_MAX_LENGTH), helperText: ((_g = field.description) === null || _g === void 0 ? void 0 : _g.length) > Group_1.GROUP_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupForm.description.error.maxLength", defaultMessage: "ui.groupForm.description.error.maxLength" })) : null }), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: {
|
|
255
260
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
256
261
|
// @ts-ignore
|
|
257
262
|
b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
|
|
@@ -279,6 +284,6 @@ function GroupForm(inProps) {
|
|
|
279
284
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
280
285
|
// @ts-ignore
|
|
281
286
|
b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
|
|
282
|
-
} })) }))] })) })))] })), isPaymentsEnabled && isStaff && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.paywallsConfiguratorWrap }, { children: (0, jsx_runtime_1.jsx)(PaywallsConfigurator_1.default, Object.assign({}, (group && { contentId: group.id }), { contentType: types_1.SCContentType.GROUP,
|
|
287
|
+
} })) }))] })) })))] })), isPaymentsEnabled && isStaff && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.paywallsConfiguratorWrap }, { children: (0, jsx_runtime_1.jsx)(PaywallsConfigurator_1.default, Object.assign({}, (group && { contentId: group.id }), { contentType: types_1.SCContentType.GROUP, onChangeContentAccessType: handleChangeContentAccessType, onChangePaymentProducts: handleChangePaymentsProducts })) }))), !group && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.inviteSection }, { children: (0, jsx_runtime_1.jsx)(GroupInviteButton_1.default, { handleInvitations: handleInviteSection }) }))] }))] }) })));
|
|
283
288
|
}
|
|
284
289
|
exports.default = GroupForm;
|
|
@@ -22,7 +22,6 @@ 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"));
|
|
26
25
|
const classes = {
|
|
27
26
|
root: `${constants_1.PREFIX}-root`,
|
|
28
27
|
cover: `${constants_1.PREFIX}-cover`,
|
|
@@ -73,7 +72,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
73
72
|
* @param inProps
|
|
74
73
|
*/
|
|
75
74
|
function GroupHeader(inProps) {
|
|
76
|
-
var _a
|
|
75
|
+
var _a;
|
|
77
76
|
// PROPS
|
|
78
77
|
const props = (0, system_1.useThemeProps)({
|
|
79
78
|
props: inProps,
|
|
@@ -90,8 +89,6 @@ function GroupHeader(inProps) {
|
|
|
90
89
|
const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
91
90
|
const theme = (0, material_1.useTheme)();
|
|
92
91
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
93
|
-
// PAYMENTS
|
|
94
|
-
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
95
92
|
// REFS
|
|
96
93
|
const updatesSubscription = (0, react_1.useRef)(null);
|
|
97
94
|
// CONST
|
|
@@ -156,6 +153,6 @@ function GroupHeader(inProps) {
|
|
|
156
153
|
: { background: `url('${scPreferences.preferences[react_core_1.SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
|
|
157
154
|
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) ||
|
|
158
155
|
scGroup.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED ||
|
|
159
|
-
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))] })) :
|
|
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)))] }))] })));
|
|
160
157
|
}
|
|
161
158
|
exports.default = GroupHeader;
|