@selfcommunity/react-ui 0.9.0-alpha.14 → 0.9.0-alpha.15
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 +1 -32
- package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +1 -1
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +7 -7
- package/lib/esm/components/EventHeader/EventHeader.js +2 -33
- package/lib/esm/components/EventMembersWidget/TabContentComponent.js +1 -1
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +7 -7
- package/lib/umd/react-ui.js +1 -1
- package/package.json +3 -3
|
@@ -8,10 +8,8 @@ const system_1 = require("@mui/system");
|
|
|
8
8
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
9
|
const types_1 = require("@selfcommunity/types");
|
|
10
10
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
|
-
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
12
11
|
const react_1 = require("react");
|
|
13
12
|
const react_intl_1 = require("react-intl");
|
|
14
|
-
const PubSub_1 = require("../../constants/PubSub");
|
|
15
13
|
const Bullet_1 = tslib_1.__importDefault(require("../../shared/Bullet"));
|
|
16
14
|
const Calendar_1 = tslib_1.__importDefault(require("../../shared/Calendar"));
|
|
17
15
|
const EventActionsMenu_1 = tslib_1.__importDefault(require("../../shared/EventActionsMenu"));
|
|
@@ -92,44 +90,15 @@ function EventHeader(inProps) {
|
|
|
92
90
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
93
91
|
// INTL
|
|
94
92
|
const intl = (0, react_intl_1.useIntl)();
|
|
95
|
-
// REFS
|
|
96
|
-
const updatesSubscription = (0, react_1.useRef)(null);
|
|
97
93
|
// CONST
|
|
98
94
|
const isEventAdmin = (0, react_1.useMemo)(() => scUserContext.user && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id]);
|
|
99
95
|
const isEventFinished = (0, react_1.useMemo)(() => (0, events_1.checkEventFinished)(scEvent), [scEvent]);
|
|
100
|
-
/**
|
|
101
|
-
* Subscriber for pubsub callback
|
|
102
|
-
*/
|
|
103
|
-
const onChangeEventMembersHandler = (0, react_1.useCallback)((msg, data) => {
|
|
104
|
-
var _a;
|
|
105
|
-
if (data && ((_a = data === null || data === void 0 ? void 0 : data.event) === null || _a === void 0 ? void 0 : _a.id) === (scEvent === null || scEvent === void 0 ? void 0 : scEvent.id)) {
|
|
106
|
-
let _event = Object.assign({}, scEvent);
|
|
107
|
-
if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.ADD_MEMBER}`) {
|
|
108
|
-
_event.subscribers_counter = _event.subscribers_counter + 1;
|
|
109
|
-
}
|
|
110
|
-
else if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.REMOVE_MEMBER}`) {
|
|
111
|
-
_event.subscribers_counter = Math.max(_event.subscribers_counter - 1, 0);
|
|
112
|
-
}
|
|
113
|
-
setSCEvent(_event);
|
|
114
|
-
}
|
|
115
|
-
}, [scEvent, setSCEvent]);
|
|
116
96
|
/**
|
|
117
97
|
* Handles callback subscribe/unsubscribe event
|
|
118
98
|
*/
|
|
119
99
|
const handleSubscribe = (_event, status) => {
|
|
120
100
|
setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
|
|
121
101
|
};
|
|
122
|
-
/**
|
|
123
|
-
* On mount, subscribe to receive events updates (only edit)
|
|
124
|
-
*/
|
|
125
|
-
(0, react_1.useEffect)(() => {
|
|
126
|
-
if (scEvent) {
|
|
127
|
-
updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.MEMBERS}`, onChangeEventMembersHandler);
|
|
128
|
-
}
|
|
129
|
-
return () => {
|
|
130
|
-
updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
|
|
131
|
-
};
|
|
132
|
-
}, [scEvent]);
|
|
133
102
|
// RENDER
|
|
134
103
|
if (!scEvent) {
|
|
135
104
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
@@ -172,6 +141,6 @@ function EventHeader(inProps) {
|
|
|
172
141
|
month: 'long'
|
|
173
142
|
}),
|
|
174
143
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
175
|
-
} })) })), (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,
|
|
144
|
+
} })) })), (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: (data) => setSCEvent(data), 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: (data) => setSCEvent(data) }, EventActionsProps))] })) }) })] }))] })));
|
|
176
145
|
}
|
|
177
146
|
exports.default = EventHeader;
|
|
@@ -47,7 +47,7 @@ function TabContentComponent(props) {
|
|
|
47
47
|
// EFFECTS
|
|
48
48
|
(0, react_1.useEffect)(() => {
|
|
49
49
|
updatesInvited.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
|
|
50
|
-
updatesParticipants.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.
|
|
50
|
+
updatesParticipants.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.MEMBERS}`, handleToggleMember);
|
|
51
51
|
return () => {
|
|
52
52
|
updatesInvited.current && pubsub_js_1.default.unsubscribe(updatesInvited.current);
|
|
53
53
|
updatesParticipants.current && pubsub_js_1.default.unsubscribe(updatesParticipants.current);
|
|
@@ -95,7 +95,7 @@ function EventSubscribeButton(inProps) {
|
|
|
95
95
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
96
96
|
// CONST
|
|
97
97
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
98
|
-
const { scEvent } = (0, react_core_1.useSCFetchEvent)({
|
|
98
|
+
const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({
|
|
99
99
|
id: eventId,
|
|
100
100
|
event,
|
|
101
101
|
cacheStrategy: authUserId ? utils_1.CacheStrategies.CACHE_FIRST : utils_1.CacheStrategies.STALE_WHILE_REVALIDATE
|
|
@@ -122,14 +122,14 @@ function EventSubscribeButton(inProps) {
|
|
|
122
122
|
const isGoing = eventStatus === types_1.SCEventSubscriptionStatusType.GOING ||
|
|
123
123
|
!(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) ||
|
|
124
124
|
(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) === types_1.SCEventSubscriptionStatusType.INVITED;
|
|
125
|
-
const toggleAction = isGoing
|
|
126
|
-
? scEventsManager.toggleEventAttendance(scEvent, (user === null || user === void 0 ? void 0 : user.id) || null)
|
|
127
|
-
: scEventsManager.toggleEventNonattendance(scEvent);
|
|
125
|
+
const toggleAction = isGoing ? scEventsManager.toggleEventAttendance(scEvent) : scEventsManager.toggleEventNonattendance(scEvent);
|
|
128
126
|
toggleAction
|
|
129
127
|
.then(() => {
|
|
130
|
-
onSubscribe
|
|
128
|
+
onSubscribe
|
|
129
|
+
? onSubscribe(scEvent, (0, react_core_1.getEventStatus)(scEvent, isGoing))
|
|
130
|
+
: setSCEvent(Object.assign({}, scEvent, { subscription_status: (0, react_core_1.getEventStatus)(scEvent, isGoing) }));
|
|
131
131
|
setLoading(false);
|
|
132
|
-
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.
|
|
132
|
+
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.MEMBERS}`);
|
|
133
133
|
})
|
|
134
134
|
.catch((e) => {
|
|
135
135
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
@@ -145,7 +145,7 @@ function EventSubscribeButton(inProps) {
|
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
function renderMenuItems() {
|
|
148
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: options.map((option) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ className: classes.item, disabled: loading }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { label: option.label, control: loading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color:
|
|
148
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: options.map((option) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ className: classes.item, disabled: loading }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { label: option.label, control: loading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "primary", size: 20 })) : ((0, jsx_runtime_1.jsx)(material_1.Checkbox, { size: "small", checked: status === option.value, value: option.value, onChange: handleToggleAction, name: `${option.value}-option`, inputProps: { 'aria-label': `${option.label}` } })), labelPlacement: "start" }) }), option.value))) }));
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* Get current translated status
|
|
@@ -6,10 +6,8 @@ import { useThemeProps } from '@mui/system';
|
|
|
6
6
|
import { SCPreferences, useSCFetchEvent, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCEventLocationType, SCEventPrivacyType } from '@selfcommunity/types';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
-
import
|
|
10
|
-
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
9
|
+
import { useMemo } from 'react';
|
|
11
10
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
12
|
-
import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
|
|
13
11
|
import Bullet from '../../shared/Bullet';
|
|
14
12
|
import Calendar from '../../shared/Calendar';
|
|
15
13
|
import EventActionsMenu from '../../shared/EventActionsMenu';
|
|
@@ -90,44 +88,15 @@ export default function EventHeader(inProps) {
|
|
|
90
88
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
91
89
|
// INTL
|
|
92
90
|
const intl = useIntl();
|
|
93
|
-
// REFS
|
|
94
|
-
const updatesSubscription = useRef(null);
|
|
95
91
|
// CONST
|
|
96
92
|
const isEventAdmin = useMemo(() => scUserContext.user && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id]);
|
|
97
93
|
const isEventFinished = useMemo(() => checkEventFinished(scEvent), [scEvent]);
|
|
98
|
-
/**
|
|
99
|
-
* Subscriber for pubsub callback
|
|
100
|
-
*/
|
|
101
|
-
const onChangeEventMembersHandler = useCallback((msg, data) => {
|
|
102
|
-
var _a;
|
|
103
|
-
if (data && ((_a = data === null || data === void 0 ? void 0 : data.event) === null || _a === void 0 ? void 0 : _a.id) === (scEvent === null || scEvent === void 0 ? void 0 : scEvent.id)) {
|
|
104
|
-
let _event = Object.assign({}, scEvent);
|
|
105
|
-
if (msg === `${SCTopicType.GROUP}.${SCGroupEventType.ADD_MEMBER}`) {
|
|
106
|
-
_event.subscribers_counter = _event.subscribers_counter + 1;
|
|
107
|
-
}
|
|
108
|
-
else if (msg === `${SCTopicType.GROUP}.${SCGroupEventType.REMOVE_MEMBER}`) {
|
|
109
|
-
_event.subscribers_counter = Math.max(_event.subscribers_counter - 1, 0);
|
|
110
|
-
}
|
|
111
|
-
setSCEvent(_event);
|
|
112
|
-
}
|
|
113
|
-
}, [scEvent, setSCEvent]);
|
|
114
94
|
/**
|
|
115
95
|
* Handles callback subscribe/unsubscribe event
|
|
116
96
|
*/
|
|
117
97
|
const handleSubscribe = (_event, status) => {
|
|
118
98
|
setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
|
|
119
99
|
};
|
|
120
|
-
/**
|
|
121
|
-
* On mount, subscribe to receive events updates (only edit)
|
|
122
|
-
*/
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (scEvent) {
|
|
125
|
-
updatesSubscription.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.MEMBERS}`, onChangeEventMembersHandler);
|
|
126
|
-
}
|
|
127
|
-
return () => {
|
|
128
|
-
updatesSubscription.current && PubSub.unsubscribe(updatesSubscription.current);
|
|
129
|
-
};
|
|
130
|
-
}, [scEvent]);
|
|
131
100
|
// RENDER
|
|
132
101
|
if (!scEvent) {
|
|
133
102
|
return _jsx(EventHeaderSkeleton, {});
|
|
@@ -170,5 +139,5 @@ export default function EventHeader(inProps) {
|
|
|
170
139
|
month: 'long'
|
|
171
140
|
}),
|
|
172
141
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
173
|
-
} })) })), _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.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), _jsx(User, { className: classes.planner, userId: scEvent.managed_by.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,
|
|
142
|
+
} })) })), _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.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), _jsx(User, { className: classes.planner, userId: scEvent.managed_by.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, disabled: isEventFinished }), _jsxs(Box, { children: [!isMobile && (_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished })), _jsx(EventActionsMenu, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), _jsx(EventActionsMenu, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })) }) })] }))] })));
|
|
174
143
|
}
|
|
@@ -44,7 +44,7 @@ export default function TabContentComponent(props) {
|
|
|
44
44
|
// EFFECTS
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
updatesInvited.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
|
|
47
|
-
updatesParticipants.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.
|
|
47
|
+
updatesParticipants.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.MEMBERS}`, handleToggleMember);
|
|
48
48
|
return () => {
|
|
49
49
|
updatesInvited.current && PubSub.unsubscribe(updatesInvited.current);
|
|
50
50
|
updatesParticipants.current && PubSub.unsubscribe(updatesParticipants.current);
|
|
@@ -93,7 +93,7 @@ export default function EventSubscribeButton(inProps) {
|
|
|
93
93
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
94
94
|
// CONST
|
|
95
95
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
96
|
-
const { scEvent } = useSCFetchEvent({
|
|
96
|
+
const { scEvent, setSCEvent } = useSCFetchEvent({
|
|
97
97
|
id: eventId,
|
|
98
98
|
event,
|
|
99
99
|
cacheStrategy: authUserId ? CacheStrategies.CACHE_FIRST : CacheStrategies.STALE_WHILE_REVALIDATE
|
|
@@ -120,14 +120,14 @@ export default function EventSubscribeButton(inProps) {
|
|
|
120
120
|
const isGoing = eventStatus === SCEventSubscriptionStatusType.GOING ||
|
|
121
121
|
!(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) ||
|
|
122
122
|
(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) === SCEventSubscriptionStatusType.INVITED;
|
|
123
|
-
const toggleAction = isGoing
|
|
124
|
-
? scEventsManager.toggleEventAttendance(scEvent, (user === null || user === void 0 ? void 0 : user.id) || null)
|
|
125
|
-
: scEventsManager.toggleEventNonattendance(scEvent);
|
|
123
|
+
const toggleAction = isGoing ? scEventsManager.toggleEventAttendance(scEvent) : scEventsManager.toggleEventNonattendance(scEvent);
|
|
126
124
|
toggleAction
|
|
127
125
|
.then(() => {
|
|
128
|
-
onSubscribe
|
|
126
|
+
onSubscribe
|
|
127
|
+
? onSubscribe(scEvent, getEventStatus(scEvent, isGoing))
|
|
128
|
+
: setSCEvent(Object.assign({}, scEvent, { subscription_status: getEventStatus(scEvent, isGoing) }));
|
|
129
129
|
setLoading(false);
|
|
130
|
-
PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.
|
|
130
|
+
PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.MEMBERS}`);
|
|
131
131
|
})
|
|
132
132
|
.catch((e) => {
|
|
133
133
|
Logger.error(SCOPE_SC_UI, e);
|
|
@@ -143,7 +143,7 @@ export default function EventSubscribeButton(inProps) {
|
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
function renderMenuItems() {
|
|
146
|
-
return (_jsx(Box, { children: options.map((option) => (_jsx(MenuItem, Object.assign({ className: classes.item, disabled: loading }, { children: _jsx(FormControlLabel, { label: option.label, control: loading ? (_jsx(CircularProgress, { color:
|
|
146
|
+
return (_jsx(Box, { children: options.map((option) => (_jsx(MenuItem, Object.assign({ className: classes.item, disabled: loading }, { children: _jsx(FormControlLabel, { label: option.label, control: loading ? (_jsx(CircularProgress, { color: "primary", size: 20 })) : (_jsx(Checkbox, { size: "small", checked: status === option.value, value: option.value, onChange: handleToggleAction, name: `${option.value}-option`, inputProps: { 'aria-label': `${option.label}` } })), labelPlacement: "start" }) }), option.value))) }));
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Get current translated status
|