@selfcommunity/react-ui 0.9.0-alpha.2 → 0.9.0-alpha.21
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/assets/onBoarding/android.d.ts +1 -1
- package/lib/cjs/assets/onBoarding/android.js +1 -1
- package/lib/cjs/components/Event/Event.js +1 -1
- package/lib/cjs/components/EventHeader/EventHeader.js +5 -40
- package/lib/cjs/components/EventMediaWidget/EventMediaWidget.js +37 -34
- package/lib/cjs/components/EventMembersWidget/EventMembersWidget.d.ts +3 -0
- package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +15 -34
- package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +1 -1
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +14 -16
- package/lib/cjs/components/Events/Events.js +3 -4
- package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +35 -2
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +1 -1
- package/lib/cjs/components/OnBoardingWidget/ActionsButton.d.ts +7 -0
- package/lib/cjs/components/OnBoardingWidget/ActionsButton.js +84 -0
- package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +44 -19
- package/lib/cjs/components/OnBoardingWidget/Steps/App/App.js +2 -1
- package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +10 -13
- package/lib/cjs/components/UserProfileEdit/Section/PublicInfo.js +2 -1
- package/lib/cjs/shared/EventActionsMenu/index.d.ts +1 -1
- package/lib/cjs/shared/EventActionsMenu/index.js +11 -15
- package/lib/cjs/utils/events.d.ts +2 -0
- package/lib/cjs/utils/events.js +10 -0
- package/lib/cjs/utils/widget.js +11 -1
- package/lib/esm/assets/onBoarding/android.d.ts +1 -1
- package/lib/esm/assets/onBoarding/android.js +1 -1
- package/lib/esm/components/Event/Event.js +1 -1
- package/lib/esm/components/EventHeader/EventHeader.js +6 -41
- package/lib/esm/components/EventMediaWidget/EventMediaWidget.js +37 -34
- package/lib/esm/components/EventMembersWidget/EventMembersWidget.d.ts +3 -0
- package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +15 -34
- package/lib/esm/components/EventMembersWidget/TabContentComponent.js +1 -1
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +16 -18
- package/lib/esm/components/Events/Events.js +3 -4
- package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +38 -5
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +1 -1
- package/lib/esm/components/OnBoardingWidget/ActionsButton.d.ts +7 -0
- package/lib/esm/components/OnBoardingWidget/ActionsButton.js +81 -0
- package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +46 -21
- package/lib/esm/components/OnBoardingWidget/Steps/App/App.js +2 -1
- package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +10 -13
- package/lib/esm/components/UserProfileEdit/Section/PublicInfo.js +2 -1
- package/lib/esm/shared/EventActionsMenu/index.d.ts +1 -1
- package/lib/esm/shared/EventActionsMenu/index.js +11 -15
- package/lib/esm/utils/events.d.ts +2 -0
- package/lib/esm/utils/events.js +6 -0
- package/lib/esm/utils/widget.js +11 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -108,7 +108,7 @@ function Event(inProps) {
|
|
|
108
108
|
});
|
|
109
109
|
const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = event_1.SCEventTemplateType.SNIPPET, hideInProgress = false, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = tslib_1.__rest(props, ["id", "eventId", "event", "className", "template", "hideInProgress", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
|
|
110
110
|
// STATE
|
|
111
|
-
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
111
|
+
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event, autoSubscribe: false });
|
|
112
112
|
const inProgress = (0, react_1.useMemo)(() => scEvent && scEvent.active && scEvent.running, [scEvent]);
|
|
113
113
|
// CONTEXT
|
|
114
114
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
@@ -8,13 +8,12 @@ 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"));
|
|
16
|
+
const events_1 = require("../../utils/events");
|
|
18
17
|
const EditEventButton_1 = tslib_1.__importDefault(require("../EditEventButton"));
|
|
19
18
|
const EventInviteButton_1 = tslib_1.__importDefault(require("../EventInviteButton"));
|
|
20
19
|
const EventSubscribeButton_1 = tslib_1.__importDefault(require("../EventSubscribeButton"));
|
|
@@ -91,49 +90,15 @@ function EventHeader(inProps) {
|
|
|
91
90
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
92
91
|
// INTL
|
|
93
92
|
const intl = (0, react_intl_1.useIntl)();
|
|
94
|
-
// REFS
|
|
95
|
-
const updatesSubscription = (0, react_1.useRef)(null);
|
|
96
93
|
// CONST
|
|
97
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]);
|
|
98
|
-
const isEventFinished = (0, react_1.useMemo)(() =>
|
|
99
|
-
if (scEvent && !scEvent.running) {
|
|
100
|
-
return new Date().getTime() > new Date(scEvent.end_date || scEvent.start_date).getTime();
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
}, [scEvent]);
|
|
104
|
-
/**
|
|
105
|
-
* Subscriber for pubsub callback
|
|
106
|
-
*/
|
|
107
|
-
const onChangeEventMembersHandler = (0, react_1.useCallback)((msg, data) => {
|
|
108
|
-
var _a;
|
|
109
|
-
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)) {
|
|
110
|
-
let _event = Object.assign({}, scEvent);
|
|
111
|
-
if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.ADD_MEMBER}`) {
|
|
112
|
-
_event.subscribers_counter = _event.subscribers_counter + 1;
|
|
113
|
-
}
|
|
114
|
-
else if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.REMOVE_MEMBER}`) {
|
|
115
|
-
_event.subscribers_counter = Math.max(_event.subscribers_counter - 1, 0);
|
|
116
|
-
}
|
|
117
|
-
setSCEvent(_event);
|
|
118
|
-
}
|
|
119
|
-
}, [scEvent, setSCEvent]);
|
|
95
|
+
const isEventFinished = (0, react_1.useMemo)(() => (0, events_1.checkEventFinished)(scEvent), [scEvent]);
|
|
120
96
|
/**
|
|
121
97
|
* Handles callback subscribe/unsubscribe event
|
|
122
98
|
*/
|
|
123
|
-
const handleSubscribe = (
|
|
124
|
-
setSCEvent(
|
|
99
|
+
const handleSubscribe = (event) => {
|
|
100
|
+
setSCEvent(event);
|
|
125
101
|
};
|
|
126
|
-
/**
|
|
127
|
-
* On mount, subscribe to receive events updates (only edit)
|
|
128
|
-
*/
|
|
129
|
-
(0, react_1.useEffect)(() => {
|
|
130
|
-
if (scEvent) {
|
|
131
|
-
updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.MEMBERS}`, onChangeEventMembersHandler);
|
|
132
|
-
}
|
|
133
|
-
return () => {
|
|
134
|
-
updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
|
|
135
|
-
};
|
|
136
|
-
}, [scEvent]);
|
|
137
102
|
// RENDER
|
|
138
103
|
if (!scEvent) {
|
|
139
104
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
@@ -176,6 +141,6 @@ function EventHeader(inProps) {
|
|
|
176
141
|
month: 'long'
|
|
177
142
|
}),
|
|
178
143
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
179
|
-
} })) })), (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: 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))] })) }) })] }))] })));
|
|
180
145
|
}
|
|
181
146
|
exports.default = EventHeader;
|
|
@@ -83,8 +83,8 @@ function EventMediaWidget(inProps) {
|
|
|
83
83
|
cacheStrategy,
|
|
84
84
|
visibleItems: limit
|
|
85
85
|
}, widget_1.stateWidgetInitializer);
|
|
86
|
-
const [medias, setMedias] = (0, react_1.useState)(
|
|
87
|
-
const [mediasCount, setMediasCount] = (0, react_1.useState)(
|
|
86
|
+
const [medias, setMedias] = (0, react_1.useState)(state.results);
|
|
87
|
+
const [mediasCount, setMediasCount] = (0, react_1.useState)(state.count);
|
|
88
88
|
const [openDialog, setOpenDialog] = (0, react_1.useState)(false);
|
|
89
89
|
const [openDialogConfirm, setOpenDialogConfirm] = (0, react_1.useState)(false);
|
|
90
90
|
const [mediaId, setMediaId] = (0, react_1.useState)(null);
|
|
@@ -96,25 +96,6 @@ function EventMediaWidget(inProps) {
|
|
|
96
96
|
// CONSTS
|
|
97
97
|
const hasAllow = (0, react_1.useMemo)(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) === (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id); }, [scUserContext, scEvent]);
|
|
98
98
|
const countHiddenMedia = (0, react_1.useMemo)(() => mediasCount - MEDIAS_TO_SHOW, [mediasCount]);
|
|
99
|
-
/**
|
|
100
|
-
* Initialize component
|
|
101
|
-
* Fetch data only if the component is not initialized and it is not loading data
|
|
102
|
-
*/
|
|
103
|
-
const _initComponent = (0, react_1.useCallback)(() => {
|
|
104
|
-
if (!state.initialized && !state.isLoadingNext) {
|
|
105
|
-
dispatch({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
106
|
-
api_services_1.EventService.getEventPhotoGallery(scEvent.id, Object.assign({}, endpointQueryParams))
|
|
107
|
-
.then((payload) => {
|
|
108
|
-
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
|
|
109
|
-
setMedias(payload.results);
|
|
110
|
-
setMediasCount(payload.count);
|
|
111
|
-
})
|
|
112
|
-
.catch((error) => {
|
|
113
|
-
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
114
|
-
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}, [state.isLoadingNext, scEvent, dispatch, setMedias, setMediasCount]);
|
|
118
99
|
const _fetchNext = (0, react_1.useCallback)((index) => {
|
|
119
100
|
if (mediasCount > medias.length && index >= 6 && !state.isLoadingNext && state.next) {
|
|
120
101
|
setPreview(index);
|
|
@@ -212,33 +193,55 @@ function EventMediaWidget(inProps) {
|
|
|
212
193
|
// EFFECTS
|
|
213
194
|
(0, react_1.useEffect)(() => {
|
|
214
195
|
let _t;
|
|
215
|
-
if (scUserContext.user &&
|
|
196
|
+
if (scUserContext.user &&
|
|
197
|
+
scEvent &&
|
|
198
|
+
!state.initialized &&
|
|
199
|
+
Boolean((eventId !== undefined && scEvent.id === eventId) || (event && scEvent.id === event.id))) {
|
|
216
200
|
_t = setTimeout(_initComponent);
|
|
217
201
|
return () => {
|
|
218
202
|
clearTimeout(_t);
|
|
219
|
-
if (state.initialized) {
|
|
220
|
-
dispatch({
|
|
221
|
-
type: widget_1.actionWidgetTypes.INITIALIZE,
|
|
222
|
-
payload: {
|
|
223
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY, scEvent.id)
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
203
|
};
|
|
228
204
|
}
|
|
229
205
|
}, [scUserContext.user, scEvent, state.initialized]);
|
|
206
|
+
(0, react_1.useEffect)(() => {
|
|
207
|
+
if (state.initialized && scEvent && Boolean((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) {
|
|
208
|
+
dispatch({ type: widget_1.actionWidgetTypes.RESET, payload: {} });
|
|
209
|
+
}
|
|
210
|
+
}, [state.initialized, scEvent, eventId, event]);
|
|
211
|
+
/**
|
|
212
|
+
* Initialize component
|
|
213
|
+
* Fetch data only if the component is not initialized and it is not loading data
|
|
214
|
+
*/
|
|
215
|
+
const _initComponent = (0, react_1.useCallback)(() => {
|
|
216
|
+
if (!state.isLoadingNext) {
|
|
217
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
218
|
+
api_services_1.EventService.getEventPhotoGallery(scEvent.id, Object.assign({}, endpointQueryParams))
|
|
219
|
+
.then((payload) => {
|
|
220
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
|
|
221
|
+
setMedias(payload.results);
|
|
222
|
+
setMediasCount(payload.count);
|
|
223
|
+
})
|
|
224
|
+
.catch((error) => {
|
|
225
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
226
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}, [state.isLoadingNext, scEvent, eventId, dispatch, setMedias, setMediasCount]);
|
|
230
230
|
(0, react_1.useEffect)(() => {
|
|
231
231
|
if (isMobile && openDialog && state.next) {
|
|
232
232
|
handleNext();
|
|
233
233
|
}
|
|
234
234
|
}, [isMobile, openDialog, state.next]);
|
|
235
235
|
// RENDER
|
|
236
|
-
if (!scEvent ||
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
if (!scEvent ||
|
|
237
|
+
!state.initialized ||
|
|
238
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) ||
|
|
239
|
+
(state.isLoadingNext && !state.initialized)) {
|
|
240
240
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
241
241
|
}
|
|
242
|
+
if (state.initialized && state.count === 0 && !hasAllow) {
|
|
243
|
+
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
244
|
+
}
|
|
242
245
|
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: classes.root }, rest, { showPadding: hasAllow }, { children: [(0, jsx_runtime_1.jsx)(material_1.CardHeader, { title: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMediaWidget.title", defaultMessage: "ui.eventMediaWidget.title" }) })), hasAllow && mediasCount > 0 && (0, jsx_runtime_1.jsx)(TriggerButton_1.default, { size: "small", onAdd: handleAddMedia })] })), className: classes.header }), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsxs)(system_1.Box, Object.assign({ className: classes.grid }, { children: [showSkeleton === 'widget' && (0, jsx_runtime_1.jsx)(Skeleton_1.EventMediaSkeleton, {}), medias.slice(0, MEDIAS_TO_SHOW).map((media, i, array) => ((0, jsx_runtime_1.jsx)(system_1.Box, Object.assign({ onClick: () => handleOpenLightbox(i), sx: {
|
|
243
246
|
background: `url(${media.image}) no-repeat center`
|
|
244
247
|
}, className: classes.media }, { children: medias.length > array.length && i === array.length - 1 && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(system_1.Box, { className: classes.mediaLayer }), (0, jsx_runtime_1.jsx)(system_1.Box, Object.assign({ className: classes.countHiddenMediaWrapper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.countHiddenMedia }, { children: ["+", countHiddenMedia] })) }))] })) }), media.id))), hasAllow && mediasCount === 0 && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMediaWidget.add", defaultMessage: "ui.eventMediaWidget.add" }) }, { children: (0, jsx_runtime_1.jsx)(TriggerButton_1.default, { size: "large", onAdd: handleAddMedia, isSquare: true }) })))] })), preview !== -1 && (0, jsx_runtime_1.jsx)(Lightbox_1.Lightbox, { onClose: handleCloseLightbox, index: preview, medias: medias, onIndexChange: _fetchNext })] })), hasAllow && mediasCount > 0 && ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleToggleDialogOpen }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMediaWidget.showAll", defaultMessage: "ui.eventMediaWidget.showAll" }) })) })) }))), openDialog && ((0, jsx_runtime_1.jsx)(DialogRoot, Object.assign({ className: classes.dialogRoot, title: intl.formatMessage(messages.title, { user: scEvent.managed_by.username }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: medias.length, height: isMobile ? '100%' : '515px', next: handleNext, hasMoreNext: Boolean(state.next), className: classes.dialogInfiniteScroll, endMessage: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMediaWidget.noMoreResults", defaultMessage: "ui.eventMediaWidget.noMoreResults" }) })) }, { children: (0, jsx_runtime_1.jsxs)(system_1.Box, Object.assign({ className: classes.grid }, { children: [medias.map((media) => ((0, jsx_runtime_1.jsx)(system_1.Box, Object.assign({ sx: {
|
|
@@ -13,7 +13,6 @@ const react_intl_1 = require("react-intl");
|
|
|
13
13
|
require("swiper/css");
|
|
14
14
|
const Errors_1 = require("../../constants/Errors");
|
|
15
15
|
const Pagination_1 = require("../../constants/Pagination");
|
|
16
|
-
const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
|
|
17
16
|
const widget_1 = require("../../utils/widget");
|
|
18
17
|
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
19
18
|
const constants_1 = require("./constants");
|
|
@@ -62,10 +61,10 @@ function EventMembersWidget(inProps) {
|
|
|
62
61
|
cacheStrategy,
|
|
63
62
|
visibleItems: limit
|
|
64
63
|
}, widget_1.stateWidgetInitializer);
|
|
65
|
-
const [participantsCount, setParticipantsCount] = (0, react_1.useState)(
|
|
66
|
-
const [invitedCount, setInvitedCount] = (0, react_1.useState)(
|
|
67
|
-
const [requestsCount, setRequestsCount] = (0, react_1.useState)(
|
|
68
|
-
const [requestsUsers, setRequestsUsers] = (0, react_1.useState)(
|
|
64
|
+
const [participantsCount, setParticipantsCount] = (0, react_1.useState)(participants.count);
|
|
65
|
+
const [invitedCount, setInvitedCount] = (0, react_1.useState)(invited.count);
|
|
66
|
+
const [requestsCount, setRequestsCount] = (0, react_1.useState)(requests.count);
|
|
67
|
+
const [requestsUsers, setRequestsUsers] = (0, react_1.useState)(requests.results);
|
|
69
68
|
const [tabValue, setTabValue] = (0, react_1.useState)(types_1.TabContentEnum.PARTICIPANTS);
|
|
70
69
|
const [refresh, setRefresh] = (0, react_1.useState)(null);
|
|
71
70
|
// CONTEXT
|
|
@@ -150,33 +149,16 @@ function EventMembersWidget(inProps) {
|
|
|
150
149
|
});
|
|
151
150
|
return () => {
|
|
152
151
|
clearTimeout(_t);
|
|
153
|
-
if (participants.initialized) {
|
|
154
|
-
dispatchParticipants({
|
|
155
|
-
type: widget_1.actionWidgetTypes.INITIALIZE,
|
|
156
|
-
payload: {
|
|
157
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USER_PARTECIPANTS_EVENTS_STATE_CACHE_PREFIX_KEY, scEvent.id)
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
if (invited.initialized) {
|
|
162
|
-
dispatchParticipants({
|
|
163
|
-
type: widget_1.actionWidgetTypes.INITIALIZE,
|
|
164
|
-
payload: {
|
|
165
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USER_INVITED_EVENTS_STATE_CACHE_PREFIX_KEY, scEvent.id)
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
if (requests.initialized) {
|
|
170
|
-
dispatchParticipants({
|
|
171
|
-
type: widget_1.actionWidgetTypes.INITIALIZE,
|
|
172
|
-
payload: {
|
|
173
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USER_REQUESTS_EVENTS_STATE_CACHE_PREFIX_KEY, scEvent.id)
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
152
|
};
|
|
178
153
|
}
|
|
179
154
|
}, [scUserContext.user, scEvent, refresh]);
|
|
155
|
+
(0, react_1.useEffect)(() => {
|
|
156
|
+
if (participants.initialized && scEvent && Boolean((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) {
|
|
157
|
+
dispatchParticipants({ type: widget_1.actionWidgetTypes.RESET, payload: {} });
|
|
158
|
+
dispatchRequests({ type: widget_1.actionWidgetTypes.RESET, payload: {} });
|
|
159
|
+
dispatchInvited({ type: widget_1.actionWidgetTypes.RESET, payload: {} });
|
|
160
|
+
}
|
|
161
|
+
}, [participants.initialized, scEvent, eventId, event]);
|
|
180
162
|
// HANDLERS
|
|
181
163
|
const handleTabChange = (0, react_1.useCallback)((_evt, newTabValue) => {
|
|
182
164
|
setTabValue(newTabValue);
|
|
@@ -190,13 +172,12 @@ function EventMembersWidget(inProps) {
|
|
|
190
172
|
}
|
|
191
173
|
setRefresh(_tabValue);
|
|
192
174
|
}, []);
|
|
193
|
-
if (!scEvent
|
|
175
|
+
if (!scEvent ||
|
|
176
|
+
!participants.initialized ||
|
|
177
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) ||
|
|
178
|
+
(tabValue === types_1.TabContentEnum.PARTICIPANTS && participants.isLoadingNext && !participants.initialized)) {
|
|
194
179
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
195
180
|
}
|
|
196
|
-
// RENDER
|
|
197
|
-
if (!scEvent) {
|
|
198
|
-
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
199
|
-
}
|
|
200
181
|
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.title }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: title, defaultMessage: title }) })), (0, jsx_runtime_1.jsxs)(lab_1.TabContext, Object.assign({ value: tabValue }, { children: [(0, jsx_runtime_1.jsxs)(lab_1.TabList, Object.assign({ className: classes.tabsWrapper, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "fullWidth" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: participantsCount })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.participants", defaultMessage: "ui.eventMembersWidget.participants" }) }))] })), value: types_1.TabContentEnum.PARTICIPANTS }), hasAllow && ((0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: invitedCount })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.invited", defaultMessage: "ui.eventMembersWidget.invited" }) }))] })), value: types_1.TabContentEnum.INVITED })), hasAllow && ((0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: requestsCount })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.requests", defaultMessage: "ui.eventMembersWidget.requests" }) }))] })), value: types_1.TabContentEnum.REQUESTS }))] })), (0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabContentEnum.PARTICIPANTS, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabContentEnum.PARTICIPANTS, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, handleRefresh: handleRefresh }) })), hasAllow && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabContentEnum.INVITED, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabContentEnum.INVITED, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
|
|
201
182
|
scEvent,
|
|
202
183
|
setCount: setInvitedCount
|
|
@@ -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);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SCEventType, SCUserType } from '@selfcommunity/types';
|
|
2
2
|
export interface EventSubscribeButtonProps {
|
|
3
3
|
/**
|
|
4
4
|
* Overrides or extends the styles applied to the component.
|
|
@@ -25,7 +25,7 @@ export interface EventSubscribeButtonProps {
|
|
|
25
25
|
* @param user
|
|
26
26
|
* @param joined
|
|
27
27
|
*/
|
|
28
|
-
onSubscribe?: (event: SCEventType
|
|
28
|
+
onSubscribe?: (event: SCEventType) => any;
|
|
29
29
|
/**
|
|
30
30
|
* Others properties
|
|
31
31
|
*/
|
|
@@ -95,19 +95,19 @@ 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
|
|
102
102
|
});
|
|
103
103
|
const isEventAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
104
104
|
// HANDLERS
|
|
105
|
-
const handleOpen = (event) => {
|
|
105
|
+
const handleOpen = (0, react_1.useCallback)((event) => {
|
|
106
106
|
setAnchorEl(event.currentTarget);
|
|
107
|
-
};
|
|
108
|
-
const handleClose = () => {
|
|
107
|
+
}, [setAnchorEl]);
|
|
108
|
+
const handleClose = (0, react_1.useCallback)(() => {
|
|
109
109
|
setAnchorEl(null);
|
|
110
|
-
};
|
|
110
|
+
}, [setAnchorEl]);
|
|
111
111
|
(0, react_1.useEffect)(() => {
|
|
112
112
|
/**
|
|
113
113
|
* Call scEventsManager.subscriptionStatus inside an effect
|
|
@@ -117,25 +117,23 @@ function EventSubscribeButton(inProps) {
|
|
|
117
117
|
setStatus(scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus(scEvent));
|
|
118
118
|
}
|
|
119
119
|
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent]);
|
|
120
|
-
const toggleEventAttendance = (eventStatus) => {
|
|
120
|
+
const toggleEventAttendance = (0, react_1.useCallback)((eventStatus) => {
|
|
121
121
|
setLoading(true);
|
|
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
|
-
.then(() => {
|
|
130
|
-
onSubscribe
|
|
127
|
+
.then((data) => {
|
|
128
|
+
onSubscribe ? onSubscribe(data) : setSCEvent(data);
|
|
131
129
|
setLoading(false);
|
|
132
|
-
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.
|
|
130
|
+
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.MEMBERS}`);
|
|
133
131
|
})
|
|
134
132
|
.catch((e) => {
|
|
135
133
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
136
134
|
});
|
|
137
|
-
};
|
|
138
|
-
const handleToggleAction = (event) => {
|
|
135
|
+
}, [scEvent, scEventsManager, onSubscribe, setLoading]);
|
|
136
|
+
const handleToggleAction = (0, react_1.useCallback)((event) => {
|
|
139
137
|
setAnchorEl(null);
|
|
140
138
|
if (!scUserContext.user) {
|
|
141
139
|
scContext.settings.handleAnonymousAction();
|
|
@@ -143,9 +141,9 @@ function EventSubscribeButton(inProps) {
|
|
|
143
141
|
else if (status !== undefined) {
|
|
144
142
|
toggleEventAttendance(event.target.value);
|
|
145
143
|
}
|
|
146
|
-
};
|
|
144
|
+
}, [scUserContext.user, status, scContext.settings]);
|
|
147
145
|
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:
|
|
146
|
+
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
147
|
}
|
|
150
148
|
/**
|
|
151
149
|
* Get current translated status
|
|
@@ -145,13 +145,13 @@ function Events(inProps) {
|
|
|
145
145
|
* On mount, fetches events list
|
|
146
146
|
*/
|
|
147
147
|
(0, react_1.useEffect)(() => {
|
|
148
|
-
if (!contentAvailability) {
|
|
148
|
+
if (!contentAvailability && !authUserId) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
152
|
query === '' && fetchEvents();
|
|
153
153
|
}
|
|
154
|
-
}, [contentAvailability, dateSearch, location, showFollowed, showPastEvents, showMyEvents, query]);
|
|
154
|
+
}, [contentAvailability, authUserId, dateSearch, location, showFollowed, showPastEvents, showMyEvents, query]);
|
|
155
155
|
/**
|
|
156
156
|
* Subscriber for pubsub callback
|
|
157
157
|
*/
|
|
@@ -214,7 +214,6 @@ function Events(inProps) {
|
|
|
214
214
|
/**
|
|
215
215
|
* Renders events list
|
|
216
216
|
*/
|
|
217
|
-
console.log(location);
|
|
218
217
|
const c = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showFilters && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(events.length !== 0 || (events.length === 0 && showMyEvents)) && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
|
|
219
218
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
220
219
|
// @ts-ignore
|
|
@@ -247,7 +246,7 @@ function Events(inProps) {
|
|
|
247
246
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
248
247
|
// @ts-ignore
|
|
249
248
|
showFollowed: showFollowed, deleteIcon: showFollowed ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading || (!events.length && !showFollowed) }) }))), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(PastEventsFilter_1.default, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== types_1.SCEventDateFilterType.ANY || loading || (!events.length && !showPastEvents) }) }))] })) }))), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loading ? ((0, jsx_runtime_1.jsx)(Skeleton_1.default, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !events.length ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.noResults }, { children: (onlyStaffEnabled && !react_core_1.UserUtils.isStaff(scUserContext.user)) ||
|
|
250
|
-
(onlyStaffEnabled && react_core_1.UserUtils.isStaff(scUserContext.user) && general) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps)), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (0, jsx_runtime_1.jsx)(CreateEventButton_1.default, {}) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.noEvents.title.onlyStaff", defaultMessage: "ui.events.noEvents.title.onlyStaff" }) }))] })) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, GridContainerComponentProps, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [events.map((event) => ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.item }, GridItemComponentProps, { children: (0, jsx_runtime_1.jsx)(Event_1.default, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), authUserId && events.length % 2 !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.itemSkeleton }, GridItemComponentProps, { children: (0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (0, jsx_runtime_1.jsx)(CreateEventButton_1.default, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })) })] }));
|
|
249
|
+
(onlyStaffEnabled && react_core_1.UserUtils.isStaff(scUserContext.user) && general) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (0, jsx_runtime_1.jsx)(CreateEventButton_1.default, {}) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.noEvents.title.onlyStaff", defaultMessage: "ui.events.noEvents.title.onlyStaff" }) }))] })) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, GridContainerComponentProps, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [events.map((event) => ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.item }, GridItemComponentProps, { children: (0, jsx_runtime_1.jsx)(Event_1.default, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), authUserId && events.length % 2 !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.itemSkeleton }, GridItemComponentProps, { children: (0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (0, jsx_runtime_1.jsx)(CreateEventButton_1.default, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })) })] }));
|
|
251
250
|
/**
|
|
252
251
|
* Renders root object (if content availability community option is false and user is anonymous, component is hidden)
|
|
253
252
|
*/
|
|
@@ -10,6 +10,9 @@ const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
|
10
10
|
const system_1 = require("@mui/system");
|
|
11
11
|
const react_intl_1 = require("react-intl");
|
|
12
12
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
13
|
+
const Errors_1 = require("../../constants/Errors");
|
|
14
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
15
|
+
const types_1 = require("@selfcommunity/types");
|
|
13
16
|
const PREFIX = 'SCNavigationSettingsIconButton';
|
|
14
17
|
const classes = {
|
|
15
18
|
root: `${PREFIX}-root`,
|
|
@@ -37,7 +40,9 @@ const PREFERENCES = [
|
|
|
37
40
|
react_core_1.SCPreferences.CONFIGURATIONS_FOLLOW_ENABLED,
|
|
38
41
|
react_core_1.SCPreferences.CONFIGURATIONS_POST_TYPE_ENABLED,
|
|
39
42
|
react_core_1.SCPreferences.CONFIGURATIONS_DISCUSSION_TYPE_ENABLED,
|
|
40
|
-
react_core_1.SCPreferences.ADDONS_LOYALTY_POINTS_COLLECTION
|
|
43
|
+
react_core_1.SCPreferences.ADDONS_LOYALTY_POINTS_COLLECTION,
|
|
44
|
+
react_core_1.SCPreferences.CONFIGURATIONS_ONBOARDING_ENABLED,
|
|
45
|
+
react_core_1.SCPreferences.CONFIGURATIONS_ONBOARDING_HIDDEN
|
|
41
46
|
];
|
|
42
47
|
/**
|
|
43
48
|
* > API documentation for the Community-JS Navigation Settings Icon Button component. Learn about the available props and the CSS API.
|
|
@@ -74,6 +79,7 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
74
79
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
75
80
|
// MEMO
|
|
76
81
|
const isAdmin = (0, react_1.useMemo)(() => react_core_1.UserUtils.isAdmin(scUserContext.user), [scUserContext.user]);
|
|
82
|
+
const isCommunityCreator = (0, react_1.useMemo)(() => react_core_1.UserUtils.isCommunityCreator(scUserContext.user), [scUserContext.user]);
|
|
77
83
|
const isModerator = (0, react_1.useMemo)(() => react_core_1.UserUtils.isModerator(scUserContext.user), [scUserContext.user]);
|
|
78
84
|
// HOOKS
|
|
79
85
|
const theme = (0, material_1.useTheme)();
|
|
@@ -94,7 +100,7 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
94
100
|
setAnchorEl(null);
|
|
95
101
|
};
|
|
96
102
|
/**
|
|
97
|
-
* Fetches
|
|
103
|
+
* Fetches platform url
|
|
98
104
|
* @param query
|
|
99
105
|
*/
|
|
100
106
|
const fetchPlatform = (query) => {
|
|
@@ -103,6 +109,27 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
103
109
|
window.open(platformUrl, '_blank').focus();
|
|
104
110
|
});
|
|
105
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Handles preferences update
|
|
114
|
+
*/
|
|
115
|
+
const handlePreferencesUpdate = () => {
|
|
116
|
+
api_services_1.PreferenceService.getAllPreferences().then((preferences) => {
|
|
117
|
+
const prefs = preferences['results'].reduce((obj, p) => (Object.assign(Object.assign({}, obj), { [`${p.section}.${p.name}`]: p })), {});
|
|
118
|
+
scPreferences.setPreferences(prefs);
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Updates onBoarding dynamic preference
|
|
123
|
+
*/
|
|
124
|
+
const showOnBoarding = () => {
|
|
125
|
+
api_services_1.PreferenceService.updatePreferences({ [`${types_1.SCPreferenceName.ONBOARDING_HIDDEN}`]: false })
|
|
126
|
+
.then(() => {
|
|
127
|
+
handlePreferencesUpdate();
|
|
128
|
+
})
|
|
129
|
+
.catch((e) => {
|
|
130
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
131
|
+
});
|
|
132
|
+
};
|
|
106
133
|
const handleLogout = () => {
|
|
107
134
|
scUserContext.logout();
|
|
108
135
|
};
|
|
@@ -121,6 +148,9 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
121
148
|
...(isAdmin
|
|
122
149
|
? [
|
|
123
150
|
(0, jsx_runtime_1.jsx)(material_1.Divider, {}, "admin_divider"),
|
|
151
|
+
isCommunityCreator &&
|
|
152
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_ONBOARDING_ENABLED] &&
|
|
153
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_ONBOARDING_HIDDEN] && ((0, jsx_runtime_1.jsx)(material_1.ListItem, Object.assign({ className: classes.item }, { children: (0, jsx_runtime_1.jsxs)(material_1.ListItemButton, Object.assign({ onClick: showOnBoarding }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.onboarding", defaultMessage: "ui.navigationSettingsIconButton.onboarding" }), (0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "magic_wand" }) })] })) }), "onboarding")),
|
|
124
154
|
(0, jsx_runtime_1.jsx)(material_1.ListItem, Object.assign({ className: classes.item }, { children: (0, jsx_runtime_1.jsx)(material_1.ListItemButton, Object.assign({ onClick: () => fetchPlatform('') }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.platform", defaultMessage: "ui.navigationSettingsIconButton.platform" }) })) }), "platform")
|
|
125
155
|
]
|
|
126
156
|
: []),
|
|
@@ -149,6 +179,9 @@ function NavigationSettingsIconButton(inProps) {
|
|
|
149
179
|
...(isAdmin
|
|
150
180
|
? [
|
|
151
181
|
(0, jsx_runtime_1.jsx)(material_1.Divider, {}, "platform_divider"),
|
|
182
|
+
isCommunityCreator &&
|
|
183
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_ONBOARDING_ENABLED] &&
|
|
184
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_ONBOARDING_HIDDEN] && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: showOnBoarding }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.onboarding", defaultMessage: "ui.navigationSettingsIconButton.onboarding" }), (0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "magic_wand" }) })] }), "onboarding")),
|
|
152
185
|
(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => fetchPlatform('') }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.navigationSettingsIconButton.platform", defaultMessage: "ui.navigationSettingsIconButton.platform" }) }), "platform")
|
|
153
186
|
]
|
|
154
187
|
: []),
|
|
@@ -144,7 +144,7 @@ function NavigationToolbar(inProps) {
|
|
|
144
144
|
(preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY] || scUserContext.user) && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.explore, { [classes.active]: value.startsWith(scRoutingContext.url(react_core_1.SCRoutes.EXPLORE_ROUTE_NAME, {})) }), "aria-label": "Explore", to: scRoutingContext.url(react_core_1.SCRoutes.EXPLORE_ROUTE_NAME, {}), component: react_core_1.Link }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "explore" }) }))), groupsEnabled && scUserContext.user && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.groups, {
|
|
145
145
|
[classes.active]: value.startsWith(scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {})) ||
|
|
146
146
|
value.startsWith(scRoutingContext.url(react_core_1.SCRoutes.GROUPS_ROUTE_NAME, {}))
|
|
147
|
-
}), "aria-label": "Groups", to: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), component: react_core_1.Link }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "groups" }) }))), eventsEnabled && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.events, {
|
|
147
|
+
}), "aria-label": "Groups", to: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), component: react_core_1.Link }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "groups" }) }))), eventsEnabled && (scUserContext.user || preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY]) && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.events, {
|
|
148
148
|
[classes.active]: value.startsWith(scRoutingContext.url(react_core_1.SCRoutes.EVENTS_ROUTE_NAME, {}))
|
|
149
149
|
}), "aria-label": "Groups", to: scRoutingContext.url(react_core_1.SCRoutes.EVENTS_ROUTE_NAME, {}), component: react_core_1.Link }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "CalendarIcon" }) })))] })));
|
|
150
150
|
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: [(0, jsx_runtime_1.jsx)(NavigationMenuIconButtonComponent, Object.assign({}, NavigationMenuIconButtonComponentProps)), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.LOGO_NAVBAR_LOGO], alt: "logo" }) })), !scUserContext.user && !preferences[react_core_1.SCPreferences.ADDONS_CLOSED_COMMUNITY] && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "inherit", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.SIGNUP_ROUTE_NAME, {}), className: classes.register }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.appBar.navigation.register", defaultMessage: "ui.appBar.navigation.register" }) }))), preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED] && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ target: "blank", to: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) })) }))) : ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ target: "blank", to: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) }))) })), _children, (preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY] || scUserContext.user) && !disableSearch ? ((0, jsx_runtime_1.jsx)(SearchAutocomplete_1.default, Object.assign({ className: classes.search, blurOnSelect: true }, SearchAutocompleteProps))) : ((0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.search })), startActions, scUserContext.user ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showComposer && (0, jsx_runtime_1.jsx)(ComposerIconButton_1.default, Object.assign({ className: classes.composer }, ComposerIconButtonProps)), (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: scUserContext.user.username }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scUserContext.user), "aria-label": "Profile", className: classes.profile }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scUserContext.user.username, src: scUserContext.user.avatar }) })) })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.notification, {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IconButtonProps } from '@mui/material';
|
|
2
|
+
export interface OnBoardingActionsButtonProps extends IconButtonProps {
|
|
3
|
+
isExpanded: boolean;
|
|
4
|
+
onExpandChange: () => void;
|
|
5
|
+
onHideOnBoarding: () => void;
|
|
6
|
+
}
|
|
7
|
+
export default function OnBoardingActionsButton(inProps: OnBoardingActionsButtonProps): JSX.Element;
|