@selfcommunity/react-ui 0.7.50-events.106 → 0.7.50-events.108

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/EventInfoWidget/EventInfoWidget.js +1 -1
  2. package/lib/cjs/components/Events/Events.js +28 -9
  3. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.d.ts +1 -1
  4. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +7 -3
  5. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +0 -4
  6. package/lib/cjs/components/OnBoardingWidget/Steps/Category/Category.js +20 -1
  7. package/lib/cjs/components/OnBoardingWidget/Steps/Content/Content.js +20 -1
  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 +1 -0
  13. package/lib/cjs/shared/EventInfoDetails/index.js +3 -2
  14. package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +1 -1
  15. package/lib/esm/components/Events/Events.js +30 -11
  16. package/lib/esm/components/MyEventsWidget/MyEventsWidget.d.ts +1 -1
  17. package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +8 -4
  18. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +0 -4
  19. package/lib/esm/components/OnBoardingWidget/Steps/Category/Category.js +21 -2
  20. package/lib/esm/components/OnBoardingWidget/Steps/Content/Content.js +21 -2
  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 +1 -0
  26. package/lib/esm/shared/EventInfoDetails/index.js +4 -3
  27. package/lib/umd/react-ui.js +1 -1
  28. package/package.json +7 -7
@@ -1,6 +1,6 @@
1
1
  import { __rest } from "tslib";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Box, Button, Chip, FormControl, Grid, Icon, IconButton, InputLabel, MenuItem, Radio, Select, TextField, Typography } from '@mui/material';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Box, Button, Chip, FormControl, Grid, Icon, IconButton, InputAdornment, InputLabel, MenuItem, Radio, Select, TextField, Typography, useMediaQuery, useTheme } from '@mui/material';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
6
6
  import { Endpoints, http } from '@selfcommunity/api-services';
@@ -24,7 +24,8 @@ const classes = {
24
24
  item: `${PREFIX}-item`,
25
25
  itemSkeleton: `${PREFIX}-item-skeleton`,
26
26
  noResults: `${PREFIX}-no-results`,
27
- showMore: `${PREFIX}-show-more`
27
+ showMore: `${PREFIX}-show-more`,
28
+ search: `${PREFIX}-search`
28
29
  };
29
30
  const options = [
30
31
  { value: SCEventDateFilterType.ANY, label: _jsx(FormattedMessage, { id: "ui.events.select.any", defaultMessage: "ui.events.select.any" }) },
@@ -82,10 +83,10 @@ export default function Events(inProps) {
82
83
  const [loading, setLoading] = useState(true);
83
84
  const [next, setNext] = useState(null);
84
85
  const [query, setQuery] = useState('');
85
- const [search, setSearch] = useState(false);
86
86
  const [dateSearch, setDateSearch] = useState(options[0].value);
87
87
  const [showFollowed, setShowFollowed] = useState(false);
88
88
  const [showPastEvents, setShowPastEvents] = useState(false);
89
+ const [showMyEvents, setShowMyEvents] = useState(false);
89
90
  // CONTEXT
90
91
  const scUserContext = useContext(SCUserContext);
91
92
  const scPreferencesContext = useContext(SCPreferencesContext);
@@ -95,6 +96,8 @@ export default function Events(inProps) {
95
96
  scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
96
97
  // CONST
97
98
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
99
+ const theme = useTheme();
100
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
98
101
  // HANDLERS
99
102
  const handleChipClick = () => {
100
103
  setShowFollowed(!showFollowed);
@@ -111,14 +114,14 @@ export default function Events(inProps) {
111
114
  /**
112
115
  * Fetches events list
113
116
  */
114
- const fetchEvents = () => {
117
+ const fetchEvents = (search) => {
115
118
  setLoading(true);
116
119
  return http
117
120
  .request({
118
121
  url: endpoint.url({}),
119
122
  method: endpoint.method,
120
123
  params: Object.assign(Object.assign({}, endpointQueryParams), (general
121
- ? Object.assign(Object.assign(Object.assign(Object.assign({}, (search && { search: query })), (dateSearch !== SCEventDateFilterType.ANY && { date_filter: dateSearch })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: SCEventDateFilterType.PAST })) : Object.assign({ subscription_status: SCEventSubscriptionStatusType.GOING }, (showPastEvents && { past: showPastEvents }))))
124
+ ? Object.assign(Object.assign(Object.assign(Object.assign({}, (search && { search: query })), (dateSearch !== SCEventDateFilterType.ANY && { date_filter: dateSearch })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: SCEventDateFilterType.PAST })) : Object.assign(Object.assign({ subscription_status: SCEventSubscriptionStatusType.GOING }, (showPastEvents && { past: showPastEvents })), (showMyEvents && { created_by: authUserId }))))
122
125
  })
123
126
  .then((res) => {
124
127
  setEvents(res.data.results);
@@ -137,9 +140,9 @@ export default function Events(inProps) {
137
140
  return;
138
141
  }
139
142
  else {
140
- fetchEvents();
143
+ query === '' && fetchEvents();
141
144
  }
142
- }, [contentAvailability, search, dateSearch, showFollowed, showPastEvents]);
145
+ }, [contentAvailability, dateSearch, showFollowed, showPastEvents, showMyEvents, query]);
143
146
  const handleNext = useMemo(() => () => {
144
147
  if (!next) {
145
148
  return;
@@ -162,7 +165,6 @@ export default function Events(inProps) {
162
165
  */
163
166
  const handleOnChangeFilterName = (event) => {
164
167
  setQuery(event.target.value);
165
- setSearch(false);
166
168
  };
167
169
  /**
168
170
  * Handle change time frame
@@ -174,8 +176,25 @@ export default function Events(inProps) {
174
176
  /**
175
177
  * Renders events list
176
178
  */
177
- const c = (_jsxs(_Fragment, { children: [showFilters && (_jsx(Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !events.length && !showPastEvents }) }))) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: _jsx(TextField, { size: 'small', fullWidth: true, value: query, label: _jsx(FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading, InputProps: {
178
- endAdornment: (_jsx(IconButton, Object.assign({ onClick: () => setSearch(true) }, { children: _jsx(Icon, { children: "search" }) })))
179
+ const c = (_jsxs(_Fragment, { children: [showFilters && (_jsx(Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !events.length && !showPastEvents }) })), (events.length !== 0 || (events.length === 0 && showMyEvents)) && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
180
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
181
+ // @ts-ignore
182
+ , {
183
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
184
+ // @ts-ignore
185
+ color: showMyEvents ? 'secondary' : 'default',
186
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
187
+ // @ts-ignore
188
+ variant: showMyEvents ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
189
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
190
+ // @ts-ignore
191
+ showFollowed: showMyEvents, deleteIcon: showMyEvents ? _jsx(Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null }) })))] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: _jsx(TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: _jsx(FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading, onKeyUp: (e) => {
192
+ e.preventDefault();
193
+ if (e.key === 'Enter') {
194
+ fetchEvents(true);
195
+ }
196
+ }, InputProps: {
197
+ endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? (_jsx(IconButton, Object.assign({ onClick: () => fetchEvents(true) }, { children: _jsx(Icon, { children: "search" }) }))) : (_jsx(Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: _jsx(Icon, { children: "search" }) })) })))
179
198
  } }) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(InputLabel, { children: _jsx(FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), _jsx(Select, Object.assign({ disabled: showPastEvents, size: 'small', label: _jsx(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) => (_jsxs(MenuItem, Object.assign({ value: option.value }, { children: [_jsx(Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), authUserId && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
180
199
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
181
200
  // @ts-ignore
@@ -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
  /**
@@ -5,19 +5,19 @@ import { styled } from '@mui/material/styles';
5
5
  import { Box, useThemeProps } from '@mui/system';
6
6
  import { Endpoints, EventService, http } from '@selfcommunity/api-services';
7
7
  import { SCCache, SCRoutes, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
8
- import { SCFeatureName } from '@selfcommunity/types';
8
+ import { SCEventSubscriptionStatusType, SCFeatureName } from '@selfcommunity/types';
9
9
  import { Logger } from '@selfcommunity/utils';
10
10
  import { useCallback, useEffect, useMemo, useReducer, useState } from 'react';
11
11
  import { FormattedMessage } from 'react-intl';
12
12
  import { SCOPE_SC_UI } from '../../constants/Errors';
13
13
  import { DEFAULT_PAGINATION_LIMIT, DEFAULT_PAGINATION_OFFSET } from '../../constants/Pagination';
14
14
  import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
15
+ import { SCEventTemplateType } from '../../types/event';
15
16
  import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
17
+ import Event from '../Event';
16
18
  import Widget from '../Widget';
17
19
  import { PREFIX } from './constants';
18
20
  import Skeleton from './Skeleton';
19
- import { SCEventTemplateType } from '../../types/event';
20
- import Event from '../Event';
21
21
  const classes = {
22
22
  root: `${PREFIX}-root`,
23
23
  titleWrapper: `${PREFIX}-title-wrapper`,
@@ -45,7 +45,11 @@ export default function MyEventsWidget(inProps) {
45
45
  name: PREFIX
46
46
  });
47
47
  // CONST
48
- const { endpointQueryParams = { limit: DEFAULT_PAGINATION_LIMIT, offset: DEFAULT_PAGINATION_OFFSET }, cacheStrategy } = props, rest = __rest(props, ["endpointQueryParams", "cacheStrategy"]);
48
+ const { endpointQueryParams = {
49
+ limit: DEFAULT_PAGINATION_LIMIT,
50
+ offset: DEFAULT_PAGINATION_OFFSET,
51
+ subscription_status: SCEventSubscriptionStatusType.GOING
52
+ }, cacheStrategy } = props, rest = __rest(props, ["endpointQueryParams", "cacheStrategy"]);
49
53
  // STATE
50
54
  const [state, dispatch] = useReducer(dataWidgetReducer, {
51
55
  isLoadingNext: false,
@@ -91,7 +91,6 @@ const OnBoardingWidget = (inProps) => {
91
91
  }
92
92
  return item;
93
93
  }));
94
- setStep(nextStep);
95
94
  })
96
95
  .catch((error) => {
97
96
  Logger.error(SCOPE_SC_UI, error);
@@ -106,9 +105,6 @@ const OnBoardingWidget = (inProps) => {
106
105
  variant: 'success',
107
106
  autoHideDuration: 7000
108
107
  });
109
- if (_step.step === step.step) {
110
- setStep(nextStep);
111
- }
112
108
  };
113
109
  const getSteps = () => __awaiter(void 0, void 0, void 0, function* () {
114
110
  yield OnBoardingService.getAllSteps()
@@ -4,7 +4,7 @@ import { Alert, Button, CardMedia, Icon, Typography } from '@mui/material';
4
4
  import Box from '@mui/material/Box';
5
5
  import { useThemeProps } from '@mui/system';
6
6
  import classNames from 'classnames';
7
- import { useEffect, useState } from 'react';
7
+ import { useEffect, useMemo, useState } from 'react';
8
8
  import { FormattedMessage } from 'react-intl';
9
9
  import { PREFIX } from '../../constants';
10
10
  import ProgressBar from '../../../../shared/ProgressBar';
@@ -69,6 +69,25 @@ export default function Category(inProps) {
69
69
  return () => clearInterval(intervalId);
70
70
  }
71
71
  }, [step.status, step.completion_percentage]);
72
+ const getLoadingMessage = useMemo(() => {
73
+ let message;
74
+ if (progress <= 10) {
75
+ message = (_jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.loading.a", defaultMessage: "ui.onBoardingWidget.step.categories.loading.a" }));
76
+ }
77
+ else if (progress <= 20) {
78
+ message = (_jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.loading.b", defaultMessage: "ui.onBoardingWidget.step.categories.loading.b" }));
79
+ }
80
+ else if (progress <= 40) {
81
+ message = (_jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.loading.c", defaultMessage: "ui.onBoardingWidget.step.categories.loading.c" }));
82
+ }
83
+ else if (progress <= 60) {
84
+ message = (_jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.loading.d", defaultMessage: "ui.onBoardingWidget.step.categories.loading.d" }));
85
+ }
86
+ else {
87
+ message = (_jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.loading.e", defaultMessage: "ui.onBoardingWidget.step.categories.loading.e" }));
88
+ }
89
+ return message;
90
+ }, [progress]);
72
91
  return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.categories", defaultMessage: "ui.onBoardingWidget.categories" }) })), _jsx(Typography, Object.assign({ className: classes.summary }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.category.summary", defaultMessage: "ui.onBoardingWidget.step.category.summary" }) })), (step === null || step === void 0 ? void 0 : step.status) !== SCOnBoardingStepStatusType.IN_PROGRESS && (_jsxs(_Fragment, { children: [_jsx(Typography, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.category.generation.steps", defaultMessage: "ui.onBoardingWidget.step.category.generation.steps", values: {
73
92
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
74
93
  // @ts-ignore
@@ -79,5 +98,5 @@ export default function Category(inProps) {
79
98
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
80
99
  // @ts-ignore
81
100
  iconC: (...chunks) => _jsx(CircledLetter, { letter: "c", statement: chunks })
82
- } }) }), _jsx(CardMedia, { className: classes.image, component: "img", src: CategoryAPlaceholder }), _jsx(CardMedia, { className: classes.image, component: "img", src: CategoryBPlaceholder })] })), _jsx(Box, Object.assign({ component: "span", className: classes.action }, { children: (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.COMPLETED ? (_jsx(Alert, Object.assign({ severity: "success" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.success", defaultMessage: "ui.onBoardingWidget.step.categories.success" }) }))) : (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.IN_PROGRESS ? (_jsxs(Box, Object.assign({ className: classes.progress }, { children: [_jsx(Player, { autoplay: true, loop: true, src: animatedProgress, className: classes.animationProgress, controls: false }), _jsx(ProgressBar, { value: progress, hideBar: true, loadingMessage: _jsx(Typography, Object.assign({ variant: "h4" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.loading", defaultMessage: "ui.onBoardingWidget.step.categories.loading" }) })) })] }))) : (_jsx(Button, Object.assign({ size: "small", variant: "contained", color: "secondary", onClick: handleCategoriesCreation, endIcon: _jsx(Icon, { children: hover ? 'ai_stars' : 'magic_wand' }), onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.onBoardingWidget.step.category.button", id: "ui.onBoardingWidget.step.category.button" }) }))) }))] })));
101
+ } }) }), _jsx(CardMedia, { className: classes.image, component: "img", src: CategoryAPlaceholder }), _jsx(CardMedia, { className: classes.image, component: "img", src: CategoryBPlaceholder })] })), _jsx(Box, Object.assign({ component: "span", className: classes.action }, { children: (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.COMPLETED ? (_jsx(Alert, Object.assign({ severity: "success" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.success", defaultMessage: "ui.onBoardingWidget.step.categories.success" }) }))) : (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.IN_PROGRESS ? (_jsxs(Box, Object.assign({ className: classes.progress }, { children: [_jsx(Player, { autoplay: true, loop: true, src: animatedProgress, className: classes.animationProgress, controls: false }), _jsx(ProgressBar, { value: progress, hideBar: true, loadingMessage: _jsx(Typography, Object.assign({ variant: "h4" }, { children: getLoadingMessage })) })] }))) : (_jsx(Button, Object.assign({ size: "small", variant: "contained", color: "secondary", onClick: handleCategoriesCreation, endIcon: _jsx(Icon, { children: hover ? 'ai_stars' : 'magic_wand' }), onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.onBoardingWidget.step.category.button", id: "ui.onBoardingWidget.step.category.button" }) }))) }))] })));
83
102
  }
@@ -4,7 +4,7 @@ import { Alert, Button, Icon, Typography } from '@mui/material';
4
4
  import Box from '@mui/material/Box';
5
5
  import { useThemeProps } from '@mui/system';
6
6
  import classNames from 'classnames';
7
- import { useEffect, useState } from 'react';
7
+ import { useEffect, useMemo, useState } from 'react';
8
8
  import { PREFIX } from '../../constants';
9
9
  import { FormattedMessage } from 'react-intl';
10
10
  import { SCOnBoardingStepStatusType } from '@selfcommunity/types';
@@ -49,5 +49,24 @@ export default function Content(inProps) {
49
49
  return () => clearInterval(intervalId);
50
50
  }
51
51
  }, [step.status, step.completion_percentage]);
52
- return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.contents", defaultMessage: "ui.onBoardingWidget.contents" }) })), _jsx(Typography, Object.assign({ className: classes.summary }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.content.summary", defaultMessage: "ui.onBoardingWidget.step.content.summary" }) })), _jsx(Box, Object.assign({ component: "span", className: classes.action }, { children: (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.COMPLETED ? (_jsx(Alert, Object.assign({ severity: "success" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.success", defaultMessage: "ui.onBoardingWidget.step.contents.success" }) }))) : (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.IN_PROGRESS ? (_jsxs(Box, Object.assign({ className: classes.progress }, { children: [_jsx(Player, { autoplay: true, loop: true, src: animatedProgress, className: classes.animationProgress, controls: false }), _jsx(ProgressBar, { value: progress, hideBar: true, loadingMessage: _jsx(Typography, Object.assign({ variant: "h4" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.loading", defaultMessage: "ui.onBoardingWidget.step.contents.loading" }) })) })] }))) : (_jsx(Button, Object.assign({ size: "small", variant: "contained", color: "secondary", onClick: handleContentCreation, endIcon: _jsx(Icon, { children: hover ? 'ai_stars' : 'magic_wand' }), onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.onBoardingWidget.step.content.button", id: "ui.onBoardingWidget.step.content.button" }) }))) }))] })));
52
+ const getLoadingMessage = useMemo(() => {
53
+ let message;
54
+ if (progress <= 10) {
55
+ message = _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.loading.a", defaultMessage: "ui.onBoardingWidget.step.contents.loading.a" });
56
+ }
57
+ else if (progress <= 20) {
58
+ message = _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.loading.b", defaultMessage: "ui.onBoardingWidget.step.contents.loading.b" });
59
+ }
60
+ else if (progress <= 40) {
61
+ message = _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.loading.c", defaultMessage: "ui.onBoardingWidget.step.contents.loading.c" });
62
+ }
63
+ else if (progress <= 60) {
64
+ message = _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.loading.d", defaultMessage: "ui.onBoardingWidget.step.contents.loading.d" });
65
+ }
66
+ else {
67
+ message = _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.loading.e", defaultMessage: "ui.onBoardingWidget.step.contents.loading.e" });
68
+ }
69
+ return message;
70
+ }, [progress]);
71
+ return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.contents", defaultMessage: "ui.onBoardingWidget.contents" }) })), _jsx(Typography, Object.assign({ className: classes.summary }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.content.summary", defaultMessage: "ui.onBoardingWidget.step.content.summary" }) })), _jsx(Box, Object.assign({ component: "span", className: classes.action }, { children: (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.COMPLETED ? (_jsx(Alert, Object.assign({ severity: "success" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.contents.success", defaultMessage: "ui.onBoardingWidget.step.contents.success" }) }))) : (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.IN_PROGRESS ? (_jsxs(Box, Object.assign({ className: classes.progress }, { children: [_jsx(Player, { autoplay: true, loop: true, src: animatedProgress, className: classes.animationProgress, controls: false }), _jsx(ProgressBar, { value: progress, hideBar: true, loadingMessage: _jsx(Typography, Object.assign({ variant: "h4" }, { children: getLoadingMessage })) })] }))) : (_jsx(Button, Object.assign({ size: "small", variant: "contained", color: "secondary", onClick: handleContentCreation, endIcon: _jsx(Icon, { children: hover ? 'ai_stars' : 'magic_wand' }), onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.onBoardingWidget.step.content.button", id: "ui.onBoardingWidget.step.content.button" }) }))) }))] })));
53
72
  }
@@ -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";
@@ -14,5 +14,6 @@ export const EDIT_CONTRIBUTION = '_edit_contribution';
14
14
  export const DELETE_CONTRIBUTION = '_delete_contribution';
15
15
  export const RESTORE_CONTRIBUTION = '_restore_contribution';
16
16
  export const SUSPEND_NOTIFICATION_CONTRIBUTION = '_suspend_notification_contribution';
17
+ export const SUSPEND_NOTIFICATION_EVENT = '_suspend_notification_event';
17
18
  export const MODERATE_CONTRIBUTION_HIDDEN = '_moderate_contribution_hidden';
18
19
  export const 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
@@ -17,7 +17,7 @@ import { MODERATION_CONTRIBUTION_STATE_DELETED, MODERATION_CONTRIBUTION_STATE_HI
17
17
  import { Endpoints, http } from '@selfcommunity/api-services';
18
18
  import { SCContext, SCUserContext, UserUtils, useSCFetchCommentObject, useSCFetchFeedObject, useSCRouting } from '@selfcommunity/react-core';
19
19
  import { SCContributionType } from '@selfcommunity/types';
20
- import { DELETE_CONTRIBUTION, DELETE_CONTRIBUTION_SECTION, EDIT_CONTRIBUTION, FLAG_CONTRIBUTION_SECTION, GENERAL_SECTION, GET_CONTRIBUTION_PERMALINK, HIDE_CONTRIBUTION_SECTION, MODERATE_CONTRIBUTION_DELETED, MODERATE_CONTRIBUTION_HIDDEN, RESTORE_CONTRIBUTION, SUSPEND_NOTIFICATION_CONTRIBUTION } from '../../constants/ContributionsActionsMenu';
20
+ import { DELETE_CONTRIBUTION, DELETE_CONTRIBUTION_SECTION, EDIT_CONTRIBUTION, FLAG_CONTRIBUTION_SECTION, GENERAL_SECTION, GET_CONTRIBUTION_PERMALINK, HIDE_CONTRIBUTION_SECTION, MODERATE_CONTRIBUTION_DELETED, MODERATE_CONTRIBUTION_HIDDEN, RESTORE_CONTRIBUTION, SUSPEND_NOTIFICATION_CONTRIBUTION, SUSPEND_NOTIFICATION_EVENT } from '../../constants/ContributionsActionsMenu';
21
21
  const PREFIX = 'SCContributionActionsMenu';
22
22
  const classes = {
23
23
  root: `${PREFIX}-root`,
@@ -76,7 +76,7 @@ const messages = defineMessages({
76
76
  });
77
77
  export default function ContributionActionsMenu(props) {
78
78
  // PROPS
79
- const { className, feedObjectId, feedObject, feedObjectType = SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, PopperProps = {} } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "PopperProps"]);
79
+ const { className, feedObjectId, feedObject, feedObjectType = SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, onSuspendNotificationEvent, PopperProps = {} } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "onSuspendNotificationEvent", "PopperProps"]);
80
80
  // INTL
81
81
  const intl = useIntl();
82
82
  // CONTEXT
@@ -171,7 +171,7 @@ export default function ContributionActionsMenu(props) {
171
171
  }
172
172
  }
173
173
  /**
174
- * Performs notification suspension
174
+ * Performs notification suspension
175
175
  */
176
176
  const performSuspendNotification = useMemo(() => () => {
177
177
  return http
@@ -186,14 +186,30 @@ export default function ContributionActionsMenu(props) {
186
186
  return Promise.resolve(res.data);
187
187
  });
188
188
  }, [contributionObj]);
189
+ /**
190
+ * Performs notification suspension of event embedded
191
+ */
192
+ const performSuspendNotificationEvent = useMemo(() => () => {
193
+ const _endpoint = contributionObj.event.show_on_feed ? Endpoints.HideEvent : Endpoints.ShowEvent;
194
+ return http
195
+ .request({
196
+ url: _endpoint.url({ id: contributionObj.event.id }),
197
+ method: _endpoint.method
198
+ })
199
+ .then((res) => {
200
+ if (res.status >= 300) {
201
+ return Promise.reject(res);
202
+ }
203
+ return Promise.resolve(res.data);
204
+ });
205
+ }, [contributionObj]);
189
206
  /**
190
207
  * Handles stop notification for contributionObj
191
- * @param contribution
192
208
  */
193
209
  function handleSuspendContentNotification() {
194
210
  setCurrentActionLoading(SUSPEND_NOTIFICATION_CONTRIBUTION);
195
211
  performSuspendNotification()
196
- .then((data) => {
212
+ .then(() => {
197
213
  const _feedObj = Object.assign({}, feedObj, { suspended: !feedObj.suspended });
198
214
  setFeedObj(_feedObj);
199
215
  onSuspendNotificationContribution && onSuspendNotificationContribution(_feedObj);
@@ -209,6 +225,29 @@ export default function ContributionActionsMenu(props) {
209
225
  });
210
226
  });
211
227
  }
228
+ /**
229
+ * Handles stop notification for event embedded in contributionObj
230
+ */
231
+ function handleSuspendEventNotification() {
232
+ setCurrentActionLoading(SUSPEND_NOTIFICATION_EVENT);
233
+ performSuspendNotificationEvent()
234
+ .then(() => {
235
+ const _eventObj = Object.assign({}, feedObj.event, { show_on_feed: !feedObj.event.show_on_feed });
236
+ const _feedObj = Object.assign({}, feedObj, { event: _eventObj });
237
+ setFeedObj(_feedObj);
238
+ onSuspendNotificationEvent && onSuspendNotificationEvent(_feedObj);
239
+ setCurrentActionLoading(null);
240
+ })
241
+ .catch((error) => {
242
+ Logger.error(SCOPE_SC_UI, error);
243
+ setCurrentAction(null);
244
+ setCurrentActionLoading(null);
245
+ enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.contributionActionMenu.actionError", defaultMessage: "ui.contributionActionMenu.actionError" }), {
246
+ variant: 'error',
247
+ autoHideDuration: 3000
248
+ });
249
+ });
250
+ }
212
251
  /**
213
252
  * Get Status Flag
214
253
  */
@@ -353,7 +392,7 @@ export default function ContributionActionsMenu(props) {
353
392
  else if (contributionObj && !isLoading && !isFlagging && type !== 'undefined') {
354
393
  setIsFlagging(true);
355
394
  performFlag(type)
356
- .then((data) => {
395
+ .then(() => {
357
396
  setFlagType(flagType === type ? null : type);
358
397
  setIsFlagging(false);
359
398
  onFlagContribution && onFlagContribution(contributionObj, type, flagType !== type);
@@ -441,6 +480,10 @@ export default function ContributionActionsMenu(props) {
441
480
  setCurrentAction(SUSPEND_NOTIFICATION_CONTRIBUTION);
442
481
  handleSuspendContentNotification();
443
482
  }
483
+ else if (action === SUSPEND_NOTIFICATION_EVENT) {
484
+ setCurrentAction(SUSPEND_NOTIFICATION_EVENT);
485
+ handleSuspendEventNotification();
486
+ }
444
487
  else if (action === MODERATE_CONTRIBUTION_HIDDEN) {
445
488
  setCurrentAction(MODERATE_CONTRIBUTION_HIDDEN);
446
489
  setOpenConfirmDialog(true);
@@ -494,7 +537,7 @@ export default function ContributionActionsMenu(props) {
494
537
  if (currentAction === DELETE_CONTRIBUTION) {
495
538
  setCurrentActionLoading(DELETE_CONTRIBUTION);
496
539
  performDeleteContribution()
497
- .then((data) => {
540
+ .then(() => {
498
541
  const _contributionObj = Object.assign({}, contributionObj, { deleted: true });
499
542
  onDeleteContribution && onDeleteContribution(_contributionObj);
500
543
  performPostConfirmAction(true);
@@ -507,7 +550,7 @@ export default function ContributionActionsMenu(props) {
507
550
  else if (currentAction === RESTORE_CONTRIBUTION) {
508
551
  setCurrentActionLoading(RESTORE_CONTRIBUTION);
509
552
  performRestoreContribution()
510
- .then((data) => {
553
+ .then(() => {
511
554
  const _contributionObj = Object.assign({}, contributionObj, { deleted: false });
512
555
  onRestoreContribution && onRestoreContribution(_contributionObj);
513
556
  performPostConfirmAction(true);
@@ -520,7 +563,7 @@ export default function ContributionActionsMenu(props) {
520
563
  else if (currentAction === MODERATE_CONTRIBUTION_HIDDEN) {
521
564
  setCurrentActionLoading(MODERATE_CONTRIBUTION_HIDDEN);
522
565
  performModerationContribution(MODERATION_TYPE_ACTION_HIDE, hideFlagType)
523
- .then((data) => {
566
+ .then(() => {
524
567
  const _contributionObj = Object.assign({}, contributionObj, { collapsed: !contributionObj.collapsed });
525
568
  setHideType(hideType === hideFlagType ? null : hideFlagType);
526
569
  setHideFlagType(null);
@@ -535,7 +578,7 @@ export default function ContributionActionsMenu(props) {
535
578
  else if (currentAction === MODERATE_CONTRIBUTION_DELETED) {
536
579
  setCurrentActionLoading(MODERATE_CONTRIBUTION_DELETED);
537
580
  performModerationContribution(MODERATION_TYPE_ACTION_DELETE, deleteFlagType)
538
- .then((data) => {
581
+ .then(() => {
539
582
  const _contributionObj = Object.assign({}, contributionObj, { deleted: !contributionObj.deleted });
540
583
  setDeleteType(deleteType === deleteFlagType ? null : deleteFlagType);
541
584
  setDeleteFlagType(null);
@@ -578,9 +621,9 @@ export default function ContributionActionsMenu(props) {
578
621
  return name;
579
622
  }
580
623
  /**
581
- * action
582
- * @param actionId
583
- */
624
+ * action
625
+ * @param sectionId
626
+ */
584
627
  function handleOpenSection(sectionId) {
585
628
  if (sectionId) {
586
629
  if (sectionId === openSection) {
@@ -651,11 +694,21 @@ export default function ContributionActionsMenu(props) {
651
694
  contributionObj &&
652
695
  contributionObj.type !== SCContributionType.COMMENT);
653
696
  }
697
+ /**
698
+ * Can authenticated user suspend notification for the event related to the contribution
699
+ */
700
+ function canSuspendNotificationEvent() {
701
+ return (scUserContext.user &&
702
+ scUserContext.user.id !== contributionObj.author.id &&
703
+ contributionObj &&
704
+ contributionObj.type !== SCContributionType.COMMENT &&
705
+ Boolean(contributionObj.event));
706
+ }
654
707
  /**
655
708
  * Renders section general
656
709
  */
657
710
  function renderGeneralSection() {
658
- return (_jsxs(Box, { children: [_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "link" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "edit" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === DELETE_CONTRIBUTION || currentActionLoading === RESTORE_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : (_jsx(Icon, { children: "delete" })) }), contributionObj.deleted ? (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === SUSPEND_NOTIFICATION_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : contributionObj['suspended'] ? (_jsx(Icon, { children: "notifications_active" })) : (_jsx(Icon, { children: "notifications_off" })) }), _jsx(ListItemText, { primary: contributionObj['suspended'] ? (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] })))] }, GENERAL_SECTION));
711
+ return (_jsxs(Box, { children: [_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "link" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "edit" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === DELETE_CONTRIBUTION || currentActionLoading === RESTORE_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : (_jsx(Icon, { children: "delete" })) }), contributionObj.deleted ? (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === SUSPEND_NOTIFICATION_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : contributionObj['suspended'] ? (_jsx(Icon, { children: "notifications_active" })) : (_jsx(Icon, { children: "notifications_off" })) }), _jsx(ListItemText, { primary: contributionObj['suspended'] ? (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canSuspendNotificationEvent() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === SUSPEND_NOTIFICATION_EVENT ? (_jsx(CircularProgress, { size: 20 })) : contributionObj.event['show_on_feed'] ? (_jsx(Icon, { children: "notifications_active" })) : (_jsx(Icon, { children: "notifications_off" })) }), _jsx(ListItemText, { primary: !contributionObj.event['show_on_feed'] ? (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(SUSPEND_NOTIFICATION_EVENT), classes: { root: classes.itemText } })] })))] }, GENERAL_SECTION));
659
712
  }
660
713
  /**
661
714
  * Renders contribution menu content
@@ -12,6 +12,7 @@ export interface EventInfoDetailsProps {
12
12
  hasPrivacyInfo?: boolean;
13
13
  hasLocationInfo?: boolean;
14
14
  hasCreatedInfo?: boolean;
15
+ hasInProgress?: boolean;
15
16
  beforeDateInfo?: ReactNode | null;
16
17
  beforeRecurringInfo?: ReactNode | null;
17
18
  beforePrivacyInfo?: ReactNode | null;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Icon, Stack, styled, Typography, useThemeProps } from '@mui/material';
2
+ import { Box, Icon, Stack, styled, Tooltip, Typography, useThemeProps } from '@mui/material';
3
3
  import { Link } from '@selfcommunity/react-core';
4
4
  import { SCEventLocationType, SCEventPrivacyType, SCEventRecurrenceType } from '@selfcommunity/types';
5
5
  import { useMemo } from 'react';
@@ -8,6 +8,7 @@ const PREFIX = 'SCEventInfoDetails';
8
8
  const classes = {
9
9
  root: `${PREFIX}-root`,
10
10
  iconTextWrapper: `${PREFIX}-icon-text-wrapper`,
11
+ live: `${PREFIX}-live`,
11
12
  link: `${PREFIX}-link`,
12
13
  url: `${PREFIX}-url`,
13
14
  creationWrapper: `${PREFIX}-creation-wrapper`
@@ -23,7 +24,7 @@ export default function EventInfoDetails(inProps) {
23
24
  props: inProps,
24
25
  name: PREFIX
25
26
  });
26
- 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;
27
+ 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;
27
28
  // HOOKS
28
29
  const intl = useIntl();
29
30
  const privacy = useMemo(() => (event.privacy === SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private'), [event]);
@@ -36,7 +37,7 @@ export default function EventInfoDetails(inProps) {
36
37
  month: 'long'
37
38
  }),
38
39
  start: intl.formatDate(event.running ? event.running_start_date : event.next_start_date, { hour: 'numeric', minute: 'numeric' })
39
- } }) }))] }))), beforeRecurringInfo, hasRecurringInfo && event.recurring !== SCEventRecurrenceType.NEVER && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && (_jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.location === SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === SCEventLocationType.ONLINE ? (_jsx(Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: _jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && (_jsxs(Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "create" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
40
+ } }) })), hasInProgress && (_jsx(Tooltip, Object.assign({ title: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.inProgress", defaultMessage: "ui.eventInfoDetails.inProgress" }) }, { children: _jsx(Box, { className: classes.live }) })))] }))), beforeRecurringInfo, hasRecurringInfo && event.recurring !== SCEventRecurrenceType.NEVER && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && (_jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.location === SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === SCEventLocationType.ONLINE ? (_jsx(Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: _jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && (_jsxs(Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "create" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
40
41
  date: intl.formatDate(event.created_at, {
41
42
  weekday: 'long',
42
43
  day: 'numeric',