@selfcommunity/react-ui 0.9.0-alpha.10 → 0.9.0-alpha.12

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.
@@ -0,0 +1,81 @@
1
+ import { __rest } from "tslib";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { styled } from '@mui/material/styles';
5
+ import { Icon, IconButton, List, ListItem, ListItemButton, ListItemIcon, Menu, MenuItem, SwipeableDrawer, useMediaQuery, useTheme } from '@mui/material';
6
+ import classNames from 'classnames';
7
+ import { useThemeProps } from '@mui/system';
8
+ import { FormattedMessage } from 'react-intl';
9
+ import { PreferenceService } from '@selfcommunity/api-services';
10
+ import { SCOPE_SC_UI } from '../../constants/Errors';
11
+ import { Logger } from '@selfcommunity/utils';
12
+ import { SCPreferenceName } from '@selfcommunity/types';
13
+ import { PREFIX } from './constants';
14
+ const classes = {
15
+ root: `${PREFIX}-actions-button-root`,
16
+ drawerRoot: `${PREFIX}-actions-drawer-root`,
17
+ menuRoot: `${PREFIX}-actions-menu-root`,
18
+ paper: `${PREFIX}-actions-paper`,
19
+ item: `${PREFIX}-actions-item`
20
+ };
21
+ const Root = styled(IconButton, {
22
+ name: PREFIX,
23
+ slot: 'Root',
24
+ overridesResolver: (props, styles) => styles.root
25
+ })(() => ({}));
26
+ const SwipeableDrawerRoot = styled(SwipeableDrawer, {
27
+ name: PREFIX,
28
+ slot: 'Root',
29
+ overridesResolver: (props, styles) => styles.drawerRoot
30
+ })(() => ({}));
31
+ const MenuRoot = styled(Menu, {
32
+ name: PREFIX,
33
+ slot: 'Root',
34
+ overridesResolver: (props, styles) => styles.menuRoot
35
+ })(() => ({}));
36
+ export default function OnBoardingActionsButton(inProps) {
37
+ // PROPS
38
+ const props = useThemeProps({
39
+ props: inProps,
40
+ name: PREFIX
41
+ });
42
+ const { className = null, isExpanded, onExpandChange, onHideOnBoarding } = props, rest = __rest(props, ["className", "isExpanded", "onExpandChange", "onHideOnBoarding"]);
43
+ // STATE
44
+ const [anchorEl, setAnchorEl] = useState(null);
45
+ const theme = useTheme();
46
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
47
+ // HANDLERS
48
+ const handleOpen = (event) => {
49
+ setAnchorEl(event.currentTarget);
50
+ };
51
+ const handleClose = () => {
52
+ setAnchorEl(null);
53
+ };
54
+ /**
55
+ * Updates onBoarding dynamic preference
56
+ */
57
+ const hideOnBoarding = () => {
58
+ PreferenceService.updatePreferences({ [`${SCPreferenceName.ONBOARDING_HIDDEN}`]: true })
59
+ .then(() => {
60
+ onHideOnBoarding();
61
+ })
62
+ .catch((e) => {
63
+ Logger.error(SCOPE_SC_UI, e);
64
+ });
65
+ };
66
+ const renderList = () => {
67
+ if (isMobile) {
68
+ return [
69
+ isExpanded ? (_jsx(ListItem, Object.assign({ className: classes.item }, { children: _jsxs(ListItemButton, Object.assign({ onClick: onExpandChange }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "expand_less" }) }), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.actionsMenu.view.less", defaultMessage: "ui.onBoardingWidget.actionsMenu.view.less" })] })) }), "expand_less")) : (_jsx(ListItem, Object.assign({ className: classes.item }, { children: _jsxs(ListItemButton, Object.assign({ onClick: onExpandChange }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "expand_more" }) }), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.actionsMenu.view.more", defaultMessage: "ui.onBoardingWidget.actionsMenu.view.more" })] })) }), "expand_more")),
70
+ _jsx(ListItem, Object.assign({ className: classes.item }, { children: _jsxs(ListItemButton, Object.assign({ onClick: hideOnBoarding }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "close" }) }), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.actionsMenu.close", defaultMessage: "ui.onBoardingWidget.actionsMenu.close" })] })) }), "close")
71
+ ];
72
+ }
73
+ else {
74
+ return [
75
+ isExpanded ? (_jsxs(MenuItem, Object.assign({ className: classes.item, onClick: onExpandChange }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "expand_less" }) }), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.actionsMenu.view.less", defaultMessage: "ui.onBoardingWidget.actionsMenu.view.less" })] }), "expand_less")) : (_jsxs(MenuItem, Object.assign({ className: classes.item, onClick: onExpandChange }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "expand_more" }) }), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.actionsMenu.view.more", defaultMessage: "ui.onBoardingWidget.actionsMenu.view.more" })] }), "expand_more")),
76
+ _jsxs(MenuItem, Object.assign({ className: classes.item, onClick: hideOnBoarding }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "close" }) }), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.actionsMenu.close", defaultMessage: "ui.onBoardingWidget.actionsMenu.close" })] }), "close")
77
+ ];
78
+ }
79
+ };
80
+ return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { onClick: handleOpen }, { children: _jsx(Icon, { children: "more_vert" }) })), isMobile ? (_jsx(SwipeableDrawerRoot, Object.assign({ onClick: () => setAnchorEl(null), className: classes.drawerRoot, anchor: "bottom", open: Boolean(anchorEl), onClose: handleClose, onOpen: handleOpen, PaperProps: { className: classes.paper }, disableSwipeToOpen: true }, { children: _jsx(List, { children: renderList() }) }))) : (_jsx(MenuRoot, Object.assign({ onClick: () => setAnchorEl(null), className: classes.menuRoot, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, PaperProps: { className: classes.paper } }, { children: renderList() })))] }));
81
+ }
@@ -8,7 +8,7 @@ import classNames from 'classnames';
8
8
  import { useThemeProps } from '@mui/system';
9
9
  import Category from './Steps/Category';
10
10
  import { PREFIX } from './constants';
11
- import { getTheme, usePreviousValue, UserUtils, useSCContext, useSCFetchCategories, useSCPreferences, useSCTheme, useSCUser } from '@selfcommunity/react-core';
11
+ import { getTheme, SCPreferences, usePreviousValue, UserUtils, useSCContext, useSCFetchCategories, useSCPreferences, useSCTheme, useSCUser } from '@selfcommunity/react-core';
12
12
  import Appearance from './Steps/Appearance';
13
13
  import Profile from './Steps/Profile';
14
14
  import Invite from './Steps/Invite';
@@ -19,13 +19,14 @@ import Content from './Steps/Content';
19
19
  import { SCOPE_SC_UI } from '../../constants/Errors';
20
20
  import { Endpoints, http, OnBoardingService, PreferenceService } from '@selfcommunity/api-services';
21
21
  import { Logger } from '@selfcommunity/utils';
22
- import { SCOnBoardingStepStatusType, SCOnBoardingStepType } from '@selfcommunity/types';
22
+ import { SCOnBoardingStepStatusType, SCOnBoardingStepType, SCOnBoardingStepIdType } from '@selfcommunity/types';
23
23
  import OnBoardingWidgetSkeleton from './Skeleton';
24
24
  import { closeSnackbar, useSnackbar } from 'notistack';
25
25
  import HeaderPlaceholder from '../../assets/onBoarding/header';
26
26
  import BaseDialog from '../../shared/BaseDialog';
27
27
  import PubSub from 'pubsub-js';
28
28
  import { SCCategoryEventType, SCTopicType } from '../../constants/PubSub';
29
+ import OnBoardingActionsButton from './ActionsButton';
29
30
  const classes = {
30
31
  root: `${PREFIX}-root`,
31
32
  content: `${PREFIX}-content`,
@@ -34,7 +35,9 @@ const classes = {
34
35
  intro: `${PREFIX}-intro`,
35
36
  steps: `${PREFIX}-steps`,
36
37
  stepsMobile: `${PREFIX}-steps-mobile`,
37
- stepContent: `${PREFIX}-step-content`
38
+ stepContent: `${PREFIX}-step-content`,
39
+ dialogRoot: `${PREFIX}-dialog-root`,
40
+ dialogContent: `${PREFIX}-dialog-content`
38
41
  };
39
42
  const Root = styled(Widget, {
40
43
  name: PREFIX,
@@ -46,6 +49,11 @@ const AccordionRoot = styled(Accordion, {
46
49
  slot: 'AccordionRoot',
47
50
  overridesResolver: (props, styles) => styles.accordionRoot
48
51
  })(() => ({}));
52
+ const DialogRoot = styled(BaseDialog, {
53
+ name: PREFIX,
54
+ slot: 'Root',
55
+ overridesResolver: (props, styles) => styles.dialogRoot
56
+ })(({ theme }) => ({}));
49
57
  const OnBoardingWidget = (inProps) => {
50
58
  // PROPS
51
59
  const props = useThemeProps({
@@ -70,7 +78,9 @@ const OnBoardingWidget = (inProps) => {
70
78
  const prevContentsStep = usePreviousValue(currentContentsStep);
71
79
  const currentCategoriesStep = steps === null || steps === void 0 ? void 0 : steps.find((s) => s.step === SCOnBoardingStepType.CATEGORIES);
72
80
  const prevCategoriesStep = usePreviousValue(currentCategoriesStep);
73
- const [showCategoriesModal, setShowCategoriesModal] = useState(false);
81
+ const [showNoCategoriesModal, setShowNoCategoriesModal] = useState(false);
82
+ const [showCategoriesWarningModal, setShowWarningCategoriesModal] = useState(false);
83
+ const [isGenerating, setIsGenerating] = useState(false);
74
84
  // CONTEXT
75
85
  const scUserContext = useSCUser();
76
86
  const isAdmin = useMemo(() => UserUtils.isCommunityCreator(scUserContext.user), [scUserContext.user]);
@@ -78,7 +88,11 @@ const OnBoardingWidget = (inProps) => {
78
88
  const scPreferencesContext = useSCPreferences();
79
89
  const scThemeContext = useSCTheme();
80
90
  const { enqueueSnackbar } = useSnackbar();
81
- const [isGenerating, setIsGenerating] = useState(false);
91
+ const showOnBoarding = useMemo(() => scPreferencesContext.preferences &&
92
+ SCPreferences.CONFIGURATIONS_ONBOARDING_ENABLED in scPreferencesContext.preferences &&
93
+ SCPreferences.CONFIGURATIONS_ONBOARDING_HIDDEN in scPreferencesContext.preferences &&
94
+ scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_ONBOARDING_ENABLED].value &&
95
+ !scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_ONBOARDING_HIDDEN].value, [scPreferencesContext.preferences]);
82
96
  // HOOKS
83
97
  const theme = useTheme();
84
98
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
@@ -164,22 +178,29 @@ const OnBoardingWidget = (inProps) => {
164
178
  };
165
179
  const generateContent = (stepId) => __awaiter(void 0, void 0, void 0, function* () {
166
180
  if (!isLoading && !categories.length) {
167
- setShowCategoriesModal(true);
181
+ setShowNoCategoriesModal(true);
182
+ }
183
+ else if (stepId === SCOnBoardingStepIdType.CATEGORIES) {
184
+ setShowWarningCategoriesModal(true);
168
185
  }
169
186
  else {
170
- yield OnBoardingService.startAStep(stepId, GenerateContentsParams)
171
- .then(() => {
172
- setIsGenerating(true);
173
- })
174
- .catch((error) => {
175
- Logger.error(SCOPE_SC_UI, error);
176
- enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
177
- variant: 'error',
178
- autoHideDuration: 3000
179
- });
180
- });
187
+ yield startStep(stepId);
181
188
  }
182
189
  });
190
+ const startStep = (stepId) => __awaiter(void 0, void 0, void 0, function* () {
191
+ showCategoriesWarningModal && setShowWarningCategoriesModal(false);
192
+ yield OnBoardingService.startAStep(stepId, GenerateContentsParams)
193
+ .then(() => {
194
+ setIsGenerating(true);
195
+ })
196
+ .catch((error) => {
197
+ Logger.error(SCOPE_SC_UI, error);
198
+ enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
199
+ variant: 'error',
200
+ autoHideDuration: 3000
201
+ });
202
+ });
203
+ });
183
204
  const handlePreferencesUpdate = () => {
184
205
  PreferenceService.getAllPreferences().then((preferences) => {
185
206
  const prefs = preferences['results'].reduce((obj, p) => (Object.assign(Object.assign({}, obj), { [`${p.section}.${p.name}`]: p })), {});
@@ -189,7 +210,7 @@ const OnBoardingWidget = (inProps) => {
189
210
  };
190
211
  const handleCategoriesClick = () => {
191
212
  fetchPlatform('/contents/interests/');
192
- setShowCategoriesModal(false);
213
+ setShowNoCategoriesModal(false);
193
214
  };
194
215
  /**
195
216
  * Notify when a category info changes
@@ -279,10 +300,10 @@ const OnBoardingWidget = (inProps) => {
279
300
  }
280
301
  return content;
281
302
  };
282
- if (!isAdmin) {
303
+ if (!isAdmin || !showOnBoarding) {
283
304
  return _jsx(HiddenPlaceholder, {});
284
305
  }
285
- return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsxs(AccordionRoot, Object.assign({ defaultExpanded: true, onChange: handleExpand, className: classes.accordionRoot, expanded: expanded }, { children: [_jsx(AccordionSummary, Object.assign({ expandIcon: _jsx(Icon, Object.assign({ fontSize: "medium" }, { children: "expand_more" })), "aria-controls": "accordion", id: "onBoarding-accordion" }, { children: _jsx(_Fragment, { children: expanded ? (_jsxs(_Fragment, { children: [!isMobile ? (_jsx(CardMedia, { className: classes.logo, component: "img", src: HeaderPlaceholder })) : (_jsxs(Typography, Object.assign({ variant: "h4" }, { children: [_jsx(Icon, Object.assign({ color: "secondary", fontSize: "medium" }, { children: "ai_stars" })), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.accordion.expanded.title.mobile", defaultMessage: "ui.onBoardingWidget.accordion.expanded.title.mobile", values: {
306
+ return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsxs(AccordionRoot, Object.assign({ defaultExpanded: true, className: classes.accordionRoot, expanded: expanded }, { children: [_jsx(AccordionSummary, Object.assign({ expandIcon: _jsx(OnBoardingActionsButton, { isExpanded: expanded, onExpandChange: handleExpand, onHideOnBoarding: handlePreferencesUpdate }), "aria-controls": "accordion", id: "onBoarding-accordion" }, { children: _jsx(_Fragment, { children: expanded ? (_jsxs(_Fragment, { children: [!isMobile ? (_jsx(CardMedia, { className: classes.logo, component: "img", src: HeaderPlaceholder })) : (_jsxs(Typography, Object.assign({ variant: "h4" }, { children: [_jsx(Icon, Object.assign({ color: "secondary", fontSize: "medium" }, { children: "ai_stars" })), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.accordion.expanded.title.mobile", defaultMessage: "ui.onBoardingWidget.accordion.expanded.title.mobile", values: {
286
307
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
287
308
  // @ts-ignore
288
309
  b: (chunks) => _jsx("strong", { children: chunks })
@@ -301,6 +322,10 @@ const OnBoardingWidget = (inProps) => {
301
322
  // @ts-ignore
302
323
  // eslint-disable-next-line prettier/prettier
303
324
  icon: (...chunks) => _jsx(Icon, Object.assign({ color: "secondary", fontSize: "medium" }, { children: chunks }))
304
- } }) }))) }) })), _jsx(AccordionDetails, { children: _jsx(Widget, Object.assign({ className: classes.content, elevation: 0 }, { children: loading ? (_jsx(OnBoardingWidgetSkeleton, {})) : (_jsxs(CardContent, { children: [_jsx(List, Object.assign({ className: isMobile ? classes.stepsMobile : classes.steps }, { children: steps === null || steps === void 0 ? void 0 : steps.map((step) => (_jsx(ListItem, { children: isMobile ? (_jsx(Chip, { size: "small", label: _jsxs(_Fragment, { children: [_jsx(FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }), ' ', step.status === SCOnBoardingStepStatusType.COMPLETED && (_jsx(Icon, Object.assign({ color: (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.COMPLETED && (step === null || step === void 0 ? void 0 : step.step) !== (_step === null || _step === void 0 ? void 0 : _step.step) ? 'success' : 'inherit' }, { children: "check" })))] }), onClick: () => handleChange(step), variant: step.step === (_step === null || _step === void 0 ? void 0 : _step.step) ? 'filled' : 'outlined', color: step.status === SCOnBoardingStepStatusType.COMPLETED ? 'success' : 'default' })) : (_jsxs(ListItemButton, Object.assign({ onClick: () => handleChange(step), selected: (step === null || step === void 0 ? void 0 : step.step) === (_step === null || _step === void 0 ? void 0 : _step.step) }, { children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { edge: "start", checked: step.status === SCOnBoardingStepStatusType.COMPLETED, tabIndex: -1, disableRipple: true, inputProps: { 'aria-labelledby': step.step }, size: 'small' }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }) })] }))) }, step.id))) })), _jsxs(Box, Object.assign({ className: classes.stepContent }, { children: [_jsx(Fade, Object.assign({ in: true, timeout: 2400 }, { children: _jsx(Box, { children: getStepContent() }) })), showCategoriesModal && (_jsx(BaseDialog, Object.assign({ title: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories", defaultMessage: "ui.onBoardingWidget.ai.no.categories" }), DialogContentProps: { dividers: false }, open: showCategoriesModal, onClose: () => setShowCategoriesModal(false), actions: _jsx(Button, Object.assign({ color: "secondary", onClick: () => setShowCategoriesModal(false) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.cancel", defaultMessage: "ui.onBoardingWidget.ai.no.categories.cancel" }) })) }, { children: _jsx(Button, Object.assign({ color: "primary", onClick: handleCategoriesClick, startIcon: _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "edit" })) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.link", defaultMessage: "ui.onBoardingWidget.ai.no.categories.link" }) })) })))] }))] })) })) })] })) })));
325
+ } }) }))) }) })), _jsx(AccordionDetails, { children: _jsx(Widget, Object.assign({ className: classes.content, elevation: 0 }, { children: loading ? (_jsx(OnBoardingWidgetSkeleton, {})) : (_jsxs(CardContent, { children: [_jsx(List, Object.assign({ className: isMobile ? classes.stepsMobile : classes.steps }, { children: steps === null || steps === void 0 ? void 0 : steps.map((step) => (_jsx(ListItem, { children: isMobile ? (_jsx(Chip, { size: "small", label: _jsxs(_Fragment, { children: [_jsx(FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }), ' ', step.status === SCOnBoardingStepStatusType.COMPLETED && (_jsx(Icon, Object.assign({ color: (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.COMPLETED && (step === null || step === void 0 ? void 0 : step.step) !== (_step === null || _step === void 0 ? void 0 : _step.step) ? 'success' : 'inherit' }, { children: "check" })))] }), onClick: () => handleChange(step), variant: step.step === (_step === null || _step === void 0 ? void 0 : _step.step) ? 'filled' : 'outlined', color: step.status === SCOnBoardingStepStatusType.COMPLETED ? 'success' : 'default' })) : (_jsxs(ListItemButton, Object.assign({ onClick: () => handleChange(step), selected: (step === null || step === void 0 ? void 0 : step.step) === (_step === null || _step === void 0 ? void 0 : _step.step) }, { children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { edge: "start", checked: step.status === SCOnBoardingStepStatusType.COMPLETED, tabIndex: -1, disableRipple: true, inputProps: { 'aria-labelledby': step.step }, size: 'small' }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }) })] }))) }, step.id))) })), _jsxs(Box, Object.assign({ className: classes.stepContent }, { children: [_jsx(Fade, Object.assign({ in: true, timeout: 2400 }, { children: _jsx(Box, { children: getStepContent() }) })), showNoCategoriesModal && (_jsx(BaseDialog, Object.assign({ title: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories", defaultMessage: "ui.onBoardingWidget.ai.no.categories" }), DialogContentProps: { dividers: false }, open: showNoCategoriesModal, onClose: () => setShowNoCategoriesModal(false), actions: _jsx(Button, Object.assign({ color: "secondary", onClick: () => setShowNoCategoriesModal(false) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.cancel", defaultMessage: "ui.onBoardingWidget.ai.no.categories.cancel" }) })) }, { children: _jsx(Button, Object.assign({ color: "primary", onClick: handleCategoriesClick, startIcon: _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "edit" })) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.link", defaultMessage: "ui.onBoardingWidget.ai.no.categories.link" }) })) }))), showCategoriesWarningModal && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.categories.warning.title", defaultMessage: "ui.onBoardingWidget.ai.categories.warning.title" }), DialogContentProps: { dividers: false }, open: showCategoriesWarningModal, onClose: () => setShowWarningCategoriesModal(false), actions: _jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ size: "small", variant: "outlined", color: "primary", onClick: () => setShowWarningCategoriesModal(false) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.categories.warning.button.close", defaultMessage: "ui.onBoardingWidget.ai.categories.warning.button.close" }) })), _jsx(Button, Object.assign({ size: "small", variant: "contained", color: "secondary", onClick: () => startStep(SCOnBoardingStepIdType.CATEGORIES), endIcon: _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "magic_wand" })) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.categories.warning.button.generate", defaultMessage: "ui.onBoardingWidget.ai.categories.warning.button.generate" }) }))] }) }, { children: _jsxs(Typography, Object.assign({ className: classes.dialogContent }, { children: [_jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.categories.warning.info", defaultMessage: "ui.onBoardingWidget.ai.categories.warning.info" }), _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.categories.warning.confirm", defaultMessage: "ui.onBoardingWidget.ai.categories.warning.confirm", values: {
326
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
327
+ // @ts-ignore
328
+ b: (chunks) => _jsx("b", { children: chunks })
329
+ } })] })) })))] }))] })) })) })] })) })));
305
330
  };
306
331
  export default OnBoardingWidget;
@@ -1,21 +1,22 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useMemo, useState } from 'react';
4
- import { styled } from '@mui/material/styles';
5
3
  import { Divider, IconButton, List, ListItemIcon, Menu, MenuItem, SwipeableDrawer, useMediaQuery, useTheme } from '@mui/material';
6
- import { FormattedMessage } from 'react-intl';
7
4
  import Icon from '@mui/material/Icon';
8
- import classNames from 'classnames';
5
+ import { styled } from '@mui/material/styles';
9
6
  import { useThemeProps } from '@mui/system';
10
- import { SCRoutes, useSCFetchEvent, useSCRouting, useSCUser } from '@selfcommunity/react-core';
11
- import ConfirmDialog from '../../shared/ConfirmDialog/ConfirmDialog';
12
7
  import { EventService } from '@selfcommunity/api-services';
13
- import { ADD_EVENT_TO_CALENDAR, CANCEL_EVENT, GET_EVENT_LINK } from '../../constants/EventActionsMenu';
8
+ import { SCRoutes, useSCFetchEvent, useSCRouting, useSCUser } from '@selfcommunity/react-core';
14
9
  import { copyTextToClipboard } from '@selfcommunity/utils';
10
+ import classNames from 'classnames';
15
11
  import { enqueueSnackbar } from 'notistack';
16
12
  import PubSub from 'pubsub-js';
17
- import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
13
+ import { useMemo, useState } from 'react';
14
+ import { FormattedMessage } from 'react-intl';
18
15
  import EventForm from '../../components/EventForm';
16
+ import { ADD_EVENT_TO_CALENDAR, CANCEL_EVENT, GET_EVENT_LINK } from '../../constants/EventActionsMenu';
17
+ import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
18
+ import ConfirmDialog from '../../shared/ConfirmDialog/ConfirmDialog';
19
+ import { checkEventFinished } from '../../utils/events';
19
20
  const PREFIX = 'SCEventActionsMenu';
20
21
  const classes = {
21
22
  root: `${PREFIX}-root`,
@@ -82,12 +83,7 @@ export default function EventActionsMenu(inProps) {
82
83
  const scUserContext = useSCUser();
83
84
  const { scEvent, setSCEvent } = useSCFetchEvent({ id: eventId, event });
84
85
  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]);
85
- const isEventFinished = useMemo(() => {
86
- if (scEvent && !scEvent.running) {
87
- return new Date().getTime() > new Date(scEvent.end_date || scEvent.start_date).getTime();
88
- }
89
- return false;
90
- }, [scEvent]);
86
+ const isEventFinished = useMemo(() => checkEventFinished(scEvent), [scEvent]);
91
87
  // HANDLERS
92
88
  const handleOpen = (event) => {
93
89
  setAnchorEl(event.currentTarget);
@@ -153,7 +149,7 @@ export default function EventActionsMenu(inProps) {
153
149
  const renderList = () => {
154
150
  return [
155
151
  _jsxs(MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(GET_EVENT_LINK) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "link" }) }), _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.item.link", defaultMessage: "ui.shared.eventActionsMenu.item.link" })] }), "link"),
156
- _jsxs(MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(ADD_EVENT_TO_CALENDAR) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "CalendarIcon" }) }), _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.item.calendar", defaultMessage: "ui.shared.eventActionsMenu.item.calendar" })] }), "calendar"),
152
+ !isEventFinished && (_jsxs(MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(ADD_EVENT_TO_CALENDAR) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "CalendarIcon" }) }), _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.item.calendar", defaultMessage: "ui.shared.eventActionsMenu.item.calendar" })] }), "calendar")),
157
153
  isEventAdmin &&
158
154
  !isEventFinished && [
159
155
  _jsx(Divider, {}, "divider"),
@@ -0,0 +1,2 @@
1
+ import { SCEventType } from '@selfcommunity/types';
2
+ export declare function checkEventFinished(event: SCEventType | null): boolean;
@@ -0,0 +1,6 @@
1
+ export function checkEventFinished(event) {
2
+ if (event && !event.running) {
3
+ return new Date().getTime() > new Date(event.end_date || event.start_date).getTime();
4
+ }
5
+ return false;
6
+ }