@selfcommunity/react-ui 0.9.0-alpha.1 → 0.9.0-alpha.10
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/Event/Event.js +1 -1
- package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
- package/lib/cjs/components/EventMediaWidget/EventMediaWidget.d.ts +4 -0
- package/lib/cjs/components/EventMediaWidget/EventMediaWidget.js +45 -34
- package/lib/cjs/components/EventMembersWidget/EventMembersWidget.d.ts +3 -0
- package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +18 -13
- package/lib/cjs/components/Events/Events.js +2 -3
- package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +10 -13
- package/lib/cjs/shared/EventActionsMenu/index.d.ts +1 -1
- package/lib/cjs/utils/widget.d.ts +1 -0
- package/lib/cjs/utils/widget.js +14 -0
- package/lib/esm/components/Event/Event.js +1 -1
- package/lib/esm/components/EventHeader/EventHeader.js +1 -1
- package/lib/esm/components/EventMediaWidget/EventMediaWidget.d.ts +4 -0
- package/lib/esm/components/EventMediaWidget/EventMediaWidget.js +46 -35
- package/lib/esm/components/EventMembersWidget/EventMembersWidget.d.ts +3 -0
- package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +18 -13
- package/lib/esm/components/Events/Events.js +2 -3
- package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +10 -13
- package/lib/esm/shared/EventActionsMenu/index.d.ts +1 -1
- package/lib/esm/utils/widget.d.ts +1 -0
- package/lib/esm/utils/widget.js +14 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +3 -3
|
@@ -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)();
|
|
@@ -176,6 +176,6 @@ function EventHeader(inProps) {
|
|
|
176
176
|
month: 'long'
|
|
177
177
|
}),
|
|
178
178
|
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, eventId: scEvent.id, 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, eventId: scEvent.id, 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({
|
|
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, eventId: scEvent.id, 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, eventId: scEvent.id, 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({ eventId: scEvent.id, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })) }) })] }))] })));
|
|
180
180
|
}
|
|
181
181
|
exports.default = EventHeader;
|
|
@@ -69,17 +69,22 @@ function EventMediaWidget(inProps) {
|
|
|
69
69
|
const { event, eventId, limit = Pagination_1.DEFAULT_PAGINATION_LIMIT, endpointQueryParams = {
|
|
70
70
|
limit,
|
|
71
71
|
offset: Pagination_1.DEFAULT_PAGINATION_OFFSET
|
|
72
|
-
}, cacheStrategy, dialogProps } = props, rest = tslib_1.__rest(props, ["event", "eventId", "limit", "endpointQueryParams", "cacheStrategy", "dialogProps"]);
|
|
72
|
+
}, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, dialogProps } = props, rest = tslib_1.__rest(props, ["event", "eventId", "limit", "endpointQueryParams", "cacheStrategy", "dialogProps"]);
|
|
73
|
+
// HOOKS
|
|
74
|
+
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
75
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
76
|
+
const theme = (0, material_1.useTheme)();
|
|
77
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
73
78
|
// STATE
|
|
74
79
|
const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
|
|
75
80
|
isLoadingNext: false,
|
|
76
81
|
next: null,
|
|
77
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY),
|
|
82
|
+
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY, event ? event.id : eventId),
|
|
78
83
|
cacheStrategy,
|
|
79
84
|
visibleItems: limit
|
|
80
85
|
}, widget_1.stateWidgetInitializer);
|
|
81
|
-
const [medias, setMedias] = (0, react_1.useState)(
|
|
82
|
-
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);
|
|
83
88
|
const [openDialog, setOpenDialog] = (0, react_1.useState)(false);
|
|
84
89
|
const [openDialogConfirm, setOpenDialogConfirm] = (0, react_1.useState)(false);
|
|
85
90
|
const [mediaId, setMediaId] = (0, react_1.useState)(null);
|
|
@@ -88,33 +93,9 @@ function EventMediaWidget(inProps) {
|
|
|
88
93
|
const [showSkeleton, setShowSkeleton] = (0, react_1.useState)(null);
|
|
89
94
|
// CONTEXT
|
|
90
95
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
91
|
-
// HOOKS
|
|
92
|
-
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
93
|
-
const intl = (0, react_intl_1.useIntl)();
|
|
94
|
-
const theme = (0, material_1.useTheme)();
|
|
95
|
-
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
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, state.initialized, 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,25 +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
203
|
};
|
|
220
204
|
}
|
|
221
|
-
}, [scUserContext.user, scEvent]);
|
|
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]);
|
|
222
230
|
(0, react_1.useEffect)(() => {
|
|
223
231
|
if (isMobile && openDialog && state.next) {
|
|
224
232
|
handleNext();
|
|
225
233
|
}
|
|
226
234
|
}, [isMobile, openDialog, state.next]);
|
|
227
235
|
// RENDER
|
|
228
|
-
if (!scEvent ||
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
236
|
+
if (!scEvent ||
|
|
237
|
+
!state.initialized ||
|
|
238
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) ||
|
|
239
|
+
(state.isLoadingNext && !state.initialized)) {
|
|
232
240
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
233
241
|
}
|
|
242
|
+
if (state.initialized && state.count === 0 && !hasAllow) {
|
|
243
|
+
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
244
|
+
}
|
|
234
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: {
|
|
235
246
|
background: `url(${media.image}) no-repeat center`
|
|
236
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
|
|
@@ -99,7 +98,7 @@ function EventMembersWidget(inProps) {
|
|
|
99
98
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
100
99
|
});
|
|
101
100
|
}
|
|
102
|
-
}, [participants.isLoadingNext, participants.initialized, scEvent]);
|
|
101
|
+
}, [participants.isLoadingNext, participants.initialized, scEvent, dispatchParticipants, setParticipantsCount]);
|
|
103
102
|
const _initInvited = (0, react_1.useCallback)(() => {
|
|
104
103
|
if (!invited.initialized && !invited.isLoadingNext && hasAllow) {
|
|
105
104
|
dispatchInvited({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
@@ -113,7 +112,7 @@ function EventMembersWidget(inProps) {
|
|
|
113
112
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
|
-
}, [invited.isLoadingNext, invited.initialized,
|
|
115
|
+
}, [invited.isLoadingNext, invited.initialized, scEvent, dispatchInvited, setInvitedCount]);
|
|
117
116
|
const _initRequests = (0, react_1.useCallback)(() => {
|
|
118
117
|
if (!requests.initialized && !requests.isLoadingNext && hasAllow) {
|
|
119
118
|
dispatchRequests({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
@@ -128,7 +127,7 @@ function EventMembersWidget(inProps) {
|
|
|
128
127
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
129
128
|
});
|
|
130
129
|
}
|
|
131
|
-
}, [requests.isLoadingNext, requests.initialized,
|
|
130
|
+
}, [requests.isLoadingNext, requests.initialized, scEvent, dispatchRequests, setRequestsCount, setRequestsUsers]);
|
|
132
131
|
// EFFECTS
|
|
133
132
|
(0, react_1.useEffect)(() => {
|
|
134
133
|
let _t;
|
|
@@ -153,6 +152,13 @@ function EventMembersWidget(inProps) {
|
|
|
153
152
|
};
|
|
154
153
|
}
|
|
155
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]);
|
|
156
162
|
// HANDLERS
|
|
157
163
|
const handleTabChange = (0, react_1.useCallback)((_evt, newTabValue) => {
|
|
158
164
|
setTabValue(newTabValue);
|
|
@@ -166,13 +172,12 @@ function EventMembersWidget(inProps) {
|
|
|
166
172
|
}
|
|
167
173
|
setRefresh(_tabValue);
|
|
168
174
|
}, []);
|
|
169
|
-
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)) {
|
|
170
179
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
171
180
|
}
|
|
172
|
-
// RENDER
|
|
173
|
-
if (!scEvent) {
|
|
174
|
-
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
175
|
-
}
|
|
176
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: {
|
|
177
182
|
scEvent,
|
|
178
183
|
setCount: setInvitedCount
|
|
@@ -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
|
|
@@ -65,8 +65,7 @@ function Appearance(inProps) {
|
|
|
65
65
|
const { className, onCompleteAction } = props;
|
|
66
66
|
// STATE
|
|
67
67
|
const [state, dispatch] = (0, react_1.useReducer)(reducer_2.reducer, (0, reducer_2.getInitialState)(null));
|
|
68
|
-
|
|
69
|
-
const [loadingLogo, setLoadingLogo] = (0, react_1.useState)(false);
|
|
68
|
+
const [loadingLogo, setLoadingLogo] = (0, react_1.useState)('');
|
|
70
69
|
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
71
70
|
const [tab, setTab] = (0, react_1.useState)(0);
|
|
72
71
|
const [updating, setUpdating] = (0, react_1.useState)(false);
|
|
@@ -162,15 +161,13 @@ function Appearance(inProps) {
|
|
|
162
161
|
setUpdating(false);
|
|
163
162
|
}
|
|
164
163
|
});
|
|
165
|
-
const updateLogoPreference = (name) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
setLoadingLogo(
|
|
164
|
+
const updateLogoPreference = (name, file) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
setLoadingLogo(name);
|
|
167
166
|
const formData = new FormData();
|
|
168
|
-
|
|
169
|
-
// @ts-ignore
|
|
170
|
-
formData.append(name, fileInput);
|
|
167
|
+
formData.append(name, file);
|
|
171
168
|
yield api_services_1.PreferenceService.updatePreferences(formData)
|
|
172
169
|
.then((preference) => {
|
|
173
|
-
setLoadingLogo(
|
|
170
|
+
setLoadingLogo('');
|
|
174
171
|
dispatch({
|
|
175
172
|
type: reducer_1.actionTypes.SET_LOGOS,
|
|
176
173
|
payload: { logos: state.logos.map((l) => (l.name === name ? Object.assign(Object.assign({}, l), { value: preference[name].value }) : l)) }
|
|
@@ -178,7 +175,7 @@ function Appearance(inProps) {
|
|
|
178
175
|
onCompleteAction();
|
|
179
176
|
})
|
|
180
177
|
.catch((e) => {
|
|
181
|
-
setLoadingLogo(
|
|
178
|
+
setLoadingLogo('');
|
|
182
179
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
183
180
|
});
|
|
184
181
|
});
|
|
@@ -188,9 +185,9 @@ function Appearance(inProps) {
|
|
|
188
185
|
* @param name
|
|
189
186
|
*/
|
|
190
187
|
const handleUpload = (event, name) => {
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
updateLogoPreference(name);
|
|
188
|
+
const file = event.target.files[0];
|
|
189
|
+
if (file) {
|
|
190
|
+
updateLogoPreference(name, file);
|
|
194
191
|
}
|
|
195
192
|
};
|
|
196
193
|
(0, react_1.useEffect)(() => {
|
|
@@ -223,7 +220,7 @@ function Appearance(inProps) {
|
|
|
223
220
|
colorRef.current.blur();
|
|
224
221
|
}
|
|
225
222
|
};
|
|
226
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", className: classes.title, alignSelf: "self-start" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.appearance", defaultMessage: "ui.onBoardingWidget.appearance" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.summary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.summary", defaultMessage: "ui.onBoardingWidget.step.appearance.summary" }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", size: "small", color: "primary", onClick: handleOpen }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.button", defaultMessage: "ui.onBoardingWidget.step.appearance.button" }) })), (0, jsx_runtime_1.jsxs)(DrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "right", open: Boolean(anchorEl), onClose: handleClose }, { children: [(0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.drawerHeader }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", color: "primary" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.header.title", defaultMessage: "ui.onBoardingWidget.step.appearance.header.title" }) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: handleClose }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "close" }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ value: tab, onChange: handleTabChange, variant: "scrollable", scrollButtons: "auto", "aria-label": "scrollable-tabs" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.colors.title", defaultMessage: "ui.onBoardingWidget.step.appearance.colors.title" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.logo.title", defaultMessage: "ui.onBoardingWidget.step.appearance.logo.title" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.titleSlogan.title", defaultMessage: "ui.onBoardingWidget.step.appearance.titleSlogan.title" }) })] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, { children: (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.drawerContent }, { children: [tab === 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: state.colors.map((color) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6" }, { children: (0, onBoarding_1.formatColorLabel)(color) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.colorContainer }, { children: [(0, jsx_runtime_1.jsx)(mui_color_input_1.MuiColorInput, { inputRef: colorRef, className: classes.color, format: "hex", value: color.value, onChange: (newColor) => handleColorChange(newColor, color.name), isAlphaHidden: true, PopoverProps: { onClose: handleClosePopover } }), updatingColor && updatingColor === color.name && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { className: classes.colorProgress, color: "secondary", size: 24 }))] }))] }, color.id))) })), tab === 1 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: state.logos.map((logo) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6" }, { children: (0, onBoarding_1.formatLogoLabel)(logo.name) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.logoContainer }, { children: [(0, jsx_runtime_1.jsx)("img", { src: logo.value, className: classes.logo }), (0, jsx_runtime_1.jsx)("input", { type: "file", onChange: (event) => handleUpload(event, logo.name),
|
|
223
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", className: classes.title, alignSelf: "self-start" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.appearance", defaultMessage: "ui.onBoardingWidget.appearance" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.summary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.summary", defaultMessage: "ui.onBoardingWidget.step.appearance.summary" }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", size: "small", color: "primary", onClick: handleOpen }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.button", defaultMessage: "ui.onBoardingWidget.step.appearance.button" }) })), (0, jsx_runtime_1.jsxs)(DrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "right", open: Boolean(anchorEl), onClose: handleClose }, { children: [(0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.drawerHeader }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4", color: "primary" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.header.title", defaultMessage: "ui.onBoardingWidget.step.appearance.header.title" }) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: handleClose }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "close" }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ value: tab, onChange: handleTabChange, variant: "scrollable", scrollButtons: "auto", "aria-label": "scrollable-tabs" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.colors.title", defaultMessage: "ui.onBoardingWidget.step.appearance.colors.title" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.logo.title", defaultMessage: "ui.onBoardingWidget.step.appearance.logo.title" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.titleSlogan.title", defaultMessage: "ui.onBoardingWidget.step.appearance.titleSlogan.title" }) })] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, { children: (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.drawerContent }, { children: [tab === 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: state.colors.map((color) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6" }, { children: (0, onBoarding_1.formatColorLabel)(color) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.colorContainer }, { children: [(0, jsx_runtime_1.jsx)(mui_color_input_1.MuiColorInput, { inputRef: colorRef, className: classes.color, format: "hex", value: color.value, onChange: (newColor) => handleColorChange(newColor, color.name), isAlphaHidden: true, PopoverProps: { onClose: handleClosePopover } }), updatingColor && updatingColor === color.name && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { className: classes.colorProgress, color: "secondary", size: 24 }))] }))] }, color.id))) })), tab === 1 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: state.logos.map((logo) => ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6" }, { children: (0, onBoarding_1.formatLogoLabel)(logo.name) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.logoContainer }, { children: [(0, jsx_runtime_1.jsx)("img", { src: logo.value, className: classes.logo }), (0, jsx_runtime_1.jsx)("input", { type: "file", onChange: (event) => handleUpload(event, logo.name), hidden: true, accept: ".gif,.png,.jpg,.jpeg", id: logo.name }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ className: classes.uploadButton, onClick: () => document.getElementById(`${logo.name}`).click(), loading: Boolean(loadingLogo) && Boolean(logo.name === loadingLogo), disabled: Boolean(loadingLogo) && Boolean(logo.name !== loadingLogo) }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "upload" }) }))] }))] }, logo.id))) })), tab === 2 && ((0, jsx_runtime_1.jsxs)(Box_1.default, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, fullWidth: true,
|
|
227
224
|
//className={classes.field}
|
|
228
225
|
label: `${intl.formatMessage(messages.titleField)}`, margin: "normal", value: (_a = state === null || state === void 0 ? void 0 : state.slogans[0]) === null || _a === void 0 ? void 0 : _a.value, name: "application_slogan1", onChange: handleChange, InputProps: {
|
|
229
226
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_b = state.slogans[0].value) === null || _b === void 0 ? void 0 : _b.length) ? 50 - ((_c = state.slogans[0].value) === null || _c === void 0 ? void 0 : _c.length) : 50 }))
|
package/lib/cjs/utils/widget.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.actionWidgetTypes = {
|
|
|
18
18
|
LOAD_PREVIOUS_FAILURE: '_load_previous_failure',
|
|
19
19
|
SET_RESULTS: '_set_results',
|
|
20
20
|
SET_VISIBLE_ITEMS: '_set_visible_items',
|
|
21
|
+
INITIALIZE: '_initialize',
|
|
21
22
|
RESET: '_reset'
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
@@ -56,6 +57,19 @@ function dataWidgetReducer(state, action) {
|
|
|
56
57
|
case exports.actionWidgetTypes.RESET:
|
|
57
58
|
_state = { isLoadingNext: false, next: null, results: [], count: 0, errorLoadNext: null, initialized: false };
|
|
58
59
|
break;
|
|
60
|
+
case exports.actionWidgetTypes.INITIALIZE:
|
|
61
|
+
_state = {
|
|
62
|
+
cacheKey: action.payload.cacheKey ? action.payload.cacheKey : null,
|
|
63
|
+
count: action.payload.count ? action.payload.count : 0,
|
|
64
|
+
results: action.payload.results ? action.payload.results : [],
|
|
65
|
+
next: action.payload.next ? action.payload.next : null,
|
|
66
|
+
previous: action.payload.previous ? action.payload.previous : null,
|
|
67
|
+
isLoadingNext: action.payload.isLoadingNext ? action.payload.isLoadingNext : false,
|
|
68
|
+
isLoadingPrevious: action.payload.isLoadingPrevious ? action.payload.isLoadingPrevious : false,
|
|
69
|
+
visibleItems: action.payload.visibleItems ? action.payload.visibleItems : null,
|
|
70
|
+
initialized: false
|
|
71
|
+
};
|
|
72
|
+
break;
|
|
59
73
|
}
|
|
60
74
|
utils_1.LRUCache.set(_state.cacheKey, _state);
|
|
61
75
|
return _state;
|
|
@@ -106,7 +106,7 @@ export default function Event(inProps) {
|
|
|
106
106
|
});
|
|
107
107
|
const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = SCEventTemplateType.SNIPPET, hideInProgress = false, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = __rest(props, ["id", "eventId", "event", "className", "template", "hideInProgress", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
|
|
108
108
|
// STATE
|
|
109
|
-
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
109
|
+
const { scEvent } = useSCFetchEvent({ id: eventId, event, autoSubscribe: false });
|
|
110
110
|
const inProgress = useMemo(() => scEvent && scEvent.active && scEvent.running, [scEvent]);
|
|
111
111
|
// CONTEXT
|
|
112
112
|
const scRoutingContext = useSCRouting();
|
|
@@ -174,5 +174,5 @@ export default function EventHeader(inProps) {
|
|
|
174
174
|
month: 'long'
|
|
175
175
|
}),
|
|
176
176
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
177
|
-
} })) })), _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, eventId: scEvent.id, disabled: isEventFinished }), _jsxs(Box, { children: [!isMobile && (_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished })), _jsx(EventActionsMenu, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({
|
|
177
|
+
} })) })), _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, eventId: scEvent.id, disabled: isEventFinished }), _jsxs(Box, { children: [!isMobile && (_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished })), _jsx(EventActionsMenu, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({ eventId: scEvent.id, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), _jsx(EventActionsMenu, Object.assign({ eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })) }) })] }))] })));
|
|
178
178
|
}
|
|
@@ -6,7 +6,7 @@ import { styled } from '@mui/material/styles';
|
|
|
6
6
|
import { Box, useThemeProps } from '@mui/system';
|
|
7
7
|
import { Endpoints, EventService, http } from '@selfcommunity/api-services';
|
|
8
8
|
import { SCCache, useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
|
|
9
|
-
import { Logger } from '@selfcommunity/utils';
|
|
9
|
+
import { CacheStrategies, Logger } from '@selfcommunity/utils';
|
|
10
10
|
import { Fragment, useCallback, useEffect, useMemo, useReducer, useState } from 'react';
|
|
11
11
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
12
12
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
@@ -67,17 +67,22 @@ export default function EventMediaWidget(inProps) {
|
|
|
67
67
|
const { event, eventId, limit = DEFAULT_PAGINATION_LIMIT, endpointQueryParams = {
|
|
68
68
|
limit,
|
|
69
69
|
offset: DEFAULT_PAGINATION_OFFSET
|
|
70
|
-
}, cacheStrategy, dialogProps } = props, rest = __rest(props, ["event", "eventId", "limit", "endpointQueryParams", "cacheStrategy", "dialogProps"]);
|
|
70
|
+
}, cacheStrategy = CacheStrategies.CACHE_FIRST, dialogProps } = props, rest = __rest(props, ["event", "eventId", "limit", "endpointQueryParams", "cacheStrategy", "dialogProps"]);
|
|
71
|
+
// HOOKS
|
|
72
|
+
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
73
|
+
const intl = useIntl();
|
|
74
|
+
const theme = useTheme();
|
|
75
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
71
76
|
// STATE
|
|
72
77
|
const [state, dispatch] = useReducer(dataWidgetReducer, {
|
|
73
78
|
isLoadingNext: false,
|
|
74
79
|
next: null,
|
|
75
|
-
cacheKey: SCCache.getWidgetStateCacheKey(SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY),
|
|
80
|
+
cacheKey: SCCache.getWidgetStateCacheKey(SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY, event ? event.id : eventId),
|
|
76
81
|
cacheStrategy,
|
|
77
82
|
visibleItems: limit
|
|
78
83
|
}, stateWidgetInitializer);
|
|
79
|
-
const [medias, setMedias] = useState(
|
|
80
|
-
const [mediasCount, setMediasCount] = useState(
|
|
84
|
+
const [medias, setMedias] = useState(state.results);
|
|
85
|
+
const [mediasCount, setMediasCount] = useState(state.count);
|
|
81
86
|
const [openDialog, setOpenDialog] = useState(false);
|
|
82
87
|
const [openDialogConfirm, setOpenDialogConfirm] = useState(false);
|
|
83
88
|
const [mediaId, setMediaId] = useState(null);
|
|
@@ -86,33 +91,9 @@ export default function EventMediaWidget(inProps) {
|
|
|
86
91
|
const [showSkeleton, setShowSkeleton] = useState(null);
|
|
87
92
|
// CONTEXT
|
|
88
93
|
const scUserContext = useSCUser();
|
|
89
|
-
// HOOKS
|
|
90
|
-
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
91
|
-
const intl = useIntl();
|
|
92
|
-
const theme = useTheme();
|
|
93
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
94
94
|
// CONSTS
|
|
95
95
|
const hasAllow = 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]);
|
|
96
96
|
const countHiddenMedia = useMemo(() => mediasCount - MEDIAS_TO_SHOW, [mediasCount]);
|
|
97
|
-
/**
|
|
98
|
-
* Initialize component
|
|
99
|
-
* Fetch data only if the component is not initialized and it is not loading data
|
|
100
|
-
*/
|
|
101
|
-
const _initComponent = useCallback(() => {
|
|
102
|
-
if (!state.initialized && !state.isLoadingNext) {
|
|
103
|
-
dispatch({ type: actionWidgetTypes.LOADING_NEXT });
|
|
104
|
-
EventService.getEventPhotoGallery(scEvent.id, Object.assign({}, endpointQueryParams))
|
|
105
|
-
.then((payload) => {
|
|
106
|
-
dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
|
|
107
|
-
setMedias(payload.results);
|
|
108
|
-
setMediasCount(payload.count);
|
|
109
|
-
})
|
|
110
|
-
.catch((error) => {
|
|
111
|
-
dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
112
|
-
Logger.error(SCOPE_SC_UI, error);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}, [state.isLoadingNext, state.initialized, scEvent, dispatch, setMedias, setMediasCount]);
|
|
116
97
|
const _fetchNext = useCallback((index) => {
|
|
117
98
|
if (mediasCount > medias.length && index >= 6 && !state.isLoadingNext && state.next) {
|
|
118
99
|
setPreview(index);
|
|
@@ -210,25 +191,55 @@ export default function EventMediaWidget(inProps) {
|
|
|
210
191
|
// EFFECTS
|
|
211
192
|
useEffect(() => {
|
|
212
193
|
let _t;
|
|
213
|
-
if (scUserContext.user &&
|
|
194
|
+
if (scUserContext.user &&
|
|
195
|
+
scEvent &&
|
|
196
|
+
!state.initialized &&
|
|
197
|
+
Boolean((eventId !== undefined && scEvent.id === eventId) || (event && scEvent.id === event.id))) {
|
|
214
198
|
_t = setTimeout(_initComponent);
|
|
215
199
|
return () => {
|
|
216
200
|
clearTimeout(_t);
|
|
217
201
|
};
|
|
218
202
|
}
|
|
219
|
-
}, [scUserContext.user, scEvent]);
|
|
203
|
+
}, [scUserContext.user, scEvent, state.initialized]);
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
if (state.initialized && scEvent && Boolean((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) {
|
|
206
|
+
dispatch({ type: actionWidgetTypes.RESET, payload: {} });
|
|
207
|
+
}
|
|
208
|
+
}, [state.initialized, scEvent, eventId, event]);
|
|
209
|
+
/**
|
|
210
|
+
* Initialize component
|
|
211
|
+
* Fetch data only if the component is not initialized and it is not loading data
|
|
212
|
+
*/
|
|
213
|
+
const _initComponent = useCallback(() => {
|
|
214
|
+
if (!state.isLoadingNext) {
|
|
215
|
+
dispatch({ type: actionWidgetTypes.LOADING_NEXT });
|
|
216
|
+
EventService.getEventPhotoGallery(scEvent.id, Object.assign({}, endpointQueryParams))
|
|
217
|
+
.then((payload) => {
|
|
218
|
+
dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
|
|
219
|
+
setMedias(payload.results);
|
|
220
|
+
setMediasCount(payload.count);
|
|
221
|
+
})
|
|
222
|
+
.catch((error) => {
|
|
223
|
+
dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
224
|
+
Logger.error(SCOPE_SC_UI, error);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}, [state.isLoadingNext, scEvent, eventId, dispatch, setMedias, setMediasCount]);
|
|
220
228
|
useEffect(() => {
|
|
221
229
|
if (isMobile && openDialog && state.next) {
|
|
222
230
|
handleNext();
|
|
223
231
|
}
|
|
224
232
|
}, [isMobile, openDialog, state.next]);
|
|
225
233
|
// RENDER
|
|
226
|
-
if (!scEvent ||
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
if (!scEvent ||
|
|
235
|
+
!state.initialized ||
|
|
236
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) ||
|
|
237
|
+
(state.isLoadingNext && !state.initialized)) {
|
|
230
238
|
return _jsx(SkeletonComponent, {});
|
|
231
239
|
}
|
|
240
|
+
if (state.initialized && state.count === 0 && !hasAllow) {
|
|
241
|
+
return _jsx(HiddenPlaceholder, {});
|
|
242
|
+
}
|
|
232
243
|
return (_jsxs(Root, Object.assign({ className: classes.root }, rest, { showPadding: hasAllow }, { children: [_jsx(CardHeader, { title: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center" }, { children: [_jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.eventMediaWidget.title", defaultMessage: "ui.eventMediaWidget.title" }) })), hasAllow && mediasCount > 0 && _jsx(TriggerButton, { size: "small", onAdd: handleAddMedia })] })), className: classes.header }), _jsx(Divider, {}), _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Box, Object.assign({ className: classes.grid }, { children: [showSkeleton === 'widget' && _jsx(EventMediaSkeleton, {}), medias.slice(0, MEDIAS_TO_SHOW).map((media, i, array) => (_jsx(Box, Object.assign({ onClick: () => handleOpenLightbox(i), sx: {
|
|
233
244
|
background: `url(${media.image}) no-repeat center`
|
|
234
245
|
}, className: classes.media }, { children: medias.length > array.length && i === array.length - 1 && (_jsxs(Fragment, { children: [_jsx(Box, { className: classes.mediaLayer }), _jsx(Box, Object.assign({ className: classes.countHiddenMediaWrapper }, { children: _jsxs(Typography, Object.assign({ className: classes.countHiddenMedia }, { children: ["+", countHiddenMedia] })) }))] })) }), media.id))), hasAllow && mediasCount === 0 && (_jsx(Tooltip, Object.assign({ title: _jsx(FormattedMessage, { id: "ui.eventMediaWidget.add", defaultMessage: "ui.eventMediaWidget.add" }) }, { children: _jsx(TriggerButton, { size: "large", onAdd: handleAddMedia, isSquare: true }) })))] })), preview !== -1 && _jsx(Lightbox, { onClose: handleCloseLightbox, index: preview, medias: medias, onIndexChange: _fetchNext })] })), hasAllow && mediasCount > 0 && (_jsx(CardActions, Object.assign({ className: classes.actions }, { children: _jsx(Button, Object.assign({ onClick: handleToggleDialogOpen }, { children: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.eventMediaWidget.showAll", defaultMessage: "ui.eventMediaWidget.showAll" }) })) })) }))), openDialog && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: intl.formatMessage(messages.title, { user: scEvent.managed_by.username }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: medias.length, height: isMobile ? '100%' : '515px', next: handleNext, hasMoreNext: Boolean(state.next), className: classes.dialogInfiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventMediaWidget.noMoreResults", defaultMessage: "ui.eventMediaWidget.noMoreResults" }) })) }, { children: _jsxs(Box, Object.assign({ className: classes.grid }, { children: [medias.map((media) => (_jsx(Box, Object.assign({ sx: {
|