@selfcommunity/react-ui 0.7.50-events.53 → 0.7.50-events.54
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.
|
@@ -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;
|
|
@@ -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
|
}
|