@selfcommunity/react-ui 0.7.50-events.49 → 0.7.50-events.50
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/EventHeader/EventHeader.js +7 -1
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +25 -26
- package/lib/esm/components/EventHeader/EventHeader.js +7 -1
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +25 -26
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -108,6 +108,12 @@ function EventHeader(inProps) {
|
|
|
108
108
|
setSCEvent(_event);
|
|
109
109
|
}
|
|
110
110
|
}, [scEvent, setSCEvent]);
|
|
111
|
+
/**
|
|
112
|
+
* Handles callback subscribe/unsubscribe event
|
|
113
|
+
*/
|
|
114
|
+
const handleSubscribe = (event, status) => {
|
|
115
|
+
setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
|
|
116
|
+
};
|
|
111
117
|
/**
|
|
112
118
|
* On mount, subscribe to receive events updates (only edit)
|
|
113
119
|
*/
|
|
@@ -161,6 +167,6 @@ function EventHeader(inProps) {
|
|
|
161
167
|
month: 'long'
|
|
162
168
|
}),
|
|
163
169
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
164
|
-
} })) })), (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.live", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { userId: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.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, eventId: scEvent.id }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(EventSubscribeButton_1.default, Object.assign({ event: scEvent }, EventSubscribeButtonProps)), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })) }) })] }))] })));
|
|
170
|
+
} })) })), (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.live", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { userId: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.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, eventId: scEvent.id }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })] }))) : ((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)), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })) }) })] }))] })));
|
|
165
171
|
}
|
|
166
172
|
exports.default = EventHeader;
|
|
@@ -113,43 +113,42 @@ function EventSubscribeButton(inProps) {
|
|
|
113
113
|
if (authUserId) {
|
|
114
114
|
setStatus(scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus(scEvent));
|
|
115
115
|
}
|
|
116
|
-
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent]);
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent, status]);
|
|
117
|
+
const toggleEventAttendance = (eventStatus) => {
|
|
118
|
+
const isGoing = eventStatus === types_1.SCEventSubscriptionStatusType.GOING || !scEvent.subscription_status;
|
|
119
|
+
const toggleAction = isGoing
|
|
120
|
+
? scEventsManager.toggleEventAttendance(scEvent, user ? user === null || user === void 0 ? void 0 : user.id : null)
|
|
121
|
+
: scEventsManager.toggleEventNonattendance(scEvent);
|
|
122
|
+
toggleAction
|
|
120
123
|
.then(() => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
? types_1.SCEventSubscriptionStatusType.SUBSCRIBED
|
|
138
|
-
: types_1.SCEventSubscriptionStatusType.NOT_GOING;
|
|
139
|
-
onSubscribe && onSubscribe(scEvent, _status);
|
|
124
|
+
let s;
|
|
125
|
+
if (isGoing) {
|
|
126
|
+
s =
|
|
127
|
+
scEvent.privacy === types_1.SCEventPrivacyType.PRIVATE && scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.INVITED
|
|
128
|
+
? types_1.SCEventSubscriptionStatusType.REQUESTED
|
|
129
|
+
: scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.GOING
|
|
130
|
+
? types_1.SCEventSubscriptionStatusType.SUBSCRIBED
|
|
131
|
+
: types_1.SCEventSubscriptionStatusType.GOING;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
s =
|
|
135
|
+
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.NOT_GOING
|
|
136
|
+
? types_1.SCEventSubscriptionStatusType.SUBSCRIBED
|
|
137
|
+
: types_1.SCEventSubscriptionStatusType.NOT_GOING;
|
|
138
|
+
}
|
|
139
|
+
onSubscribe && onSubscribe(scEvent, s);
|
|
140
140
|
})
|
|
141
141
|
.catch((e) => {
|
|
142
142
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
143
143
|
});
|
|
144
144
|
};
|
|
145
145
|
const handleToggleAction = (event) => {
|
|
146
|
-
const _status = event.target.value;
|
|
147
146
|
setAnchorEl(null);
|
|
148
147
|
if (!scUserContext.user) {
|
|
149
148
|
scContext.settings.handleAnonymousAction();
|
|
150
149
|
}
|
|
151
150
|
else {
|
|
152
|
-
(
|
|
151
|
+
toggleEventAttendance(event.target.value);
|
|
153
152
|
}
|
|
154
153
|
};
|
|
155
154
|
function renderMenuItems() {
|
|
@@ -186,6 +185,6 @@ function EventSubscribeButton(inProps) {
|
|
|
186
185
|
}
|
|
187
186
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== types_1.SCEventPrivacyType.PRIVATE ||
|
|
188
187
|
((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 &&
|
|
189
|
-
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 }, rest, { children: getStatus }))) }));
|
|
188
|
+
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 }))) }));
|
|
190
189
|
}
|
|
191
190
|
exports.default = EventSubscribeButton;
|
|
@@ -106,6 +106,12 @@ export default function EventHeader(inProps) {
|
|
|
106
106
|
setSCEvent(_event);
|
|
107
107
|
}
|
|
108
108
|
}, [scEvent, setSCEvent]);
|
|
109
|
+
/**
|
|
110
|
+
* Handles callback subscribe/unsubscribe event
|
|
111
|
+
*/
|
|
112
|
+
const handleSubscribe = (event, status) => {
|
|
113
|
+
setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
|
|
114
|
+
};
|
|
109
115
|
/**
|
|
110
116
|
* On mount, subscribe to receive events updates (only edit)
|
|
111
117
|
*/
|
|
@@ -159,5 +165,5 @@ export default function EventHeader(inProps) {
|
|
|
159
165
|
month: 'long'
|
|
160
166
|
}),
|
|
161
167
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
162
|
-
} })) })), _jsx(Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), _jsxs(Box, Object.assign({ className: classes.visibility }, { children: [_jsx(_Fragment, { children: scEvent.privacy === SCEventPrivacyType.PUBLIC ? (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), _jsx(Bullet, {}), _jsx(Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === SCEventLocationType.PERSON ? (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.online" })) }))] })), _jsx(User, { userId: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.id, secondary: _jsx(FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: _jsx(_Fragment, { children: isEventAdmin ? (_jsxs(Box, Object.assign({ className: classes.multiActions }, { children: [_jsx(EventInviteButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id }), _jsxs(Box, { children: [_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }), _jsx(EventActionsMenu, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({ event: scEvent }, EventSubscribeButtonProps)), _jsx(EventActionsMenu, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })) }) })] }))] })));
|
|
168
|
+
} })) })), _jsx(Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), _jsxs(Box, Object.assign({ className: classes.visibility }, { children: [_jsx(_Fragment, { children: scEvent.privacy === SCEventPrivacyType.PUBLIC ? (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), _jsx(Bullet, {}), _jsx(Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === SCEventLocationType.PERSON ? (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.online" })) }))] })), _jsx(User, { userId: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.id, secondary: _jsx(FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: _jsx(_Fragment, { children: isEventAdmin ? (_jsxs(Box, Object.assign({ className: classes.multiActions }, { children: [_jsx(EventInviteButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id }), _jsxs(Box, { children: [_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }), _jsx(EventActionsMenu, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps)), _jsx(EventActionsMenu, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })) }) })] }))] })));
|
|
163
169
|
}
|
|
@@ -111,43 +111,42 @@ export default function EventSubscribeButton(inProps) {
|
|
|
111
111
|
if (authUserId) {
|
|
112
112
|
setStatus(scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus(scEvent));
|
|
113
113
|
}
|
|
114
|
-
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent]);
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent, status]);
|
|
115
|
+
const toggleEventAttendance = (eventStatus) => {
|
|
116
|
+
const isGoing = eventStatus === SCEventSubscriptionStatusType.GOING || !scEvent.subscription_status;
|
|
117
|
+
const toggleAction = isGoing
|
|
118
|
+
? scEventsManager.toggleEventAttendance(scEvent, user ? user === null || user === void 0 ? void 0 : user.id : null)
|
|
119
|
+
: scEventsManager.toggleEventNonattendance(scEvent);
|
|
120
|
+
toggleAction
|
|
118
121
|
.then(() => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
? SCEventSubscriptionStatusType.SUBSCRIBED
|
|
136
|
-
: SCEventSubscriptionStatusType.NOT_GOING;
|
|
137
|
-
onSubscribe && onSubscribe(scEvent, _status);
|
|
122
|
+
let s;
|
|
123
|
+
if (isGoing) {
|
|
124
|
+
s =
|
|
125
|
+
scEvent.privacy === SCEventPrivacyType.PRIVATE && scEvent.subscription_status !== SCEventSubscriptionStatusType.INVITED
|
|
126
|
+
? SCEventSubscriptionStatusType.REQUESTED
|
|
127
|
+
: scEvent.subscription_status === SCEventSubscriptionStatusType.GOING
|
|
128
|
+
? SCEventSubscriptionStatusType.SUBSCRIBED
|
|
129
|
+
: SCEventSubscriptionStatusType.GOING;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
s =
|
|
133
|
+
scEvent.subscription_status === SCEventSubscriptionStatusType.NOT_GOING
|
|
134
|
+
? SCEventSubscriptionStatusType.SUBSCRIBED
|
|
135
|
+
: SCEventSubscriptionStatusType.NOT_GOING;
|
|
136
|
+
}
|
|
137
|
+
onSubscribe && onSubscribe(scEvent, s);
|
|
138
138
|
})
|
|
139
139
|
.catch((e) => {
|
|
140
140
|
Logger.error(SCOPE_SC_UI, e);
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
143
|
const handleToggleAction = (event) => {
|
|
144
|
-
const _status = event.target.value;
|
|
145
144
|
setAnchorEl(null);
|
|
146
145
|
if (!scUserContext.user) {
|
|
147
146
|
scContext.settings.handleAnonymousAction();
|
|
148
147
|
}
|
|
149
148
|
else {
|
|
150
|
-
(
|
|
149
|
+
toggleEventAttendance(event.target.value);
|
|
151
150
|
}
|
|
152
151
|
};
|
|
153
152
|
function renderMenuItems() {
|
|
@@ -184,5 +183,5 @@ export default function EventSubscribeButton(inProps) {
|
|
|
184
183
|
}
|
|
185
184
|
return (_jsx(_Fragment, { children: (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== SCEventPrivacyType.PRIVATE ||
|
|
186
185
|
((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 &&
|
|
187
|
-
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 }, rest, { children: getStatus }))) }));
|
|
186
|
+
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 }))) }));
|
|
188
187
|
}
|