@selfcommunity/react-ui 0.7.50-events.53 → 0.7.50-events.55
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/EventSubscribeButton/EventSubscribeButton.js +7 -3
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +3 -2
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +7 -3
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +4 -3
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -81,7 +81,7 @@ function EventSubscribeButton(inProps) {
|
|
|
81
81
|
});
|
|
82
82
|
const { className, eventId, event, user, onSubscribe } = props, rest = tslib_1.__rest(props, ["className", "eventId", "event", "user", "onSubscribe"]);
|
|
83
83
|
// STATE
|
|
84
|
-
const [status, setStatus] = (0, react_1.useState)(
|
|
84
|
+
const [status, setStatus] = (0, react_1.useState)(undefined);
|
|
85
85
|
const [anchorEl, setAnchorEl] = react_1.default.useState(null);
|
|
86
86
|
const open = Boolean(anchorEl);
|
|
87
87
|
// CONTEXT
|
|
@@ -180,11 +180,15 @@ function EventSubscribeButton(inProps) {
|
|
|
180
180
|
}
|
|
181
181
|
return _status;
|
|
182
182
|
}, [status, scEvent]);
|
|
183
|
-
if (!scEvent ||
|
|
183
|
+
if (!scEvent ||
|
|
184
|
+
status === undefined ||
|
|
185
|
+
(isEventAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) ||
|
|
186
|
+
(isEventAdmin && !(user === null || user === void 0 ? void 0 : user.id)) ||
|
|
187
|
+
scEventsManager.isLoading(scEvent)) {
|
|
184
188
|
return null;
|
|
185
189
|
}
|
|
186
190
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== types_1.SCEventPrivacyType.PRIVATE ||
|
|
187
|
-
((scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy)
|
|
191
|
+
((scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === types_1.SCEventPrivacyType.PRIVATE && status && status !== types_1.SCEventSubscriptionStatusType.REQUESTED) ? ((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 &&
|
|
188
192
|
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 })), isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: open, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: renderMenuItems() }))) : ((0, jsx_runtime_1.jsx)(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: open, onClose: handleClose }, { children: renderMenuItems() })))] })) : ((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, disabled: status === types_1.SCEventSubscriptionStatusType.REQUESTED, onClick: handleToggleAction }, rest, { children: getStatus }))) }));
|
|
189
193
|
}
|
|
190
194
|
exports.default = EventSubscribeButton;
|
|
@@ -116,13 +116,14 @@ function Share(props) {
|
|
|
116
116
|
if (shareMedias.length) {
|
|
117
117
|
sharedObjectId = shareMedias[0].embed.metadata.id;
|
|
118
118
|
}
|
|
119
|
+
const isMediaEvent = obj.medias.some((media) => media.embed.embed_type === Media_1.MEDIA_EMBED_SC_SHARED_EVENT);
|
|
119
120
|
return api_services_1.http
|
|
120
121
|
.request({
|
|
121
122
|
url: api_services_1.Endpoints.ComposerMediaCreate.url(),
|
|
122
123
|
method: api_services_1.Endpoints.ComposerMediaCreate.method,
|
|
123
124
|
data: {
|
|
124
125
|
type: Media_1.MEDIA_TYPE_SHARE,
|
|
125
|
-
shared_object: sharedObjectId
|
|
126
|
+
[isMediaEvent ? 'event_object' : 'shared_object']: sharedObjectId
|
|
126
127
|
}
|
|
127
128
|
})
|
|
128
129
|
.then((res) => {
|
|
@@ -133,7 +134,7 @@ function Share(props) {
|
|
|
133
134
|
});
|
|
134
135
|
}, [obj]);
|
|
135
136
|
/**
|
|
136
|
-
* Performs the
|
|
137
|
+
* Performs the contribution sharing
|
|
137
138
|
*/
|
|
138
139
|
function share(inCategories) {
|
|
139
140
|
if (!scUserContext.user) {
|
|
@@ -79,7 +79,7 @@ export default function EventSubscribeButton(inProps) {
|
|
|
79
79
|
});
|
|
80
80
|
const { className, eventId, event, user, onSubscribe } = props, rest = __rest(props, ["className", "eventId", "event", "user", "onSubscribe"]);
|
|
81
81
|
// STATE
|
|
82
|
-
const [status, setStatus] = useState(
|
|
82
|
+
const [status, setStatus] = useState(undefined);
|
|
83
83
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
84
84
|
const open = Boolean(anchorEl);
|
|
85
85
|
// CONTEXT
|
|
@@ -178,10 +178,14 @@ export default function EventSubscribeButton(inProps) {
|
|
|
178
178
|
}
|
|
179
179
|
return _status;
|
|
180
180
|
}, [status, scEvent]);
|
|
181
|
-
if (!scEvent ||
|
|
181
|
+
if (!scEvent ||
|
|
182
|
+
status === undefined ||
|
|
183
|
+
(isEventAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) ||
|
|
184
|
+
(isEventAdmin && !(user === null || user === void 0 ? void 0 : user.id)) ||
|
|
185
|
+
scEventsManager.isLoading(scEvent)) {
|
|
182
186
|
return null;
|
|
183
187
|
}
|
|
184
188
|
return (_jsx(_Fragment, { children: (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== SCEventPrivacyType.PRIVATE ||
|
|
185
|
-
((scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy)
|
|
189
|
+
((scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PRIVATE && status && status !== SCEventSubscriptionStatusType.REQUESTED) ? (_jsxs(_Fragment, { children: [_jsx(SelectRoot, Object.assign({ className: classNames(classes.selectRoot, className, { [classes.going]: status && status === SCEventSubscriptionStatusType.GOING }, { [classes.notGoing]: status && status === SCEventSubscriptionStatusType.NOT_GOING }), onClick: handleOpen, endIcon: _jsx(Icon, { children: open ? 'expand_less' : 'expand_more' }), startIcon: status &&
|
|
186
190
|
status !== SCEventSubscriptionStatusType.SUBSCRIBED && (_jsx(Icon, { children: status === SCEventSubscriptionStatusType.GOING ? 'circle_checked' : 'circle_closed' })) }, rest, { children: getStatus })), isMobile ? (_jsx(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: open, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: renderMenuItems() }))) : (_jsx(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: open, onClose: handleClose }, { children: renderMenuItems() })))] })) : (_jsx(RequestRoot, Object.assign({ className: classNames(classes.requestRoot, className), variant: "outlined", size: "small", loading: scUserContext.user ? scEventsManager.isLoading(scEvent) : null, disabled: status === SCEventSubscriptionStatusType.REQUESTED, onClick: handleToggleAction }, rest, { children: getStatus }))) }));
|
|
187
191
|
}
|
|
@@ -9,7 +9,7 @@ import { styled } from '@mui/material/styles';
|
|
|
9
9
|
import { Box, Button, Divider, ListItemText, Menu, SwipeableDrawer, Tooltip, useMediaQuery, useTheme } from '@mui/material';
|
|
10
10
|
import MenuItem from '@mui/material/MenuItem';
|
|
11
11
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
12
|
-
import { MEDIA_TYPE_SHARE } from '../../../../constants/Media';
|
|
12
|
+
import { MEDIA_EMBED_SC_SHARED_EVENT, MEDIA_TYPE_SHARE } from '../../../../constants/Media';
|
|
13
13
|
import { SCOPE_SC_UI } from '../../../../constants/Errors';
|
|
14
14
|
import classNames from 'classnames';
|
|
15
15
|
import { useSnackbar } from 'notistack';
|
|
@@ -114,13 +114,14 @@ export default function Share(props) {
|
|
|
114
114
|
if (shareMedias.length) {
|
|
115
115
|
sharedObjectId = shareMedias[0].embed.metadata.id;
|
|
116
116
|
}
|
|
117
|
+
const isMediaEvent = obj.medias.some((media) => media.embed.embed_type === MEDIA_EMBED_SC_SHARED_EVENT);
|
|
117
118
|
return http
|
|
118
119
|
.request({
|
|
119
120
|
url: Endpoints.ComposerMediaCreate.url(),
|
|
120
121
|
method: Endpoints.ComposerMediaCreate.method,
|
|
121
122
|
data: {
|
|
122
123
|
type: MEDIA_TYPE_SHARE,
|
|
123
|
-
shared_object: sharedObjectId
|
|
124
|
+
[isMediaEvent ? 'event_object' : 'shared_object']: sharedObjectId
|
|
124
125
|
}
|
|
125
126
|
})
|
|
126
127
|
.then((res) => {
|
|
@@ -131,7 +132,7 @@ export default function Share(props) {
|
|
|
131
132
|
});
|
|
132
133
|
}, [obj]);
|
|
133
134
|
/**
|
|
134
|
-
* Performs the
|
|
135
|
+
* Performs the contribution sharing
|
|
135
136
|
*/
|
|
136
137
|
function share(inCategories) {
|
|
137
138
|
if (!scUserContext.user) {
|