@selfcommunity/react-ui 0.8.0-alpha.1 → 0.8.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.
Files changed (56) hide show
  1. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +11 -2
  2. package/lib/cjs/components/Composer/Composer.js +8 -2
  3. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +12 -3
  4. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +5 -1
  5. package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +5 -1
  6. package/lib/cjs/components/EventForm/EventAddress.d.ts +3 -8
  7. package/lib/cjs/components/EventForm/EventAddress.js +20 -20
  8. package/lib/cjs/components/EventForm/EventForm.d.ts +1 -1
  9. package/lib/cjs/components/EventForm/EventForm.js +90 -76
  10. package/lib/cjs/components/EventForm/constants.d.ts +4 -0
  11. package/lib/cjs/components/EventForm/constants.js +5 -1
  12. package/lib/cjs/components/EventForm/types.d.ts +27 -0
  13. package/lib/cjs/components/EventForm/types.js +2 -0
  14. package/lib/cjs/components/EventForm/utils.d.ts +4 -0
  15. package/lib/cjs/components/EventForm/utils.js +28 -0
  16. package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
  17. package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +24 -1
  18. package/lib/cjs/components/Events/Events.js +10 -5
  19. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +34 -2
  20. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +12 -3
  21. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
  22. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +23 -15
  23. package/lib/cjs/components/SuggestedEventsWidget/SuggestedEventsWidget.js +26 -0
  24. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +7 -2
  25. package/lib/cjs/shared/EventActionsMenu/index.d.ts +4 -0
  26. package/lib/cjs/shared/EventActionsMenu/index.js +13 -3
  27. package/lib/cjs/shared/Media/Link/DisplayComponent.js +21 -5
  28. package/lib/esm/components/BottomNavigation/BottomNavigation.js +11 -2
  29. package/lib/esm/components/Composer/Composer.js +8 -2
  30. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +13 -4
  31. package/lib/esm/components/CreateEventButton/CreateEventButton.js +5 -1
  32. package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +5 -1
  33. package/lib/esm/components/EventForm/EventAddress.d.ts +3 -8
  34. package/lib/esm/components/EventForm/EventAddress.js +20 -20
  35. package/lib/esm/components/EventForm/EventForm.d.ts +1 -1
  36. package/lib/esm/components/EventForm/EventForm.js +92 -78
  37. package/lib/esm/components/EventForm/constants.d.ts +4 -0
  38. package/lib/esm/components/EventForm/constants.js +4 -0
  39. package/lib/esm/components/EventForm/types.d.ts +27 -0
  40. package/lib/esm/components/EventForm/types.js +1 -0
  41. package/lib/esm/components/EventForm/utils.d.ts +4 -0
  42. package/lib/esm/components/EventForm/utils.js +21 -0
  43. package/lib/esm/components/EventHeader/EventHeader.js +1 -1
  44. package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +25 -2
  45. package/lib/esm/components/Events/Events.js +10 -5
  46. package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +36 -4
  47. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +12 -3
  48. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
  49. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +24 -16
  50. package/lib/esm/components/SuggestedEventsWidget/SuggestedEventsWidget.js +27 -1
  51. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +8 -3
  52. package/lib/esm/shared/EventActionsMenu/index.d.ts +4 -0
  53. package/lib/esm/shared/EventActionsMenu/index.js +13 -3
  54. package/lib/esm/shared/Media/Link/DisplayComponent.js +21 -5
  55. package/lib/umd/react-ui.js +1 -1
  56. package/package.json +6 -6
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.combineDateAndTime = exports.getLaterDaysDate = exports.getLaterHoursDate = exports.getNewDate = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ function getNewDate(date) {
6
+ if (date) {
7
+ return new Date(date);
8
+ }
9
+ return new Date();
10
+ }
11
+ exports.getNewDate = getNewDate;
12
+ function getLaterHoursDate(h) {
13
+ return (0, date_fns_1.addHours)(getNewDate(), h);
14
+ }
15
+ exports.getLaterHoursDate = getLaterHoursDate;
16
+ function getLaterDaysDate(d) {
17
+ return (0, date_fns_1.addDays)(getNewDate(), d);
18
+ }
19
+ exports.getLaterDaysDate = getLaterDaysDate;
20
+ const combineDateAndTime = (date, time) => {
21
+ const combined = date;
22
+ combined.setHours(time.getHours());
23
+ combined.setMinutes(time.getMinutes());
24
+ combined.setSeconds(time.getSeconds());
25
+ combined.setMilliseconds(time.getMilliseconds());
26
+ return combined.toISOString();
27
+ };
28
+ exports.combineDateAndTime = combineDateAndTime;
@@ -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: [(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 }, 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 }, EventActionsProps))] })) }) })] }))] })));
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({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })) }) })] }))] })));
180
180
  }
181
181
  exports.default = EventHeader;
@@ -12,6 +12,8 @@ const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/Hidden
12
12
  const Widget_1 = tslib_1.__importDefault(require("../Widget"));
13
13
  const constants_1 = require("./constants");
14
14
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
15
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
16
+ const PubSub_1 = require("../../constants/PubSub");
15
17
  const classes = {
16
18
  root: `${constants_1.PREFIX}-root`,
17
19
  content: `${constants_1.PREFIX}-content`,
@@ -45,7 +47,9 @@ function EventInfoWidget(inProps) {
45
47
  const [showButton, setShowButton] = (0, react_1.useState)(!summaryExpanded);
46
48
  const [loading, setLoading] = (0, react_1.useState)(true);
47
49
  // HOOKS
48
- const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
50
+ const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
51
+ // REFS
52
+ const updatesSubscription = (0, react_1.useRef)(null);
49
53
  (0, react_1.useEffect)(() => {
50
54
  setLoading(false);
51
55
  }, []);
@@ -67,6 +71,25 @@ function EventInfoWidget(inProps) {
67
71
  const showInfo = (0, react_1.useMemo)(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === types_1.SCEventPrivacyType.PUBLIC ||
68
72
  [types_1.SCEventSubscriptionStatusType.SUBSCRIBED, types_1.SCEventSubscriptionStatusType.GOING, types_1.SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
69
73
  const description = (0, react_1.useMemo)(() => (expanded ? scEvent === null || scEvent === void 0 ? void 0 : scEvent.description : getTruncatedText(scEvent === null || scEvent === void 0 ? void 0 : scEvent.description, 220)), [expanded, scEvent]);
74
+ /**
75
+ * Subscriber for pubsub callback
76
+ */
77
+ const onChangeGroupHandler = (0, react_1.useCallback)((_msg, data) => {
78
+ if (data && scEvent.id === data.id) {
79
+ setSCEvent(data);
80
+ }
81
+ }, [scEvent, setSCEvent]);
82
+ /**
83
+ * On mount, subscribe to receive groups updates (only edit)
84
+ */
85
+ (0, react_1.useEffect)(() => {
86
+ if (scEvent) {
87
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.EDIT}`, onChangeGroupHandler);
88
+ }
89
+ return () => {
90
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
91
+ };
92
+ }, [scEvent]);
70
93
  // RENDER
71
94
  if (!scEvent && loading) {
72
95
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
@@ -154,7 +154,12 @@ function Events(inProps) {
154
154
  * Subscriber for pubsub callback
155
155
  */
156
156
  const onDeleteEventHandler = (0, react_1.useCallback)((_msg, deleted) => {
157
- setEvents((prev) => prev.filter((e) => e.id !== deleted));
157
+ setEvents((prev) => {
158
+ if (prev.some((e) => e.id === deleted)) {
159
+ return prev.filter((e) => e.id !== deleted);
160
+ }
161
+ return prev;
162
+ });
158
163
  }, [events]);
159
164
  /**
160
165
  * On mount, subscribe to receive event updates (only delete)
@@ -212,14 +217,14 @@ function Events(inProps) {
212
217
  variant: showMyEvents ? 'filled' : 'outlined', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
213
218
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
214
219
  // @ts-ignore
215
- showFollowed: showMyEvents, deleteIcon: showMyEvents ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) })))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading, onKeyUp: (e) => {
220
+ showFollowed: showMyEvents, deleteIcon: showMyEvents ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) })))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading || (!events.length && !query), onKeyUp: (e) => {
216
221
  e.preventDefault();
217
222
  if (e.key === 'Enter') {
218
223
  fetchEvents(true);
219
224
  }
220
225
  }, InputProps: {
221
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }) }))) : ((0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }), disabled: loading })) })))
222
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ disabled: showPastEvents || loading, size: 'small', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: option.value }, { children: [(0, jsx_runtime_1.jsx)(material_1.Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), authUserId && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
226
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading || (!events.length && !query) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }) }))) : ((0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }), disabled: loading || (!events.length && !query) })) })))
227
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ disabled: showPastEvents || loading || (!events.length && dateSearch === types_1.SCEventDateFilterType.ANY), size: 'small', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: option.value }, { children: [(0, jsx_runtime_1.jsx)(material_1.Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), authUserId && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
223
228
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
224
229
  // @ts-ignore
225
230
  , {
@@ -231,7 +236,7 @@ function Events(inProps) {
231
236
  variant: showFollowed ? 'filled' : 'outlined', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByFollowedInterest", defaultMessage: "ui.events.filterByFollowedInterest" }), onClick: handleChipClick,
232
237
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
233
238
  // @ts-ignore
234
- showFollowed: showFollowed, deleteIcon: showFollowed ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading }) }))), (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 }) }))] })) }))), (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)) ||
239
+ 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)) ||
235
240
  (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" }) })))] })) })) })] }));
236
241
  /**
237
242
  * Renders root object (if content availability community option is false and user is anonymous, component is hidden)
@@ -20,6 +20,8 @@ const Event_1 = tslib_1.__importDefault(require("../Event"));
20
20
  const Widget_1 = tslib_1.__importDefault(require("../Widget"));
21
21
  const constants_1 = require("./constants");
22
22
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
23
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
24
+ const PubSub_1 = require("../../constants/PubSub");
23
25
  const classes = {
24
26
  root: `${constants_1.PREFIX}-root`,
25
27
  titleWrapper: `${constants_1.PREFIX}-title-wrapper`,
@@ -64,8 +66,14 @@ function MyEventsWidget(inProps) {
64
66
  // CONTEXT
65
67
  const scUserContext = (0, react_core_1.useSCUser)();
66
68
  const scRoutingContext = (0, react_core_1.useSCRouting)();
67
- const { features } = (0, react_core_1.useSCPreferences)();
68
- const eventsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.EVENT) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
69
+ const { preferences, features } = (0, react_core_1.useSCPreferences)();
70
+ const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
71
+ features &&
72
+ features.includes(types_1.SCFeatureName.TAGGING) &&
73
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
74
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
75
+ // REFS
76
+ const updatesSubscription = (0, react_1.useRef)(null);
69
77
  /**
70
78
  * Initialize component
71
79
  * Fetch data only if the component is not initialized and it is not loading data
@@ -120,6 +128,30 @@ function MyEventsWidget(inProps) {
120
128
  _fetchNext();
121
129
  }
122
130
  }, [eventIndex, state.results]);
131
+ /**
132
+ * Subscriber for pubsub callback
133
+ */
134
+ const onDeleteEventHandler = (0, react_1.useCallback)((_msg, deleted) => {
135
+ const _events = [...state.results];
136
+ if (_events.some((e) => e.id === deleted)) {
137
+ const updatedEvents = _events.filter((e) => e.id !== deleted);
138
+ dispatch({
139
+ type: widget_1.actionWidgetTypes.SET_RESULTS,
140
+ payload: { results: updatedEvents }
141
+ });
142
+ }
143
+ }, [state.results]);
144
+ /**
145
+ * On mount, subscribe to receive event updates (only delete)
146
+ */
147
+ (0, react_1.useEffect)(() => {
148
+ if (state.results) {
149
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.DELETE}`, onDeleteEventHandler);
150
+ }
151
+ return () => {
152
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
153
+ };
154
+ }, [state.results]);
123
155
  // RENDER
124
156
  if (!eventsEnabled || (state.initialized && state.count === 0)) {
125
157
  return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
@@ -110,12 +110,21 @@ function NavigationToolbar(inProps) {
110
110
  return _preferences;
111
111
  }, [scPreferences.preferences]);
112
112
  const privateMessagingEnabled = (0, react_1.useMemo)(() => scPreferences.features.includes(types_1.SCFeatureName.PRIVATE_MESSAGING), [scPreferences.features]);
113
- const groupsEnabled = (0, react_1.useMemo)(() => scPreferences.features && scPreferences.features.includes(types_1.SCFeatureName.GROUPING) && scPreferences.features.includes(types_1.SCFeatureName.TAGGING), [scPreferences.features]);
114
- const eventsEnabled = (0, react_1.useMemo)(() => scPreferences.features && scPreferences.features.includes(types_1.SCFeatureName.EVENT) && scPreferences.features.includes(types_1.SCFeatureName.TAGGING), [scPreferences.features]);
113
+ const groupsEnabled = (0, react_1.useMemo)(() => scPreferences.preferences &&
114
+ scPreferences.features &&
115
+ scPreferences.features.includes(types_1.SCFeatureName.TAGGING) &&
116
+ scPreferences.features.includes(types_1.SCFeatureName.GROUPING) &&
117
+ react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in scPreferences.preferences &&
118
+ scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
119
+ const eventsEnabled = (0, react_1.useMemo)(() => scPreferences.preferences &&
120
+ scPreferences.features &&
121
+ scPreferences.features.includes(types_1.SCFeatureName.TAGGING) &&
122
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
123
+ scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
115
124
  const showComposer = (0, react_1.useMemo)(() => {
116
125
  return (!disableComposer &&
117
126
  (!scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value || react_core_1.UserUtils.isStaff(scUserContext.user)));
118
- }, [scPreferences, disableComposer, scUserContext.user]);
127
+ }, [preferences, disableComposer, scUserContext.user]);
119
128
  // STATE
120
129
  const [anchorNotification, setAnchorNotification] = react_1.default.useState(null);
121
130
  // HANDLERS
@@ -80,8 +80,17 @@ function NavigationToolbarMobile(inProps) {
80
80
  // STATE
81
81
  const [searchOpen, setSearchOpen] = (0, react_1.useState)(false);
82
82
  // MEMO
83
- const groupsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.GROUPING) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
84
- const eventsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.EVENT) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
83
+ const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
84
+ features &&
85
+ features.includes(types_1.SCFeatureName.TAGGING) &&
86
+ features.includes(types_1.SCFeatureName.GROUPING) &&
87
+ react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
88
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
89
+ const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
90
+ features &&
91
+ features.includes(types_1.SCFeatureName.TAGGING) &&
92
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
93
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
85
94
  const exploreStreamEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
86
95
  const postOnlyStaffEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
87
96
  const contentAvailable = preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
@@ -26,6 +26,7 @@ const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
26
26
  const notistack_1 = require("notistack");
27
27
  const constants_2 = require("../PlatformWidget/constants");
28
28
  const header_1 = tslib_1.__importDefault(require("../../assets/onBoarding/header"));
29
+ const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
29
30
  const classes = {
30
31
  root: `${constants_1.PREFIX}-root`,
31
32
  content: `${constants_1.PREFIX}-content`,
@@ -54,7 +55,7 @@ const OnBoardingWidget = (inProps) => {
54
55
  });
55
56
  const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange } = props, rest = tslib_1.__rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange"]);
56
57
  // STATE
57
- const [isLoading, setIsLoading] = (0, react_1.useState)(true);
58
+ const [loading, setLoading] = (0, react_1.useState)(true);
58
59
  const [initialized, setInitialized] = (0, react_1.useState)(false);
59
60
  const [steps, setSteps] = (0, react_1.useState)([]);
60
61
  const nextStep = (0, react_1.useMemo)(() => {
@@ -70,6 +71,7 @@ const OnBoardingWidget = (inProps) => {
70
71
  const prevContentsStep = (0, react_core_1.usePreviousValue)(currentContentsStep);
71
72
  const currentCategoriesStep = steps === null || steps === void 0 ? void 0 : steps.find((s) => s.step === types_1.SCOnBoardingStepType.CATEGORIES);
72
73
  const prevCategoriesStep = (0, react_core_1.usePreviousValue)(currentCategoriesStep);
74
+ const [showCategoriesModal, setShowCategoriesModal] = (0, react_1.useState)(false);
73
75
  // CONTEXT
74
76
  const scUserContext = (0, react_core_1.useSCUser)();
75
77
  const isAdmin = (0, react_1.useMemo)(() => react_core_1.UserUtils.isCommunityCreator(scUserContext.user), [scUserContext.user]);
@@ -82,6 +84,7 @@ const OnBoardingWidget = (inProps) => {
82
84
  // HOOKS
83
85
  const theme = (0, material_1.useTheme)();
84
86
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
87
+ const { categories, isLoading } = (0, react_core_1.useSCFetchCategories)();
85
88
  // HANDLERS
86
89
  const completeStep = (s) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
87
90
  if (s.status !== types_1.SCOnBoardingStepStatusType.COMPLETED) {
@@ -114,14 +117,14 @@ const OnBoardingWidget = (inProps) => {
114
117
  const contentStep = res.results.find((step) => step.step === types_1.SCOnBoardingStepType.CONTENTS);
115
118
  setIsGenerating(res.results.some((step) => step.status === 'in_progress'));
116
119
  setSteps(res.results);
117
- setIsLoading(false);
120
+ setLoading(false);
118
121
  if (contentStep.status === types_1.SCOnBoardingStepStatusType.IN_PROGRESS && contentStep.results.length !== 0 && onGeneratedContent) {
119
122
  onGeneratedContent(contentStep.results);
120
123
  }
121
124
  })
122
125
  .catch((error) => {
123
126
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
124
- setIsLoading(false);
127
+ setLoading(false);
125
128
  });
126
129
  });
127
130
  const handleChange = (newStep) => {
@@ -132,17 +135,22 @@ const OnBoardingWidget = (inProps) => {
132
135
  onHeightChange && onHeightChange();
133
136
  };
134
137
  const generateContent = (stepId) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
135
- yield api_services_1.OnBoardingService.startAStep(stepId, GenerateContentsParams)
136
- .then(() => {
137
- setIsGenerating(true);
138
- })
139
- .catch((error) => {
140
- utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
141
- enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
142
- variant: 'error',
143
- autoHideDuration: 3000
138
+ if (!isLoading && !categories.length) {
139
+ setShowCategoriesModal(true);
140
+ }
141
+ else {
142
+ yield api_services_1.OnBoardingService.startAStep(stepId, GenerateContentsParams)
143
+ .then(() => {
144
+ setIsGenerating(true);
145
+ })
146
+ .catch((error) => {
147
+ utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
148
+ enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
149
+ variant: 'error',
150
+ autoHideDuration: 3000
151
+ });
144
152
  });
145
- });
153
+ }
146
154
  });
147
155
  const handlePreferencesUpdate = () => {
148
156
  api_services_1.PreferenceService.getAllPreferences().then((preferences) => {
@@ -154,7 +162,7 @@ const OnBoardingWidget = (inProps) => {
154
162
  // EFFECTS
155
163
  (0, react_1.useEffect)(() => {
156
164
  if (prevContentsStep &&
157
- prevCategoriesStep.status === types_1.SCOnBoardingStepStatusType.IN_PROGRESS &&
165
+ prevContentsStep.status === types_1.SCOnBoardingStepStatusType.IN_PROGRESS &&
158
166
  (currentContentsStep === null || currentContentsStep === void 0 ? void 0 : currentContentsStep.status) === types_1.SCOnBoardingStepStatusType.COMPLETED) {
159
167
  showSuccessAlert(currentContentsStep);
160
168
  }
@@ -235,6 +243,6 @@ const OnBoardingWidget = (inProps) => {
235
243
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
236
244
  // @ts-ignore
237
245
  icon: (...chunks) => ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "secondary", fontSize: "medium" }, { children: chunks })))
238
- } }) }))) }) })), (0, jsx_runtime_1.jsx)(material_1.AccordionDetails, { children: (0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ className: classes.content, elevation: 0 }, { children: isLoading ? ((0, jsx_runtime_1.jsx)(Skeleton_1.default, {})) : ((0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: isMobile ? classes.stepsMobile : classes.steps }, { children: steps === null || steps === void 0 ? void 0 : steps.map((step) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: isMobile ? ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", label: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }), ' ', step.status === types_1.SCOnBoardingStepStatusType.COMPLETED && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: (step === null || step === void 0 ? void 0 : step.status) === types_1.SCOnBoardingStepStatusType.COMPLETED && (step === null || step === void 0 ? void 0 : step.step) !== (_step === null || _step === void 0 ? void 0 : _step.step) ? 'success' : 'inherit' }, { children: "check" })))] }), onClick: () => handleChange(step), variant: step.step === (_step === null || _step === void 0 ? void 0 : _step.step) ? 'filled' : 'outlined', color: step.status === types_1.SCOnBoardingStepStatusType.COMPLETED ? 'success' : 'default' })) : ((0, jsx_runtime_1.jsxs)(material_1.ListItemButton, Object.assign({ onClick: () => handleChange(step), selected: (step === null || step === void 0 ? void 0 : step.step) === (_step === null || _step === void 0 ? void 0 : _step.step) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { edge: "start", checked: step.status === types_1.SCOnBoardingStepStatusType.COMPLETED, tabIndex: -1, disableRipple: true, inputProps: { 'aria-labelledby': step.step }, size: 'small' }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }) })] }))) }, step.id))) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.stepContent }, { children: (0, jsx_runtime_1.jsx)(material_1.Fade, Object.assign({ in: true, timeout: 2400 }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { children: getStepContent() }) })) }))] })) })) })] })) })));
246
+ } }) }))) }) })), (0, jsx_runtime_1.jsx)(material_1.AccordionDetails, { children: (0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ className: classes.content, elevation: 0 }, { children: loading ? ((0, jsx_runtime_1.jsx)(Skeleton_1.default, {})) : ((0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: isMobile ? classes.stepsMobile : classes.steps }, { children: steps === null || steps === void 0 ? void 0 : steps.map((step) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: isMobile ? ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", label: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }), ' ', step.status === types_1.SCOnBoardingStepStatusType.COMPLETED && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: (step === null || step === void 0 ? void 0 : step.status) === types_1.SCOnBoardingStepStatusType.COMPLETED && (step === null || step === void 0 ? void 0 : step.step) !== (_step === null || _step === void 0 ? void 0 : _step.step) ? 'success' : 'inherit' }, { children: "check" })))] }), onClick: () => handleChange(step), variant: step.step === (_step === null || _step === void 0 ? void 0 : _step.step) ? 'filled' : 'outlined', color: step.status === types_1.SCOnBoardingStepStatusType.COMPLETED ? 'success' : 'default' })) : ((0, jsx_runtime_1.jsxs)(material_1.ListItemButton, Object.assign({ onClick: () => handleChange(step), selected: (step === null || step === void 0 ? void 0 : step.step) === (_step === null || _step === void 0 ? void 0 : _step.step) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { edge: "start", checked: step.status === types_1.SCOnBoardingStepStatusType.COMPLETED, tabIndex: -1, disableRipple: true, inputProps: { 'aria-labelledby': step.step }, size: 'small' }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }) })] }))) }, step.id))) })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.stepContent }, { children: [(0, jsx_runtime_1.jsx)(material_1.Fade, Object.assign({ in: true, timeout: 2400 }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { children: getStepContent() }) })), showCategoriesModal && ((0, jsx_runtime_1.jsx)(BaseDialog_1.default, Object.assign({ title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories", defaultMessage: "ui.onBoardingWidget.ai.no.categories" }), DialogContentProps: { dividers: false }, open: showCategoriesModal, onClose: () => setShowCategoriesModal(false), actions: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", onClick: () => setShowCategoriesModal(false) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.cancel", defaultMessage: "ui.onBoardingWidget.ai.no.categories.cancel" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "primary", href: isStage ? constants_2.CONSOLE_STAGE : constants_2.CONSOLE_PROD, onClick: () => setShowCategoriesModal(false), target: "_blank", startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "edit" })) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.link", defaultMessage: "ui.onBoardingWidget.ai.no.categories.link" }) })) })))] }))] })) })) })] })) })));
239
247
  };
240
248
  exports.default = OnBoardingWidget;
@@ -20,6 +20,8 @@ const Widget_1 = tslib_1.__importDefault(require("../Widget"));
20
20
  const Arrow_1 = tslib_1.__importDefault(require("./Arrow"));
21
21
  const constants_1 = require("./constants");
22
22
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
23
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
24
+ const PubSub_1 = require("../../constants/PubSub");
23
25
  const classes = {
24
26
  root: `${constants_1.PREFIX}-root`,
25
27
  content: `${constants_1.PREFIX}-content`,
@@ -58,6 +60,8 @@ function SuggestedEventsWidget(inProps) {
58
60
  const scRoutingContext = (0, react_core_1.useSCRouting)();
59
61
  //HOOKS
60
62
  const theme = (0, material_1.useTheme)();
63
+ // REFS
64
+ const updatesSubscription = (0, react_1.useRef)(null);
61
65
  (0, react_1.useEffect)(() => {
62
66
  api_services_1.SuggestionService.getEventSuggestion(Object.assign({}, endpointQueryParams))
63
67
  .then((payload) => {
@@ -106,6 +110,28 @@ function SuggestedEventsWidget(inProps) {
106
110
  }
107
111
  }
108
112
  }, [count, hideMarginLeft, hideMarginRight]);
113
+ /**
114
+ * Subscriber for pubsub callback
115
+ */
116
+ const onDeleteEventHandler = (0, react_1.useCallback)((_msg, deleted) => {
117
+ setEvents((prev) => {
118
+ if (prev.some((e) => e.id === deleted)) {
119
+ return prev.filter((e) => e.id !== deleted);
120
+ }
121
+ return prev;
122
+ });
123
+ }, [events]);
124
+ /**
125
+ * On mount, subscribe to receive event updates (only delete)
126
+ */
127
+ (0, react_1.useEffect)(() => {
128
+ if (events) {
129
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.DELETE}`, onDeleteEventHandler);
130
+ }
131
+ return () => {
132
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
133
+ };
134
+ }, [events]);
109
135
  // RENDER
110
136
  if (!events && loading) {
111
137
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
@@ -73,8 +73,13 @@ function UserSubscribedGroupsWidget(inProps) {
73
73
  // CONTEXT
74
74
  const scUserContext = (0, react_core_1.useSCUser)();
75
75
  const isMe = (0, react_1.useMemo)(() => scUserContext.user && userId === scUserContext.user.id, [scUserContext.user, userId]);
76
- const { features } = (0, react_core_1.useSCPreferences)();
77
- const groupsEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.GROUPING) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
76
+ const { preferences, features } = (0, react_core_1.useSCPreferences)();
77
+ const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
78
+ features &&
79
+ features.includes(types_1.SCFeatureName.TAGGING) &&
80
+ features.includes(types_1.SCFeatureName.GROUPING) &&
81
+ react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
82
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
78
83
  // STATE
79
84
  const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
80
85
  isLoadingNext: false,
@@ -18,6 +18,10 @@ export interface EventActionsMenuProps extends IconButtonProps {
18
18
  * Handles callback on delete confirm
19
19
  */
20
20
  onDeleteConfirm?: () => void;
21
+ /**
22
+ * Handles on edit success
23
+ */
24
+ onEditSuccess?: (data: SCEventType) => any;
21
25
  /**
22
26
  * Any other properties
23
27
  */
@@ -17,6 +17,7 @@ const utils_1 = require("@selfcommunity/utils");
17
17
  const notistack_1 = require("notistack");
18
18
  const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
19
19
  const PubSub_1 = require("../../constants/PubSub");
20
+ const EventForm_1 = tslib_1.__importDefault(require("../../components/EventForm"));
20
21
  const PREFIX = 'SCEventActionsMenu';
21
22
  const classes = {
22
23
  root: `${PREFIX}-root`,
@@ -71,16 +72,17 @@ function EventActionsMenu(inProps) {
71
72
  props: inProps,
72
73
  name: PREFIX
73
74
  });
74
- const { className, event, eventId, onDeleteConfirm } = props, rest = tslib_1.__rest(props, ["className", "event", "eventId", "onDeleteConfirm"]);
75
+ const { className, event, eventId, onDeleteConfirm, onEditSuccess } = props, rest = tslib_1.__rest(props, ["className", "event", "eventId", "onDeleteConfirm", "onEditSuccess"]);
75
76
  // STATE
76
77
  const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
77
78
  const [openConfirmDialog, setOpenConfirmDialog] = (0, react_1.useState)(false);
79
+ const [openEdit, setOpenEdit] = (0, react_1.useState)(false);
78
80
  // HOOKS
79
81
  const theme = (0, material_1.useTheme)();
80
82
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
81
83
  const scRoutingContext = (0, react_core_1.useSCRouting)();
82
84
  const scUserContext = (0, react_core_1.useSCUser)();
83
- const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
85
+ const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
84
86
  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]);
85
87
  const isEventFinished = (0, react_1.useMemo)(() => {
86
88
  if (scEvent && !scEvent.running) {
@@ -95,10 +97,17 @@ function EventActionsMenu(inProps) {
95
97
  const handleClose = () => {
96
98
  setAnchorEl(null);
97
99
  };
100
+ const handleEditClick = () => {
101
+ setOpenEdit((o) => !o);
102
+ };
98
103
  const handleCloseDialog = () => {
99
104
  setOpenConfirmDialog(false);
100
105
  setAnchorEl(null);
101
106
  };
107
+ const handleEditSuccess = (data) => {
108
+ setSCEvent(data);
109
+ onEditSuccess && onEditSuccess(data);
110
+ };
102
111
  /**
103
112
  * Handles thread deletion
104
113
  */
@@ -150,6 +159,7 @@ function EventActionsMenu(inProps) {
150
159
  isEventAdmin &&
151
160
  !isEventFinished && [
152
161
  (0, jsx_runtime_1.jsx)(material_1.Divider, {}, "divider"),
162
+ isMobile && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: handleEditClick }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "edit" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.item.edit", defaultMessage: "ui.shared.eventActionsMenu.item.edit" })] }), "edit")),
153
163
  (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(EventActionsMenu_1.CANCEL_EVENT) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "close" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.item.cancel", defaultMessage: "ui.shared.eventActionsMenu.item.cancel" })] }), "cancel")
154
164
  ]
155
165
  ];
@@ -157,6 +167,6 @@ function EventActionsMenu(inProps) {
157
167
  if (!scEvent) {
158
168
  return null;
159
169
  }
160
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { onClick: handleOpen }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "more_vert" }) })), isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "bottom", open: Boolean(anchorEl), onClose: handleClose, onOpen: handleOpen, PaperProps: { className: classes.paper }, disableSwipeToOpen: true }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: renderList() }) }))) : ((0, jsx_runtime_1.jsx)(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, PaperProps: { className: classes.paper } }, { children: renderList() }))), openConfirmDialog && ((0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { open: openConfirmDialog, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.dialog.msg", defaultMessage: "ui.shared.eventActionsMenu.dialog.msg" }), btnConfirm: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.dialog.confirm", defaultMessage: "ui.shared.eventActionsMenu.dialog.confirm" }), onConfirm: handleDeleteThread, onClose: handleCloseDialog }))] }));
170
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { onClick: handleOpen }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "more_vert" }) })), isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "bottom", open: Boolean(anchorEl), onClose: handleClose, onOpen: handleOpen, PaperProps: { className: classes.paper }, disableSwipeToOpen: true }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: renderList() }) }))) : ((0, jsx_runtime_1.jsx)(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, PaperProps: { className: classes.paper } }, { children: renderList() }))), openConfirmDialog && ((0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { open: openConfirmDialog, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.dialog.msg", defaultMessage: "ui.shared.eventActionsMenu.dialog.msg" }), btnConfirm: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.dialog.confirm", defaultMessage: "ui.shared.eventActionsMenu.dialog.confirm" }), onConfirm: handleDeleteThread, onClose: handleCloseDialog })), openEdit && (0, jsx_runtime_1.jsx)(EventForm_1.default, { onClose: handleEditClick, event: scEvent, onSuccess: handleEditSuccess })] }));
161
171
  }
162
172
  exports.default = EventActionsMenu;
@@ -12,10 +12,15 @@ const LazyLoad_1 = require("../../../constants/LazyLoad");
12
12
  const Skeleton_1 = tslib_1.__importDefault(require("@mui/material/Skeleton"));
13
13
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
14
14
  const constants_1 = require("./constants");
15
+ const material_1 = require("@mui/material");
15
16
  const filter_1 = tslib_1.__importDefault(require("./filter"));
16
17
  const classes = {
17
18
  displayRoot: `${constants_1.PREFIX}-display-root`,
18
19
  displayLink: `${constants_1.PREFIX}-link`,
20
+ displayHtmlWrap: `${constants_1.PREFIX}-html-wrap`,
21
+ displayHtml: `${constants_1.PREFIX}-html`,
22
+ displayHtmlPlaceholder: `${constants_1.PREFIX}-html-placeholder`,
23
+ displayHtmlLoading: `${constants_1.PREFIX}-html-loading`,
19
24
  displayVideo: `${constants_1.PREFIX}-video`,
20
25
  thumbnail: `${constants_1.PREFIX}-thumbnail`,
21
26
  thumbnailFullWidth: `${constants_1.PREFIX}-thumbnail`,
@@ -40,12 +45,23 @@ exports.default = (props) => {
40
45
  // RENDER
41
46
  /**
42
47
  * Renders link display
43
- * @param (link)
44
- * @param(key)
48
+ * @param media
49
+ * @param key
45
50
  */
46
- const renderPreview = (link, key) => {
47
- const domain = new URL(link.embed.metadata.url).hostname.replace('www.', '');
48
- return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayLink }, { children: [link.embed.metadata.images && link.embed.metadata.images.length > 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fullWidth ? ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnailFullWidth, classes.image), style: { background: `url(${link.image})`, paddingBottom: `${100 / link.image_width / link.image_height}%` } })) : ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnail, classes.image), style: { background: `url(${link.image})` } })) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.snippet }, { children: [(0, jsx_runtime_1.jsx)("b", Object.assign({ className: classes.snippetTitle }, { children: link.embed.metadata.title })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: classes.snippetDescription }, { children: link.embed.metadata.description })), (0, jsx_runtime_1.jsx)("a", Object.assign({ href: link.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(link) }, { children: domain }))] })), (0, jsx_runtime_1.jsx)("div", { style: { clear: 'both' } })] }), key));
51
+ const renderPreview = (media, key) => {
52
+ // if (media.embed.metadata.html) {
53
+ // return renderHtml(media, key);
54
+ // }
55
+ const domain = new URL(media.embed.metadata.url).hostname.replace('www.', '');
56
+ return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayLink }, { children: [media.embed.metadata.images && media.embed.metadata.images.length > 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fullWidth ? ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnailFullWidth, classes.image), style: { background: `url(${media.image})`, paddingBottom: `${100 / media.image_width / media.image_height}%` } })) : ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnail, classes.image), style: { background: `url(${media.image})` } })) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.snippet }, { children: [(0, jsx_runtime_1.jsx)("b", Object.assign({ className: classes.snippetTitle }, { children: media.embed.metadata.title })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: classes.snippetDescription }, { children: media.embed.metadata.description })), (0, jsx_runtime_1.jsx)("a", Object.assign({ href: media.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(media) }, { children: domain }))] })), (0, jsx_runtime_1.jsx)("div", { style: { clear: 'both' } })] }), key));
57
+ };
58
+ /**
59
+ * Render html embed
60
+ * @param media
61
+ * @param key
62
+ */
63
+ const renderHtml = (media, key) => {
64
+ return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayHtmlWrap }, { children: [(0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: { __html: media.embed.metadata.html }, className: classes.displayHtml }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.displayHtmlPlaceholder, style: { paddingTop: `${(100 * media.embed.metadata.height) / media.embed.metadata.width}%`, maxHeight: media.embed.metadata.height } }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20, className: classes.displayHtmlLoading }) }))] }), key));
49
65
  };
50
66
  /**
51
67
  * Renders component
@@ -61,8 +61,17 @@ export default function BottomNavigation(inProps) {
61
61
  const { preferences, features } = useSCPreferences();
62
62
  // MEMO
63
63
  const privateMessagingEnabled = useMemo(() => features.includes(SCFeatureName.PRIVATE_MESSAGING), [features]);
64
- const groupsEnabled = useMemo(() => features.includes(SCFeatureName.GROUPING) && features.includes(SCFeatureName.TAGGING), [features]);
65
- const eventsEnabled = useMemo(() => features && features.includes(SCFeatureName.EVENT) && features.includes(SCFeatureName.TAGGING), [features]);
64
+ const groupsEnabled = useMemo(() => preferences &&
65
+ features &&
66
+ features.includes(SCFeatureName.TAGGING) &&
67
+ features.includes(SCFeatureName.GROUPING) &&
68
+ SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
69
+ preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
70
+ const eventsEnabled = useMemo(() => preferences &&
71
+ features &&
72
+ features.includes(SCFeatureName.TAGGING) &&
73
+ SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
74
+ preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
66
75
  const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
67
76
  const postOnlyStaffEnabled = preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
68
77
  const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
@@ -428,10 +428,16 @@ export default function Composer(inProps) {
428
428
  if (features.includes(SCFeatureName.TAGGING) && addressing !== null) {
429
429
  data.addressing = addressing.map((t) => t.id);
430
430
  }
431
- if (features.includes(SCFeatureName.GROUPING) && group !== null) {
431
+ if (features.includes(SCFeatureName.TAGGING) &&
432
+ features.includes(SCFeatureName.GROUPING) &&
433
+ preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value &&
434
+ group !== null) {
432
435
  data.group = group.id;
433
436
  }
434
- if (features.includes(SCFeatureName.EVENT) && event !== null) {
437
+ if (features.includes(SCFeatureName.TAGGING) &&
438
+ features.includes(SCFeatureName.EVENT) &&
439
+ preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value &&
440
+ event !== null) {
435
441
  data.event = event.id;
436
442
  }
437
443
  setIsSubmitting(true);