@selfcommunity/react-ui 0.7.50-events.105 → 0.7.50-events.107

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 (28) hide show
  1. package/lib/cjs/components/EventHeader/EventHeader.js +2 -3
  2. package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +8 -2
  3. package/lib/cjs/components/Events/Events.js +9 -5
  4. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.d.ts +1 -1
  5. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +7 -3
  6. package/lib/cjs/components/RelatedEventsWidget/RelatedEventsWidget.js +1 -1
  7. package/lib/cjs/components/RelatedEventsWidget/Skeleton.js +2 -2
  8. package/lib/cjs/constants/ContributionsActionsMenu.d.ts +1 -0
  9. package/lib/cjs/constants/ContributionsActionsMenu.js +2 -1
  10. package/lib/cjs/shared/ContributionActionsMenu/index.d.ts +4 -0
  11. package/lib/cjs/shared/ContributionActionsMenu/index.js +66 -13
  12. package/lib/cjs/shared/EventInfoDetails/index.d.ts +7 -6
  13. package/lib/cjs/shared/EventInfoDetails/index.js +6 -4
  14. package/lib/esm/components/EventHeader/EventHeader.js +2 -3
  15. package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +9 -3
  16. package/lib/esm/components/Events/Events.js +10 -6
  17. package/lib/esm/components/MyEventsWidget/MyEventsWidget.d.ts +1 -1
  18. package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +8 -4
  19. package/lib/esm/components/RelatedEventsWidget/RelatedEventsWidget.js +3 -3
  20. package/lib/esm/components/RelatedEventsWidget/Skeleton.js +3 -3
  21. package/lib/esm/constants/ContributionsActionsMenu.d.ts +1 -0
  22. package/lib/esm/constants/ContributionsActionsMenu.js +1 -0
  23. package/lib/esm/shared/ContributionActionsMenu/index.d.ts +4 -0
  24. package/lib/esm/shared/ContributionActionsMenu/index.js +67 -14
  25. package/lib/esm/shared/EventInfoDetails/index.d.ts +7 -6
  26. package/lib/esm/shared/EventInfoDetails/index.js +7 -5
  27. package/lib/umd/react-ui.js +1 -1
  28. package/package.json +7 -7
@@ -75,7 +75,6 @@ const Root = (0, styles_1.styled)(material_1.Box, {
75
75
  * @param inProps
76
76
  */
77
77
  function EventHeader(inProps) {
78
- var _a, _b;
79
78
  // PROPS
80
79
  const props = (0, system_1.useThemeProps)({
81
80
  props: inProps,
@@ -95,7 +94,7 @@ function EventHeader(inProps) {
95
94
  // REFS
96
95
  const updatesSubscription = (0, react_1.useRef)(null);
97
96
  // CONST
98
- 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]);
97
+ const isEventAdmin = (0, react_1.useMemo)(() => scUserContext.user && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id]);
99
98
  const isEventFinished = (0, react_1.useMemo)(() => {
100
99
  if (scEvent && !scEvent.running) {
101
100
  return new Date().getTime() > new Date(scEvent.end_date || scEvent.start_date).getTime();
@@ -177,6 +176,6 @@ function EventHeader(inProps) {
177
176
  month: 'long'
178
177
  }),
179
178
  hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
180
- } })) })), (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: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.id, secondary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isEventAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, 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: [(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))] })) }) })] }))] })));
181
180
  }
182
181
  exports.default = EventHeader;
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const material_1 = require("@mui/material");
6
6
  const react_core_1 = require("@selfcommunity/react-core");
7
+ const types_1 = require("@selfcommunity/types");
7
8
  const react_1 = require("react");
8
9
  const react_intl_1 = require("react-intl");
9
10
  const EventInfoDetails_1 = tslib_1.__importDefault(require("../../shared/EventInfoDetails"));
@@ -27,6 +28,9 @@ function isTextLongerThanLimit(text, limit = 125) {
27
28
  return text.length > limit;
28
29
  }
29
30
  function getTruncatedText(text, limit = 125) {
31
+ if (!text) {
32
+ return '';
33
+ }
30
34
  return isTextLongerThanLimit(text, limit) ? text.substring(0, limit).concat('...') : text;
31
35
  }
32
36
  function EventInfoWidget(inProps) {
@@ -60,6 +64,9 @@ function EventInfoWidget(inProps) {
60
64
  const handleToggleSummary = (0, react_1.useCallback)(() => {
61
65
  setExpanded(!expanded);
62
66
  }, [expanded]);
67
+ const showInfo = (0, react_1.useMemo)(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === types_1.SCEventPrivacyType.PUBLIC ||
68
+ [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
+ 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]);
63
70
  // RENDER
64
71
  if (!scEvent && loading) {
65
72
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
@@ -67,7 +74,6 @@ function EventInfoWidget(inProps) {
67
74
  if (!scEvent) {
68
75
  return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
69
76
  }
70
- const description = expanded ? scEvent.description : getTruncatedText(scEvent.description, 220);
71
- 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.jsxs)(material_1.Stack, Object.assign({ className: classes.titleWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "info" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textWrapper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true })] })) })));
77
+ 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.jsxs)(material_1.Stack, Object.assign({ className: classes.titleWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "info" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textWrapper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo, hasInProgress: false })] })) })));
72
78
  }
73
79
  exports.default = EventInfoWidget;
@@ -84,7 +84,8 @@ function Events(inProps) {
84
84
  const [events, setEvents] = (0, react_1.useState)([]);
85
85
  const [loading, setLoading] = (0, react_1.useState)(true);
86
86
  const [next, setNext] = (0, react_1.useState)(null);
87
- const [search, setSearch] = (0, react_1.useState)('');
87
+ const [query, setQuery] = (0, react_1.useState)('');
88
+ const [search, setSearch] = (0, react_1.useState)(false);
88
89
  const [dateSearch, setDateSearch] = (0, react_1.useState)(options[0].value);
89
90
  const [showFollowed, setShowFollowed] = (0, react_1.useState)(false);
90
91
  const [showPastEvents, setShowPastEvents] = (0, react_1.useState)(false);
@@ -114,13 +115,13 @@ function Events(inProps) {
114
115
  * Fetches events list
115
116
  */
116
117
  const fetchEvents = () => {
117
- search === '' && setLoading(true);
118
+ setLoading(true);
118
119
  return api_services_1.http
119
120
  .request({
120
121
  url: endpoint.url({}),
121
122
  method: endpoint.method,
122
123
  params: Object.assign(Object.assign({}, endpointQueryParams), (general
123
- ? Object.assign(Object.assign(Object.assign(Object.assign({}, (search !== '' && { search: search })), (dateSearch !== types_1.SCEventDateFilterType.ANY && { date_filter: dateSearch })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: types_1.SCEventDateFilterType.PAST })) : Object.assign(Object.assign(Object.assign({}, (search !== '' && { search: search })), { subscription_status: types_1.SCEventSubscriptionStatusType.GOING }), (showPastEvents && { past: showPastEvents }))))
124
+ ? Object.assign(Object.assign(Object.assign(Object.assign({}, (search && { search: query })), (dateSearch !== types_1.SCEventDateFilterType.ANY && { date_filter: dateSearch })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: types_1.SCEventDateFilterType.PAST })) : Object.assign({ subscription_status: types_1.SCEventSubscriptionStatusType.GOING }, (showPastEvents && { past: showPastEvents }))))
124
125
  })
125
126
  .then((res) => {
126
127
  setEvents(res.data.results);
@@ -163,7 +164,8 @@ function Events(inProps) {
163
164
  * @param event
164
165
  */
165
166
  const handleOnChangeFilterName = (event) => {
166
- setSearch(event.target.value);
167
+ setQuery(event.target.value);
168
+ setSearch(false);
167
169
  };
168
170
  /**
169
171
  * Handle change time frame
@@ -175,7 +177,9 @@ function Events(inProps) {
175
177
  /**
176
178
  * Renders events list
177
179
  */
178
- 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.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(PastEventsFilter_1.default, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !events.length && !showPastEvents }) }))) : ((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, { size: 'small', fullWidth: true, value: search, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading }) })), (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, 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
180
+ 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.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(PastEventsFilter_1.default, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !events.length && !showPastEvents }) }))) : ((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, { 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, InputProps: {
181
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => setSearch(true) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }) })))
182
+ } }) })), (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, 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
179
183
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
180
184
  // @ts-ignore
181
185
  , {
@@ -3,7 +3,7 @@ import { WidgetProps } from '../Widget';
3
3
  export interface MyEventsWidgetProps extends WidgetProps {
4
4
  /**
5
5
  * Feed API Query Params
6
- * @default [{'limit': 20, 'offset': 0}]
6
+ * @default [{'limit': 20, 'offset': 0, subscription_status: 'going'}]
7
7
  */
8
8
  endpointQueryParams?: Record<string, string | number>;
9
9
  /**
@@ -14,12 +14,12 @@ const react_intl_1 = require("react-intl");
14
14
  const Errors_1 = require("../../constants/Errors");
15
15
  const Pagination_1 = require("../../constants/Pagination");
16
16
  const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
17
+ const event_1 = require("../../types/event");
17
18
  const widget_1 = require("../../utils/widget");
19
+ const Event_1 = tslib_1.__importDefault(require("../Event"));
18
20
  const Widget_1 = tslib_1.__importDefault(require("../Widget"));
19
21
  const constants_1 = require("./constants");
20
22
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
21
- const event_1 = require("../../types/event");
22
- const Event_1 = tslib_1.__importDefault(require("../Event"));
23
23
  const classes = {
24
24
  root: `${constants_1.PREFIX}-root`,
25
25
  titleWrapper: `${constants_1.PREFIX}-title-wrapper`,
@@ -47,7 +47,11 @@ function MyEventsWidget(inProps) {
47
47
  name: constants_1.PREFIX
48
48
  });
49
49
  // CONST
50
- const { endpointQueryParams = { limit: Pagination_1.DEFAULT_PAGINATION_LIMIT, offset: Pagination_1.DEFAULT_PAGINATION_OFFSET }, cacheStrategy } = props, rest = tslib_1.__rest(props, ["endpointQueryParams", "cacheStrategy"]);
50
+ const { endpointQueryParams = {
51
+ limit: Pagination_1.DEFAULT_PAGINATION_LIMIT,
52
+ offset: Pagination_1.DEFAULT_PAGINATION_OFFSET,
53
+ subscription_status: types_1.SCEventSubscriptionStatusType.GOING
54
+ }, cacheStrategy } = props, rest = tslib_1.__rest(props, ["endpointQueryParams", "cacheStrategy"]);
51
55
  // STATE
52
56
  const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
53
57
  isLoadingNext: false,
@@ -121,6 +121,6 @@ function RelatedEventsWidget(inProps) {
121
121
  if (!scEvent || (state === null || state === void 0 ? void 0 : state.count) === 0) {
122
122
  return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
123
123
  }
124
- return ((0, jsx_runtime_1.jsxs)(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.jsxs)(material_1.Stack, Object.assign({ className: classes.header }, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, { id: (_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id }), className: classes.avatarWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "rounded", src: scEvent.managed_by.avatar, alt: scEvent.managed_by.username, className: classes.avatar }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4" }, { children: (0, jsx_runtime_1.jsx)("b", { children: intl.formatMessage(messages.title, { user: scEvent.managed_by.username }) }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.eventWrapper }, { children: state === null || state === void 0 ? void 0 : state.results.map((_event, i, array) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.default, Object.assign({ event: _event, eventId: _event.id }, eventComponentProps, { className: classes.event }), i), i < array.length - 1 && (0, jsx_runtime_1.jsx)(material_1.Divider, {})] }))) }))] })), state.count > state.visibleItems && ((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, className: classes.actionButton }, { 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.relatedEventsWidget.showAll", defaultMessage: "ui.relatedEventsWidget.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: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: (0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({ elevation: 0 }, eventComponentProps)), className: classes.infiniteScroll, 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.relatedEventsWidget.noMoreResults", defaultMessage: "ui.eventMembersWidget.noMoreResults" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: state.results.map((event) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(Event_1.default, Object.assign({ elevation: 0, event: event }, eventComponentProps)) }, event.id))) }) })) })))] })));
124
+ return ((0, jsx_runtime_1.jsxs)(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.jsxs)(material_1.Stack, Object.assign({ className: classes.header }, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, { id: (_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id }), className: classes.avatarWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "rounded", src: scEvent.managed_by.avatar, alt: scEvent.managed_by.username, className: classes.avatar }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4" }, { children: (0, jsx_runtime_1.jsx)("b", { children: intl.formatMessage(messages.title, { user: scEvent.managed_by.username }) }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.eventWrapper }, { children: state === null || state === void 0 ? void 0 : state.results.map((_event, i, array) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.default, Object.assign({ event: _event, eventId: _event.id }, eventComponentProps, { className: classes.event })), i < array.length - 1 && (0, jsx_runtime_1.jsx)(material_1.Divider, {})] }, i))) }))] })), state.count > state.visibleItems && ((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, className: classes.actionButton }, { 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.relatedEventsWidget.showAll", defaultMessage: "ui.relatedEventsWidget.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: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: (0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({ elevation: 0 }, eventComponentProps)), className: classes.infiniteScroll, 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.relatedEventsWidget.noMoreResults", defaultMessage: "ui.eventMembersWidget.noMoreResults" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: state.results.map((event) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(Event_1.default, Object.assign({ elevation: 0, event: event }, eventComponentProps)) }, event.id))) }) })) })))] })));
125
125
  }
126
126
  exports.default = RelatedEventsWidget;
@@ -4,9 +4,9 @@ const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const material_1 = require("@mui/material");
6
6
  const system_1 = require("@mui/system");
7
+ const react_1 = require("react");
7
8
  require("swiper/css");
8
9
  const Event_1 = require("../Event");
9
- const User_1 = require("../User");
10
10
  const Widget_1 = tslib_1.__importDefault(require("../Widget"));
11
11
  const constants_1 = require("./constants");
12
12
  const classes = {
@@ -23,6 +23,6 @@ const Root = (0, system_1.styled)(Widget_1.default, {
23
23
  overridesResolver: (_props, styles) => styles.skeletonRoot
24
24
  })(() => ({}));
25
25
  function RelatedEventsWidgetSkeleton() {
26
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: classes.root }, { children: [(0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(User_1.UserSkeleton, { className: classes.user, elevation: 0 }), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.eventWrapper }, { children: [1, 2, 3, 4].map((_event, i, array) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, { elevation: 0, className: classes.event }, i), i < array.length - 1 && (0, jsx_runtime_1.jsx)(material_1.Divider, {})] }))) }))] })), (0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { animation: "wave", width: "52px", height: "20px" }) }))] })));
26
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: classes.root }, { children: [(0, jsx_runtime_1.jsx)(material_1.CardContent, Object.assign({ className: classes.content }, { children: (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.eventWrapper }, { children: [1, 2, 3, 4].map((_event, i, array) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, { elevation: 0, className: classes.event }), i < array.length - 1 && (0, jsx_runtime_1.jsx)(material_1.Divider, {})] }, i))) })) })), (0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { animation: "wave", width: "52px", height: "20px" }) }))] })));
27
27
  }
28
28
  exports.default = RelatedEventsWidgetSkeleton;
@@ -14,5 +14,6 @@ export declare const EDIT_CONTRIBUTION = "_edit_contribution";
14
14
  export declare const DELETE_CONTRIBUTION = "_delete_contribution";
15
15
  export declare const RESTORE_CONTRIBUTION = "_restore_contribution";
16
16
  export declare const SUSPEND_NOTIFICATION_CONTRIBUTION = "_suspend_notification_contribution";
17
+ export declare const SUSPEND_NOTIFICATION_EVENT = "_suspend_notification_event";
17
18
  export declare const MODERATE_CONTRIBUTION_HIDDEN = "_moderate_contribution_hidden";
18
19
  export declare const MODERATE_CONTRIBUTION_DELETED = "_moderate_contribution_deleted";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODERATE_CONTRIBUTION_DELETED = exports.MODERATE_CONTRIBUTION_HIDDEN = exports.SUSPEND_NOTIFICATION_CONTRIBUTION = exports.RESTORE_CONTRIBUTION = exports.DELETE_CONTRIBUTION = exports.EDIT_CONTRIBUTION = exports.GET_CONTRIBUTION_PERMALINK = exports.DELETE_CONTRIBUTION_SECTION = exports.HIDE_CONTRIBUTION_SECTION = exports.FLAG_CONTRIBUTION_SECTION = exports.GENERAL_SECTION = void 0;
3
+ exports.MODERATE_CONTRIBUTION_DELETED = exports.MODERATE_CONTRIBUTION_HIDDEN = exports.SUSPEND_NOTIFICATION_EVENT = exports.SUSPEND_NOTIFICATION_CONTRIBUTION = exports.RESTORE_CONTRIBUTION = exports.DELETE_CONTRIBUTION = exports.EDIT_CONTRIBUTION = exports.GET_CONTRIBUTION_PERMALINK = exports.DELETE_CONTRIBUTION_SECTION = exports.HIDE_CONTRIBUTION_SECTION = exports.FLAG_CONTRIBUTION_SECTION = exports.GENERAL_SECTION = void 0;
4
4
  /**
5
5
  * Sections
6
6
  * @type {string}
@@ -17,5 +17,6 @@ exports.EDIT_CONTRIBUTION = '_edit_contribution';
17
17
  exports.DELETE_CONTRIBUTION = '_delete_contribution';
18
18
  exports.RESTORE_CONTRIBUTION = '_restore_contribution';
19
19
  exports.SUSPEND_NOTIFICATION_CONTRIBUTION = '_suspend_notification_contribution';
20
+ exports.SUSPEND_NOTIFICATION_EVENT = '_suspend_notification_event';
20
21
  exports.MODERATE_CONTRIBUTION_HIDDEN = '_moderate_contribution_hidden';
21
22
  exports.MODERATE_CONTRIBUTION_DELETED = '_moderate_contribution_deleted';
@@ -54,6 +54,10 @@ export interface ContributionActionsMenuProps {
54
54
  * Handle suspend notification obj
55
55
  */
56
56
  onSuspendNotificationContribution?: (obj: SCCommentType | SCFeedObjectType) => void;
57
+ /**
58
+ * Handle suspend notification event embedded in obj
59
+ */
60
+ onSuspendNotificationEvent?: (obj: SCCommentType | SCFeedObjectType) => void;
57
61
  /**
58
62
  * Props to spread to popper
59
63
  * @default empty object
@@ -78,7 +78,7 @@ const messages = (0, react_intl_1.defineMessages)({
78
78
  });
79
79
  function ContributionActionsMenu(props) {
80
80
  // PROPS
81
- const { className, feedObjectId, feedObject, feedObjectType = types_1.SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, PopperProps = {} } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "PopperProps"]);
81
+ const { className, feedObjectId, feedObject, feedObjectType = types_1.SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, onSuspendNotificationEvent, PopperProps = {} } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "onSuspendNotificationEvent", "PopperProps"]);
82
82
  // INTL
83
83
  const intl = (0, react_intl_1.useIntl)();
84
84
  // CONTEXT
@@ -173,7 +173,7 @@ function ContributionActionsMenu(props) {
173
173
  }
174
174
  }
175
175
  /**
176
- * Performs notification suspension
176
+ * Performs notification suspension
177
177
  */
178
178
  const performSuspendNotification = (0, react_1.useMemo)(() => () => {
179
179
  return api_services_1.http
@@ -188,14 +188,30 @@ function ContributionActionsMenu(props) {
188
188
  return Promise.resolve(res.data);
189
189
  });
190
190
  }, [contributionObj]);
191
+ /**
192
+ * Performs notification suspension of event embedded
193
+ */
194
+ const performSuspendNotificationEvent = (0, react_1.useMemo)(() => () => {
195
+ const _endpoint = contributionObj.event.show_on_feed ? api_services_1.Endpoints.HideEvent : api_services_1.Endpoints.ShowEvent;
196
+ return api_services_1.http
197
+ .request({
198
+ url: _endpoint.url({ id: contributionObj.event.id }),
199
+ method: _endpoint.method
200
+ })
201
+ .then((res) => {
202
+ if (res.status >= 300) {
203
+ return Promise.reject(res);
204
+ }
205
+ return Promise.resolve(res.data);
206
+ });
207
+ }, [contributionObj]);
191
208
  /**
192
209
  * Handles stop notification for contributionObj
193
- * @param contribution
194
210
  */
195
211
  function handleSuspendContentNotification() {
196
212
  setCurrentActionLoading(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION);
197
213
  performSuspendNotification()
198
- .then((data) => {
214
+ .then(() => {
199
215
  const _feedObj = Object.assign({}, feedObj, { suspended: !feedObj.suspended });
200
216
  setFeedObj(_feedObj);
201
217
  onSuspendNotificationContribution && onSuspendNotificationContribution(_feedObj);
@@ -211,6 +227,29 @@ function ContributionActionsMenu(props) {
211
227
  });
212
228
  });
213
229
  }
230
+ /**
231
+ * Handles stop notification for event embedded in contributionObj
232
+ */
233
+ function handleSuspendEventNotification() {
234
+ setCurrentActionLoading(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT);
235
+ performSuspendNotificationEvent()
236
+ .then(() => {
237
+ const _eventObj = Object.assign({}, feedObj.event, { show_on_feed: !feedObj.event.show_on_feed });
238
+ const _feedObj = Object.assign({}, feedObj, { event: _eventObj });
239
+ setFeedObj(_feedObj);
240
+ onSuspendNotificationEvent && onSuspendNotificationEvent(_feedObj);
241
+ setCurrentActionLoading(null);
242
+ })
243
+ .catch((error) => {
244
+ utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
245
+ setCurrentAction(null);
246
+ setCurrentActionLoading(null);
247
+ enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.actionError", defaultMessage: "ui.contributionActionMenu.actionError" }), {
248
+ variant: 'error',
249
+ autoHideDuration: 3000
250
+ });
251
+ });
252
+ }
214
253
  /**
215
254
  * Get Status Flag
216
255
  */
@@ -355,7 +394,7 @@ function ContributionActionsMenu(props) {
355
394
  else if (contributionObj && !isLoading && !isFlagging && type !== 'undefined') {
356
395
  setIsFlagging(true);
357
396
  performFlag(type)
358
- .then((data) => {
397
+ .then(() => {
359
398
  setFlagType(flagType === type ? null : type);
360
399
  setIsFlagging(false);
361
400
  onFlagContribution && onFlagContribution(contributionObj, type, flagType !== type);
@@ -443,6 +482,10 @@ function ContributionActionsMenu(props) {
443
482
  setCurrentAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION);
444
483
  handleSuspendContentNotification();
445
484
  }
485
+ else if (action === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT) {
486
+ setCurrentAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT);
487
+ handleSuspendEventNotification();
488
+ }
446
489
  else if (action === ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN) {
447
490
  setCurrentAction(ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN);
448
491
  setOpenConfirmDialog(true);
@@ -496,7 +539,7 @@ function ContributionActionsMenu(props) {
496
539
  if (currentAction === ContributionsActionsMenu_1.DELETE_CONTRIBUTION) {
497
540
  setCurrentActionLoading(ContributionsActionsMenu_1.DELETE_CONTRIBUTION);
498
541
  performDeleteContribution()
499
- .then((data) => {
542
+ .then(() => {
500
543
  const _contributionObj = Object.assign({}, contributionObj, { deleted: true });
501
544
  onDeleteContribution && onDeleteContribution(_contributionObj);
502
545
  performPostConfirmAction(true);
@@ -509,7 +552,7 @@ function ContributionActionsMenu(props) {
509
552
  else if (currentAction === ContributionsActionsMenu_1.RESTORE_CONTRIBUTION) {
510
553
  setCurrentActionLoading(ContributionsActionsMenu_1.RESTORE_CONTRIBUTION);
511
554
  performRestoreContribution()
512
- .then((data) => {
555
+ .then(() => {
513
556
  const _contributionObj = Object.assign({}, contributionObj, { deleted: false });
514
557
  onRestoreContribution && onRestoreContribution(_contributionObj);
515
558
  performPostConfirmAction(true);
@@ -522,7 +565,7 @@ function ContributionActionsMenu(props) {
522
565
  else if (currentAction === ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN) {
523
566
  setCurrentActionLoading(ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN);
524
567
  performModerationContribution(Flagging_1.MODERATION_TYPE_ACTION_HIDE, hideFlagType)
525
- .then((data) => {
568
+ .then(() => {
526
569
  const _contributionObj = Object.assign({}, contributionObj, { collapsed: !contributionObj.collapsed });
527
570
  setHideType(hideType === hideFlagType ? null : hideFlagType);
528
571
  setHideFlagType(null);
@@ -537,7 +580,7 @@ function ContributionActionsMenu(props) {
537
580
  else if (currentAction === ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_DELETED) {
538
581
  setCurrentActionLoading(ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_DELETED);
539
582
  performModerationContribution(Flagging_1.MODERATION_TYPE_ACTION_DELETE, deleteFlagType)
540
- .then((data) => {
583
+ .then(() => {
541
584
  const _contributionObj = Object.assign({}, contributionObj, { deleted: !contributionObj.deleted });
542
585
  setDeleteType(deleteType === deleteFlagType ? null : deleteFlagType);
543
586
  setDeleteFlagType(null);
@@ -580,9 +623,9 @@ function ContributionActionsMenu(props) {
580
623
  return name;
581
624
  }
582
625
  /**
583
- * action
584
- * @param actionId
585
- */
626
+ * action
627
+ * @param sectionId
628
+ */
586
629
  function handleOpenSection(sectionId) {
587
630
  if (sectionId) {
588
631
  if (sectionId === openSection) {
@@ -653,11 +696,21 @@ function ContributionActionsMenu(props) {
653
696
  contributionObj &&
654
697
  contributionObj.type !== types_1.SCContributionType.COMMENT);
655
698
  }
699
+ /**
700
+ * Can authenticated user suspend notification for the event related to the contribution
701
+ */
702
+ function canSuspendNotificationEvent() {
703
+ return (scUserContext.user &&
704
+ scUserContext.user.id !== contributionObj.author.id &&
705
+ contributionObj &&
706
+ contributionObj.type !== types_1.SCContributionType.COMMENT &&
707
+ Boolean(contributionObj.event));
708
+ }
656
709
  /**
657
710
  * Renders section general
658
711
  */
659
712
  function renderGeneralSection() {
660
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "link" }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(ContributionsActionsMenu_1.GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { 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)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.DELETE_CONTRIBUTION || currentActionLoading === ContributionsActionsMenu_1.RESTORE_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "delete" })) }), contributionObj.deleted ? ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_off" })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] })))] }, ContributionsActionsMenu_1.GENERAL_SECTION));
713
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "link" }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(ContributionsActionsMenu_1.GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { 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)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.DELETE_CONTRIBUTION || currentActionLoading === ContributionsActionsMenu_1.RESTORE_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "delete" })) }), contributionObj.deleted ? ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_off" })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canSuspendNotificationEvent() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : contributionObj.event['show_on_feed'] ? ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_off" })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: !contributionObj.event['show_on_feed'] ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT), classes: { root: classes.itemText } })] })))] }, ContributionsActionsMenu_1.GENERAL_SECTION));
661
714
  }
662
715
  /**
663
716
  * Renders contribution menu content
@@ -1,5 +1,5 @@
1
1
  import { SCEventType } from '@selfcommunity/types';
2
- import React from 'react';
2
+ import { ReactNode } from 'react';
3
3
  export interface EventInfoDetailsProps {
4
4
  event: SCEventType;
5
5
  hideDateIcon?: boolean;
@@ -12,10 +12,11 @@ export interface EventInfoDetailsProps {
12
12
  hasPrivacyInfo?: boolean;
13
13
  hasLocationInfo?: boolean;
14
14
  hasCreatedInfo?: boolean;
15
- beforeDateInfo?: React.ReactNode | null;
16
- beforeRecurringInfo?: React.ReactNode | null;
17
- beforePrivacyInfo?: React.ReactNode | null;
18
- beforeLocationInfo?: React.ReactNode | null;
19
- beforeCreatedInfo?: React.ReactNode | null;
15
+ hasInProgress?: boolean;
16
+ beforeDateInfo?: ReactNode | null;
17
+ beforeRecurringInfo?: ReactNode | null;
18
+ beforePrivacyInfo?: ReactNode | null;
19
+ beforeLocationInfo?: ReactNode | null;
20
+ beforeCreatedInfo?: ReactNode | null;
20
21
  }
21
22
  export default function EventInfoDetails(inProps: EventInfoDetailsProps): JSX.Element;
@@ -4,11 +4,13 @@ const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const material_1 = require("@mui/material");
5
5
  const react_core_1 = require("@selfcommunity/react-core");
6
6
  const types_1 = require("@selfcommunity/types");
7
+ const react_1 = require("react");
7
8
  const react_intl_1 = require("react-intl");
8
9
  const PREFIX = 'SCEventInfoDetails';
9
10
  const classes = {
10
11
  root: `${PREFIX}-root`,
11
12
  iconTextWrapper: `${PREFIX}-icon-text-wrapper`,
13
+ live: `${PREFIX}-live`,
12
14
  link: `${PREFIX}-link`,
13
15
  url: `${PREFIX}-url`,
14
16
  creationWrapper: `${PREFIX}-creation-wrapper`
@@ -24,11 +26,11 @@ function EventInfoDetails(inProps) {
24
26
  props: inProps,
25
27
  name: PREFIX
26
28
  });
27
- const { event, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, beforeDateInfo, beforeRecurringInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
29
+ const { event, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, hasInProgress = true, beforeDateInfo, beforeRecurringInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
28
30
  // HOOKS
29
31
  const intl = (0, react_intl_1.useIntl)();
30
- const privacy = event.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private';
31
- const location = event.location === types_1.SCEventLocationType.ONLINE ? 'ui.eventInfoDetails.location.virtual' : 'ui.eventInfoDetails.location.inPerson';
32
+ const privacy = (0, react_1.useMemo)(() => (event.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private'), [event]);
33
+ const location = (0, react_1.useMemo)(() => (event.location === types_1.SCEventLocationType.ONLINE ? 'ui.eventInfoDetails.location.virtual' : 'ui.eventInfoDetails.location.inPerson'), [event]);
32
34
  return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: classes.root }, { children: [beforeDateInfo, hasDateInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideDateIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "CalendarIcon" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.date.startEndTime", defaultMessage: "ui.eventInfoDetails.date.startEndTime", values: {
33
35
  date: intl.formatDate(event.running ? event.running_start_date : event.next_start_date, {
34
36
  weekday: 'long',
@@ -37,7 +39,7 @@ function EventInfoDetails(inProps) {
37
39
  month: 'long'
38
40
  }),
39
41
  start: intl.formatDate(event.running ? event.running_start_date : event.next_start_date, { hour: 'numeric', minute: 'numeric' })
40
- } }) }))] }))), beforeRecurringInfo, hasRecurringInfo && event.recurring !== types_1.SCEventRecurrenceType.NEVER && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.location === types_1.SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === types_1.SCEventLocationType.ONLINE ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "create" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
42
+ } }) })), hasInProgress && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.inProgress", defaultMessage: "ui.eventInfoDetails.inProgress" }) }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.live }) })))] }))), beforeRecurringInfo, hasRecurringInfo && event.recurring !== types_1.SCEventRecurrenceType.NEVER && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.location === types_1.SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === types_1.SCEventLocationType.ONLINE ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "create" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
41
43
  date: intl.formatDate(event.created_at, {
42
44
  weekday: 'long',
43
45
  day: 'numeric',
@@ -73,7 +73,6 @@ const Root = styled(Box, {
73
73
  * @param inProps
74
74
  */
75
75
  export default function EventHeader(inProps) {
76
- var _a, _b;
77
76
  // PROPS
78
77
  const props = useThemeProps({
79
78
  props: inProps,
@@ -93,7 +92,7 @@ export default function EventHeader(inProps) {
93
92
  // REFS
94
93
  const updatesSubscription = useRef(null);
95
94
  // CONST
96
- const isEventAdmin = 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]);
95
+ const isEventAdmin = useMemo(() => scUserContext.user && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id]);
97
96
  const isEventFinished = useMemo(() => {
98
97
  if (scEvent && !scEvent.running) {
99
98
  return new Date().getTime() > new Date(scEvent.end_date || scEvent.start_date).getTime();
@@ -175,5 +174,5 @@ export default function EventHeader(inProps) {
175
174
  month: 'long'
176
175
  }),
177
176
  hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
178
- } })) })), _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: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.id, secondary: _jsx(FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: _jsx(_Fragment, { children: isEventAdmin ? (_jsxs(Box, Object.assign({ className: classes.multiActions }, { children: [_jsx(EventInviteButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, disabled: isEventFinished }), _jsxs(Box, { children: [_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished }), _jsx(EventActionsMenu, Object.assign({ event: scEvent }, EventActionsProps))] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), _jsx(EventActionsMenu, Object.assign({ event: scEvent }, EventActionsProps))] })) }) })] }))] })));
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: [_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished }), _jsx(EventActionsMenu, Object.assign({ event: scEvent }, EventActionsProps))] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), _jsx(EventActionsMenu, Object.assign({ event: scEvent }, EventActionsProps))] })) }) })] }))] })));
179
178
  }
@@ -2,7 +2,8 @@ import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Box, Button, CardContent, Icon, Stack, styled, Typography, useThemeProps } from '@mui/material';
4
4
  import { useSCFetchEvent } from '@selfcommunity/react-core';
5
- import { useCallback, useEffect, useState } from 'react';
5
+ import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
6
+ import { useCallback, useEffect, useMemo, useState } from 'react';
6
7
  import { FormattedMessage } from 'react-intl';
7
8
  import EventInfoDetails from '../../shared/EventInfoDetails';
8
9
  import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
@@ -25,6 +26,9 @@ function isTextLongerThanLimit(text, limit = 125) {
25
26
  return text.length > limit;
26
27
  }
27
28
  function getTruncatedText(text, limit = 125) {
29
+ if (!text) {
30
+ return '';
31
+ }
28
32
  return isTextLongerThanLimit(text, limit) ? text.substring(0, limit).concat('...') : text;
29
33
  }
30
34
  export default function EventInfoWidget(inProps) {
@@ -58,6 +62,9 @@ export default function EventInfoWidget(inProps) {
58
62
  const handleToggleSummary = useCallback(() => {
59
63
  setExpanded(!expanded);
60
64
  }, [expanded]);
65
+ const showInfo = useMemo(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PUBLIC ||
66
+ [SCEventSubscriptionStatusType.SUBSCRIBED, SCEventSubscriptionStatusType.GOING, SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
67
+ const description = useMemo(() => (expanded ? scEvent === null || scEvent === void 0 ? void 0 : scEvent.description : getTruncatedText(scEvent === null || scEvent === void 0 ? void 0 : scEvent.description, 220)), [expanded, scEvent]);
61
68
  // RENDER
62
69
  if (!scEvent && loading) {
63
70
  return _jsx(Skeleton, {});
@@ -65,6 +72,5 @@ export default function EventInfoWidget(inProps) {
65
72
  if (!scEvent) {
66
73
  return _jsx(HiddenPlaceholder, {});
67
74
  }
68
- const description = expanded ? scEvent.description : getTruncatedText(scEvent.description, 220);
69
- return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true })] })) })));
75
+ return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo, hasInProgress: false })] })) })));
70
76
  }