@selfcommunity/react-ui 0.11.0-alpha.5 → 0.11.0-alpha.51

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 (147) hide show
  1. package/lib/cjs/components/CategoryAutocomplete/CategoryAutocomplete.d.ts +5 -0
  2. package/lib/cjs/components/CategoryAutocomplete/CategoryAutocomplete.js +3 -3
  3. package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +1 -1
  4. package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.js +4 -1
  5. package/lib/cjs/components/ComposerIconButton/ComposerIconButton.js +9 -1
  6. package/lib/cjs/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  7. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +1 -1
  8. package/lib/cjs/components/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -6
  9. package/lib/cjs/components/CreateLiveStreamButton/CreateLiveStreamButton.js +2 -9
  10. package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +10 -4
  11. package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +17 -11
  12. package/lib/cjs/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +10 -2
  13. package/lib/cjs/components/Editor/Editor.js +9 -9
  14. package/lib/cjs/components/Editor/nodes/HashtagNode.js +2 -0
  15. package/lib/cjs/components/Editor/nodes/MentionNode.js +2 -0
  16. package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
  17. package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.js +34 -0
  18. package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
  19. package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.js +2 -3
  20. package/lib/cjs/components/Event/Event.js +6 -3
  21. package/lib/cjs/components/EventForm/EventAddress.js +1 -1
  22. package/lib/cjs/components/EventForm/EventForm.js +17 -8
  23. package/lib/cjs/components/EventFormDialog/EventFormDialog.d.ts +1 -1
  24. package/lib/cjs/components/EventFormDialog/EventFormDialog.js +3 -3
  25. package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
  26. package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +11 -11
  27. package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +8 -8
  28. package/lib/cjs/components/EventMembersWidget/types.d.ts +4 -5
  29. package/lib/cjs/components/EventMembersWidget/types.js +7 -7
  30. package/lib/cjs/components/EventParticipantsButton/EventParticipantsButton.js +1 -1
  31. package/lib/cjs/components/Events/Events.d.ts +11 -0
  32. package/lib/cjs/components/Events/Events.js +21 -10
  33. package/lib/cjs/components/Events/OngoingEventsFilter.d.ts +8 -0
  34. package/lib/cjs/components/Events/OngoingEventsFilter.js +24 -0
  35. package/lib/cjs/components/FeedObject/Activities/Activities.js +1 -1
  36. package/lib/cjs/components/GroupForm/GroupForm.js +2 -2
  37. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  38. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  39. package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +65 -6
  40. package/lib/cjs/components/LiveStreamForm/LiveStreamFormSettings.js +8 -3
  41. package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +8 -6
  42. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
  43. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.d.ts +2 -1
  44. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.js +2 -2
  45. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +9 -0
  46. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +106 -0
  47. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.d.ts +4 -0
  48. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.js +37 -0
  49. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  50. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  51. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
  52. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +45 -2
  53. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +62 -5
  54. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
  55. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
  56. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.d.ts +1 -1
  57. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +2 -2
  58. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -1
  59. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +4 -4
  60. package/lib/cjs/components/Notification/Event/Event.js +20 -2
  61. package/lib/cjs/components/SearchDialog/SearchDialog.d.ts +4 -1
  62. package/lib/cjs/components/SearchDialog/SearchDialog.js +2 -2
  63. package/lib/cjs/constants/LiveStream.d.ts +1 -0
  64. package/lib/cjs/constants/LiveStream.js +2 -1
  65. package/lib/cjs/shared/EventActionsMenu/index.js +5 -1
  66. package/lib/cjs/shared/UpScalingTierBadge/index.js +9 -0
  67. package/lib/cjs/utils/buttonCounters.d.ts +1 -0
  68. package/lib/cjs/utils/buttonCounters.js +4 -3
  69. package/lib/cjs/utils/contribution.js +1 -2
  70. package/lib/cjs/utils/events.d.ts +1 -0
  71. package/lib/cjs/utils/events.js +6 -1
  72. package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.d.ts +5 -0
  73. package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.js +3 -3
  74. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +1 -1
  75. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.js +4 -1
  76. package/lib/esm/components/ComposerIconButton/ComposerIconButton.js +10 -2
  77. package/lib/esm/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  78. package/lib/esm/components/CreateEventButton/CreateEventButton.js +1 -1
  79. package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -6
  80. package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.js +2 -9
  81. package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +10 -4
  82. package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +17 -11
  83. package/lib/esm/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +12 -4
  84. package/lib/esm/components/Editor/Editor.js +8 -8
  85. package/lib/esm/components/Editor/nodes/HashtagNode.js +2 -0
  86. package/lib/esm/components/Editor/nodes/MentionNode.js +2 -0
  87. package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
  88. package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.js +30 -0
  89. package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
  90. package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.js +1 -1
  91. package/lib/esm/components/Event/Event.js +6 -3
  92. package/lib/esm/components/EventForm/EventAddress.js +1 -1
  93. package/lib/esm/components/EventForm/EventForm.js +18 -9
  94. package/lib/esm/components/EventFormDialog/EventFormDialog.d.ts +1 -1
  95. package/lib/esm/components/EventFormDialog/EventFormDialog.js +3 -3
  96. package/lib/esm/components/EventHeader/EventHeader.js +1 -1
  97. package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +12 -12
  98. package/lib/esm/components/EventMembersWidget/TabContentComponent.js +9 -9
  99. package/lib/esm/components/EventMembersWidget/types.d.ts +4 -5
  100. package/lib/esm/components/EventMembersWidget/types.js +6 -6
  101. package/lib/esm/components/EventParticipantsButton/EventParticipantsButton.js +1 -1
  102. package/lib/esm/components/Events/Events.d.ts +11 -0
  103. package/lib/esm/components/Events/Events.js +22 -11
  104. package/lib/esm/components/Events/OngoingEventsFilter.d.ts +8 -0
  105. package/lib/esm/components/Events/OngoingEventsFilter.js +21 -0
  106. package/lib/esm/components/FeedObject/Activities/Activities.js +1 -1
  107. package/lib/esm/components/GroupForm/GroupForm.js +2 -2
  108. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  109. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  110. package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +67 -8
  111. package/lib/esm/components/LiveStreamForm/LiveStreamFormSettings.js +8 -3
  112. package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +8 -6
  113. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
  114. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.d.ts +2 -1
  115. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.js +2 -2
  116. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +9 -0
  117. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +103 -0
  118. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.d.ts +4 -0
  119. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.js +34 -0
  120. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  121. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  122. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
  123. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +45 -2
  124. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +66 -9
  125. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
  126. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
  127. package/lib/esm/components/NavigationToolbar/NavigationToolbar.d.ts +1 -1
  128. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +2 -2
  129. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -1
  130. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +4 -4
  131. package/lib/esm/components/Notification/Event/Event.js +22 -4
  132. package/lib/esm/components/SearchDialog/SearchDialog.d.ts +4 -1
  133. package/lib/esm/components/SearchDialog/SearchDialog.js +2 -2
  134. package/lib/esm/constants/LiveStream.d.ts +1 -0
  135. package/lib/esm/constants/LiveStream.js +1 -0
  136. package/lib/esm/shared/EventActionsMenu/index.js +6 -2
  137. package/lib/esm/shared/UpScalingTierBadge/index.js +9 -0
  138. package/lib/esm/utils/buttonCounters.d.ts +1 -0
  139. package/lib/esm/utils/buttonCounters.js +3 -2
  140. package/lib/esm/utils/contribution.js +1 -2
  141. package/lib/esm/utils/events.d.ts +1 -0
  142. package/lib/esm/utils/events.js +4 -0
  143. package/lib/umd/239.js +2 -0
  144. package/lib/umd/react-ui.js +1 -1
  145. package/package.json +14 -13
  146. package/lib/umd/653.js +0 -2
  147. /package/lib/umd/{653.js.LICENSE.txt → 239.js.LICENSE.txt} +0 -0
@@ -22,6 +22,11 @@ export interface CategoryAutocompleteProps extends Pick<AutocompleteProps<SCCate
22
22
  * @param value
23
23
  */
24
24
  onChange?: (value: any) => void;
25
+ /**
26
+ * Feed API Query Params
27
+ * @default [{'limit': 10, 'offset': 0}]
28
+ */
29
+ endpointQueryParams?: Record<string, string | number | boolean>;
25
30
  }
26
31
  /**
27
32
  * > API documentation for the Community-JS Category Autocomplete component. Learn about the available props and the CSS API.
@@ -49,17 +49,17 @@ const CategoryAutocomplete = (inProps) => {
49
49
  name: PREFIX
50
50
  });
51
51
  // Props
52
- const { onChange, multiple = false, defaultValue = multiple ? [] : null, limitCountCategories = 0, checkboxSelect = false, disabled = false, TextFieldProps = {
52
+ const { onChange, multiple = false, defaultValue = multiple ? [] : null, limitCountCategories = 0, checkboxSelect = false, disabled = false, endpointQueryParams = {}, TextFieldProps = {
53
53
  variant: 'outlined',
54
54
  label: _jsx(FormattedMessage, { id: "ui.categoryAutocomplete.label", defaultMessage: "ui.categoryAutocomplete.label" })
55
- } } = props, rest = __rest(props, ["onChange", "multiple", "defaultValue", "limitCountCategories", "checkboxSelect", "disabled", "TextFieldProps"]);
55
+ } } = props, rest = __rest(props, ["onChange", "multiple", "defaultValue", "limitCountCategories", "checkboxSelect", "disabled", "endpointQueryParams", "TextFieldProps"]);
56
56
  // State
57
57
  const [open, setOpen] = useState(false);
58
58
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
59
59
  // @ts-ignore
60
60
  const [value, setValue] = useState(typeof defaultValue === 'string' ? null : defaultValue);
61
61
  // HOOKS
62
- const { categories, isLoading } = useSCFetchCategories();
62
+ const { categories, isLoading } = useSCFetchCategories({ endpointQueryParams });
63
63
  useEffect(() => {
64
64
  if (value === null) {
65
65
  return;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { BoxProps } from '@mui/material';
3
- import { SCCategoryType } from '@selfcommunity/types/src/index';
3
+ import { SCCategoryType } from '@selfcommunity/types';
4
4
  import { ComposerLayerProps } from '../../../../types/composer';
5
5
  export interface CategoryLayerProps extends Omit<BoxProps, 'defaultValue'>, ComposerLayerProps {
6
6
  defaultValue: SCCategoryType[];
@@ -4,6 +4,7 @@ import React, { useCallback, useState } from 'react';
4
4
  import { FormattedMessage } from 'react-intl';
5
5
  import { Box, Button, DialogTitle, IconButton, Typography } from '@mui/material';
6
6
  import { styled } from '@mui/material/styles';
7
+ import { UserUtils, useSCUser } from '@selfcommunity/react-core';
7
8
  import Icon from '@mui/material/Icon';
8
9
  import CategoryAutocomplete from '../../../CategoryAutocomplete';
9
10
  import DialogContent from '@mui/material/DialogContent';
@@ -23,9 +24,11 @@ const CategoryLayer = React.forwardRef((props, ref) => {
23
24
  const { className, onClose, onSave, defaultValue = [] } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultValue"]);
24
25
  // STATE
25
26
  const [value, setValue] = useState(defaultValue);
27
+ // CONTEXT
28
+ const scUserContext = useSCUser();
26
29
  // HANDLERS
27
30
  const handleSave = useCallback(() => onSave(value), [value, onSave]);
28
31
  const handleChange = useCallback((categories) => setValue(categories), []);
29
- return _jsxs(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest, { children: [_jsxs(DialogTitle, Object.assign({ className: classes.title }, { children: [_jsx(IconButton, Object.assign({ onClick: onClose }, { children: _jsx(Icon, { children: "arrow_back" }) })), _jsx(Typography, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.category.title", defaultMessage: "ui.composer.layer.category.title" }) }), _jsx(Button, Object.assign({ size: "small", color: "secondary", variant: "contained", onClick: handleSave }, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }) }))] })), _jsx(DialogContent, Object.assign({ className: classes.content }, { children: _jsx(CategoryAutocomplete, { multiple: true, onChange: handleChange, defaultValue: defaultValue }) }))] }));
32
+ return (_jsxs(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest, { children: [_jsxs(DialogTitle, Object.assign({ className: classes.title }, { children: [_jsx(IconButton, Object.assign({ onClick: onClose }, { children: _jsx(Icon, { children: "arrow_back" }) })), _jsx(Typography, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.category.title", defaultMessage: "ui.composer.layer.category.title" }) }), _jsx(Button, Object.assign({ size: "small", color: "secondary", variant: "contained", onClick: handleSave }, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }) }))] })), _jsx(DialogContent, Object.assign({ className: classes.content }, { children: _jsx(CategoryAutocomplete, Object.assign({ multiple: true, onChange: handleChange, defaultValue: defaultValue }, (!UserUtils.isStaff(scUserContext.user) && { endpointQueryParams: { can_create_content: true } }))) }))] })));
30
33
  });
31
34
  export default CategoryLayer;
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { Icon, IconButton, useMediaQuery, styled, useTheme, SwipeableDrawer, MenuList, MenuItem, ListItemIcon, ListItemText, Typography, useThemeProps, Menu } from '@mui/material';
5
- import { Link, SCRoutes, UserUtils, useSCContext, useSCRouting, useSCUser } from '@selfcommunity/react-core';
5
+ import { Link, SCPreferences, SCRoutes, UserUtils, useSCContext, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
6
6
  import { FormattedMessage } from 'react-intl';
7
7
  import Composer from '../Composer';
8
8
  import { useSnackbar } from 'notistack';
@@ -11,6 +11,7 @@ import EventFormDialog from '../EventFormDialog';
11
11
  import classNames from 'classnames';
12
12
  import GroupForm from '../GroupForm';
13
13
  import CreateLiveStreamDialog from '../CreateLiveStreamDialog';
14
+ import { SCCommunitySubscriptionTier } from '@selfcommunity/types';
14
15
  const PREFIX = 'SCComposerIconButton';
15
16
  const classes = {
16
17
  root: `${PREFIX}-root`,
@@ -81,10 +82,17 @@ export default React.forwardRef(function ComposerIconButton(inProps, ref) {
81
82
  // HOOKS
82
83
  const theme = useTheme();
83
84
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
85
+ const { preferences } = useSCPreferences();
84
86
  // MEMOS
85
87
  const canCreateGroup = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_group; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
86
88
  const canCreateEvent = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_event; }, [(_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.permission]);
87
- const canCreateLiveStream = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_c = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _c === void 0 ? void 0 : _c.permission]);
89
+ const canCreateLive = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_c = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _c === void 0 ? void 0 : _c.permission]);
90
+ const isCommunityOwner = useMemo(() => { var _a; return ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) === 1; }, [scUserContext.user]);
91
+ const isFreeTrialTier = useMemo(() => preferences &&
92
+ SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
93
+ preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
94
+ preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value === SCCommunitySubscriptionTier.FREE_TRIAL, [preferences]);
95
+ const canCreateLiveStream = useMemo(() => (isFreeTrialTier && isCommunityOwner && canCreateLive) || (!isFreeTrialTier && canCreateLive), [isFreeTrialTier, isCommunityOwner, canCreateLive]);
88
96
  const renderContent = useMemo(() => {
89
97
  return (_jsx(MenuList, { children: listItem.map((item, i) => (_jsxs(MenuItem, Object.assign({ onClick: item.onClick }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, Object.assign({ fontSize: "small" }, { children: item.icon })) }), _jsx(ListItemText, { primary: _jsx(Typography, Object.assign({ variant: "h6" }, { children: _jsx(FormattedMessage, { id: item.text, defaultMessage: item.text }) })) })] }), i))) }));
90
98
  }, [listItem]);
@@ -7,7 +7,7 @@ export interface CreateEventButtonProps extends ButtonProps {
7
7
  */
8
8
  className?: string;
9
9
  /**
10
- * Props to spread to CreateGroup component
10
+ * Props to spread to CreateEvent component
11
11
  * @default empty object
12
12
  */
13
13
  EventFormDialogComponentProps?: EventFormDialogProps;
@@ -16,7 +16,7 @@ const classes = {
16
16
  const Root = styled(Button, {
17
17
  name: PREFIX,
18
18
  slot: 'Root',
19
- overridesResolver: (props, styles) => styles.root
19
+ overridesResolver: (_props, styles) => styles.root
20
20
  })(() => ({}));
21
21
  /**
22
22
  *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
@@ -1,5 +1,4 @@
1
1
  import { ButtonProps } from '@mui/material/Button/Button';
2
- import { SCEventType, SCLiveStreamType } from '@selfcommunity/types';
3
2
  import { CreateLiveStreamDialogProps } from '../CreateLiveStreamDialog';
4
3
  export interface CreateLiveStreamButtonProps extends ButtonProps {
5
4
  /**
@@ -12,11 +11,6 @@ export interface CreateLiveStreamButtonProps extends ButtonProps {
12
11
  * @default empty object
13
12
  */
14
13
  CreateLiveStreamDialogComponentProps?: CreateLiveStreamDialogProps;
15
- /**
16
- * On success callback function
17
- * @default null
18
- */
19
- onSuccess?: (data: SCEventType | SCLiveStreamType) => void;
20
14
  /**
21
15
  * Any other properties
22
16
  */
@@ -43,7 +43,7 @@ export default function CreateLiveStreamButton(inProps) {
43
43
  props: inProps,
44
44
  name: PREFIX
45
45
  });
46
- const { className, CreateLiveStreamDialogComponentProps = {}, onSuccess, children } = props, rest = __rest(props, ["className", "CreateLiveStreamDialogComponentProps", "onSuccess", "children"]);
46
+ const { className, CreateLiveStreamDialogComponentProps = {}, children } = props, rest = __rest(props, ["className", "CreateLiveStreamDialogComponentProps", "children"]);
47
47
  // CONTEXT
48
48
  const scUserContext = useContext(SCUserContext);
49
49
  const { preferences, features } = useSCPreferences();
@@ -69,13 +69,6 @@ export default function CreateLiveStreamButton(inProps) {
69
69
  const handleClose = () => {
70
70
  setOpen((o) => !o);
71
71
  };
72
- /**
73
- * Handle close
74
- */
75
- const handleSuccess = (data) => {
76
- onSuccess && onSuccess(data);
77
- setOpen((o) => !o);
78
- };
79
72
  /**
80
73
  * If there's no authUserId, component is hidden.
81
74
  */
@@ -85,5 +78,5 @@ export default function CreateLiveStreamButton(inProps) {
85
78
  /**
86
79
  * Renders root object
87
80
  */
88
- return (_jsxs(React.Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, variant: "contained", color: "secondary", startIcon: _jsx(Icon, { children: "movie" }) }, rest, { children: children !== null && children !== void 0 ? children : _jsx(FormattedMessage, { id: "ui.createEventButton.goLive", defaultMessage: "ui.createEventButton.goLive" }) })), open && _jsx(CreateLivestreamDialog, Object.assign({ open: true, onClose: handleClose, onSuccess: handleSuccess }, CreateLiveStreamDialogComponentProps))] }));
81
+ return (_jsxs(React.Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, variant: "contained", color: "secondary", startIcon: _jsx(Icon, { children: "movie" }) }, rest, { children: children !== null && children !== void 0 ? children : _jsx(FormattedMessage, { id: "ui.createEventButton.goLive", defaultMessage: "ui.createEventButton.goLive" }) })), open && _jsx(CreateLivestreamDialog, Object.assign({ open: true, onClose: handleClose }, CreateLiveStreamDialogComponentProps))] }));
89
82
  }
@@ -1,5 +1,6 @@
1
- import { SCEventType, SCLiveStreamType } from '@selfcommunity/types';
2
1
  import { BaseDialogProps } from '../../shared/BaseDialog';
2
+ import { EventFormProps } from '../EventForm';
3
+ import { LiveStreamFormProps } from '../LiveStreamForm';
3
4
  export interface CreateLiveStreamDialogProps extends BaseDialogProps {
4
5
  /**
5
6
  * Overrides or extends the styles applied to the component.
@@ -17,10 +18,15 @@ export interface CreateLiveStreamDialogProps extends BaseDialogProps {
17
18
  */
18
19
  onClose?: () => void;
19
20
  /**
20
- * On success callback function
21
- * @default null
21
+ * Props to spread to EventForm component
22
+ * @default {}
23
+ */
24
+ EventFormComponentProps?: EventFormProps;
25
+ /**
26
+ * Props to spread to LiveStreamForm component
27
+ * @default {}
22
28
  */
23
- onSuccess?: (data: SCEventType | SCLiveStreamType) => void;
29
+ LiveStreamFormComponentProps?: LiveStreamFormProps;
24
30
  /**
25
31
  * Any other properties
26
32
  */
@@ -23,10 +23,11 @@ const classes = {
23
23
  const Root = styled(BaseDialog, {
24
24
  name: PREFIX,
25
25
  slot: 'Root'
26
- })(({ theme }) => ({
26
+ })(() => ({
27
27
  paddingBottom: '0px !important',
28
28
  [`& .${classes.title}`]: {
29
- display: 'flex'
29
+ display: 'flex',
30
+ alignItems: 'center'
30
31
  },
31
32
  [`& .${classes.content}`]: {
32
33
  paddingBottom: 0
@@ -56,20 +57,21 @@ const Transition = React.forwardRef(function Transition(props, ref) {
56
57
  * @param inProps
57
58
  */
58
59
  export default function CreateLiveStreamDialog(inProps) {
59
- var _a, _b;
60
+ var _a;
60
61
  //PROPS
61
62
  const props = useThemeProps({
62
63
  props: inProps,
63
64
  name: PREFIX
64
65
  });
65
- const { className, open = true, onClose, onSuccess } = props, rest = __rest(props, ["className", "open", "onClose", "onSuccess"]);
66
+ const { className, open = true, onClose, EventFormComponentProps = {}, LiveStreamFormComponentProps = {} } = props, rest = __rest(props, ["className", "open", "onClose", "EventFormComponentProps", "LiveStreamFormComponentProps"]);
66
67
  // CONTEXT
67
68
  const scUserContext = useSCUser();
68
- const canCreateLiveStream = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
69
- const canCreateEvent = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_event; }, [(_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.permission]);
69
+ // PERMISSION
70
+ const canCreateEvent = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_event; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
70
71
  // STATE
71
72
  const [step, setStep] = useState(canCreateEvent ? CreateLiveStreamStep.SELECT_TYPE : CreateLiveStreamStep.CREATE_LIVE);
72
73
  const [liveType, setLiveType] = useState(canCreateEvent ? null : LiveStreamType.DIRECT_LIVE);
74
+ const canShowBackButton = useMemo(() => step === CreateLiveStreamStep.CREATE_LIVE && canCreateEvent, [step, canCreateEvent]);
73
75
  // HANDLER
74
76
  const handleLiveTypeSelected = useCallback((l) => {
75
77
  setLiveType(l);
@@ -78,23 +80,27 @@ export default function CreateLiveStreamDialog(inProps) {
78
80
  setLiveType(l);
79
81
  setStep(CreateLiveStreamStep.CREATE_LIVE);
80
82
  }, []);
81
- const handleBack = useCallback((l) => {
83
+ const handleBack = useCallback(() => {
82
84
  setStep(CreateLiveStreamStep.SELECT_TYPE);
83
85
  }, []);
84
86
  const handleSubmit = useCallback((e) => {
85
- onSuccess && onSuccess(e);
86
- }, []);
87
+ var _a, _b;
88
+ liveType === LiveStreamType.EVENT_LIVE
89
+ ? (_a = EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, e)
90
+ : (_b = LiveStreamFormComponentProps.onSuccess) === null || _b === void 0 ? void 0 : _b.call(LiveStreamFormComponentProps, e);
91
+ onClose === null || onClose === void 0 ? void 0 : onClose();
92
+ }, [liveType, onClose, EventFormComponentProps, LiveStreamFormComponentProps]);
87
93
  useEffect(() => {
88
94
  if (!canCreateEvent) {
89
95
  setLiveType(LiveStreamType.DIRECT_LIVE);
90
96
  }
91
97
  }, [canCreateEvent]);
92
98
  // user must be logged
93
- if (!scUserContext.user || !canCreateLiveStream) {
99
+ if (!scUserContext.user) {
94
100
  return null;
95
101
  }
96
102
  /**
97
103
  * Renders root object
98
104
  */
99
- return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: 'md', title: _jsxs(Box, Object.assign({ className: classes.title, component: 'span' }, { children: [Boolean(step === CreateLiveStreamStep.CREATE_LIVE && canCreateEvent) && (_jsx(Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: _jsx(Icon, { children: "arrow_back" }) }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.button.back", defaultMessage: "ui.createLivestreamDialog.button.back" }) }))), _jsx(Box, Object.assign({ component: 'span' }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: "body", onClose: onClose, className: classNames(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: _jsxs(Box, Object.assign({ className: classes.content }, { children: [step === CreateLiveStreamStep.SELECT_TYPE && (_jsx(LiveStreamSelector, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === CreateLiveStreamStep.CREATE_LIVE && (_jsx(_Fragment, { children: liveType === LiveStreamType.EVENT_LIVE ? (_jsx(EventForm, { EventAddressComponentProps: { locations: [SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit })) : (_jsx(LiveStreamForm, { onSuccess: handleSubmit })) }))] })) })));
105
+ return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: _jsxs(Box, Object.assign({ className: classes.title, component: "span" }, { children: [canShowBackButton && (_jsx(Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: _jsx(Icon, { children: "arrow_back" }) }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.button.back", defaultMessage: "ui.createLivestreamDialog.button.back" }) }))), _jsx(Box, Object.assign({ component: "span" }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: "body", onClose: !canShowBackButton ? onClose : undefined, className: classNames(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: _jsxs(Box, Object.assign({ className: classes.content }, { children: [step === CreateLiveStreamStep.SELECT_TYPE && (_jsx(LiveStreamSelector, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === CreateLiveStreamStep.CREATE_LIVE && (_jsx(_Fragment, { children: liveType === LiveStreamType.EVENT_LIVE ? (_jsx(EventForm, Object.assign({}, EventFormComponentProps, { EventAddressComponentProps: { locations: [SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit }))) : (_jsx(LiveStreamForm, Object.assign({}, LiveStreamFormComponentProps, { onSuccess: handleSubmit }))) }))] })) })));
100
106
  }
@@ -12,8 +12,8 @@ import LiveImage from '../../../assets/liveStream/live';
12
12
  import { LiveStreamApiClient } from '@selfcommunity/api-services';
13
13
  import { WARNING_THRESHOLD_EXPIRING_SOON } from '../../LiveStreamRoom/constants';
14
14
  import { Link, SCPreferences, useSCContext, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
15
- import { SCCommunitySubscriptionTier } from '@selfcommunity/types';
16
- import { SELFCOMMUNITY_PRICING } from '../../PlatformWidget/constants';
15
+ import { SCCommunityEnvironment, SCCommunitySubscriptionTier } from '@selfcommunity/types';
16
+ import { HUB_PROD, HUB_STAGE } from '../../PlatformWidget/constants';
17
17
  export const PREFIX = 'SCLiveStreamSelector';
18
18
  const classes = {
19
19
  root: `${PREFIX}-root`,
@@ -80,6 +80,14 @@ export default function LiveStreamSelector(inProps) {
80
80
  SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
81
81
  preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
82
82
  preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value === SCCommunitySubscriptionTier.FREE_TRIAL, [preferences]);
83
+ const isEnterpriseTier = useMemo(() => preferences &&
84
+ SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
85
+ preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
86
+ preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value === SCCommunitySubscriptionTier.ENTERPRISE, [preferences]);
87
+ const isStage = useMemo(() => preferences &&
88
+ SCPreferences.STATIC_ENVIRONMENT in preferences &&
89
+ preferences[SCPreferences.STATIC_ENVIRONMENT].value === SCCommunityEnvironment.STAGE, [preferences]);
90
+ const communityStackId = useMemo(() => preferences && SCPreferences.STATIC_ENVIRONMENT in preferences && preferences[SCPreferences.STATIC_STACKID].value, [preferences]);
83
91
  const intl = useIntl();
84
92
  const options = [
85
93
  {
@@ -153,11 +161,11 @@ export default function LiveStreamSelector(inProps) {
153
161
  }, []);
154
162
  const warning = useMemo(() => {
155
163
  let _message;
156
- if (isFreeTrialTier && isCommunityOwner) {
164
+ if (isFreeTrialTier && isCommunityOwner && !isEnterpriseTier) {
157
165
  _message = (_jsx(FormattedMessage, { id: "ui.liveStreamForm.selector.warningSubscriptionRequired", defaultMessage: "ui.liveStreamForm.selector.warningSubscriptionRequired", values: {
158
166
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
159
167
  // @ts-ignore
160
- link: (...chunks) => _jsx(Link, Object.assign({ to: SELFCOMMUNITY_PRICING[scContext.settings.locale.default] }, { children: chunks }))
168
+ link: (...chunks) => (_jsx(Link, Object.assign({ target: "_blank", to: `${isStage ? HUB_STAGE : HUB_PROD}dashboard/community/${communityStackId}/subscription` }, { children: chunks })))
161
169
  } }));
162
170
  }
163
171
  else if (timeRemaining !== null && timeRemaining <= WARNING_THRESHOLD_EXPIRING_SOON) {
@@ -8,19 +8,19 @@ import { useThemeProps } from '@mui/system';
8
8
  import nodes from './nodes';
9
9
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
10
10
  import { ContentEditable } from '@lexical/react/LexicalContentEditable';
11
- import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
11
+ import ToolbarPlugin from './plugins/ToolbarPlugin';
12
+ import { PREFIX } from './constants';
13
+ import { HorizontalRulePlugin } from './plugins/HorizontalRulePlugin';
12
14
  import { RichTextPlugin } from './plugins/LexicalRichTextPlugin';
13
- import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
14
- import { HorizontalRulePlugin } from '@lexical/react/LexicalHorizontalRulePlugin';
15
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
15
16
  import { AutoLinkPlugin, DefaultHtmlValuePlugin, EmojiPlugin, ImagePlugin, MentionsPlugin, OnChangePlugin } from './plugins';
17
+ import OnBlurPlugin from './plugins/OnBlurPlugin';
18
+ import OnFocusPlugin from './plugins/OnFocusPlugin';
16
19
  import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
20
+ import FloatingLinkPlugin from './plugins/FloatingLinkPlugin';
17
21
  import ApiPlugin from './plugins/ApiPlugin';
18
- import ToolbarPlugin from './plugins/ToolbarPlugin';
22
+ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
19
23
  import { ListPlugin } from '@lexical/react/LexicalListPlugin';
20
- import FloatingLinkPlugin from './plugins/FloatingLinkPlugin';
21
- import OnBlurPlugin from './plugins/OnBlurPlugin';
22
- import OnFocusPlugin from './plugins/OnFocusPlugin';
23
- import { PREFIX } from './constants';
24
24
  const classes = {
25
25
  root: `${PREFIX}-root`,
26
26
  focused: `${PREFIX}-focused`,
@@ -33,6 +33,8 @@ export class HashtagNode extends TextNode {
33
33
  if (inner === null) {
34
34
  return true;
35
35
  }
36
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
37
+ // @ts-ignore
36
38
  super.updateDOM(prevNode, inner, config);
37
39
  return false;
38
40
  }
@@ -47,6 +47,8 @@ export class MentionNode extends TextNode {
47
47
  if (inner === null) {
48
48
  return true;
49
49
  }
50
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
51
+ // @ts-ignore
50
52
  super.updateDOM(prevNode, inner, config);
51
53
  return false;
52
54
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare function HorizontalRulePlugin(): null;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
+ import { $createHorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND } from '@lexical/react/LexicalHorizontalRuleNode';
10
+ import { $insertNodeToNearestRoot } from '@lexical/utils';
11
+ import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
12
+ import { useEffect } from 'react';
13
+ export function HorizontalRulePlugin() {
14
+ const [editor] = useLexicalComposerContext();
15
+ useEffect(() => {
16
+ return editor.registerCommand(INSERT_HORIZONTAL_RULE_COMMAND, (type) => {
17
+ const selection = $getSelection();
18
+ if (!$isRangeSelection(selection)) {
19
+ return false;
20
+ }
21
+ const focusNode = selection.focus.getNode();
22
+ if (focusNode !== null) {
23
+ const horizontalRuleNode = $createHorizontalRuleNode();
24
+ $insertNodeToNearestRoot(horizontalRuleNode);
25
+ }
26
+ return true;
27
+ }, COMMAND_PRIORITY_EDITOR);
28
+ }, [editor]);
29
+ return null;
30
+ }
@@ -1,6 +1,6 @@
1
1
  import { ErrorBoundaryType } from '../shared/useDecorators';
2
2
  export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary }: {
3
3
  contentEditable: JSX.Element;
4
- placeholder: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
- ErrorBoundary: ErrorBoundaryType;
4
+ placeholder?: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
+ ErrorBoundary?: ErrorBoundaryType;
6
6
  }): JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
- import useLexicalEditable from '@lexical/react/useLexicalEditable';
3
+ import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
4
4
  import { useDecorators } from '../shared/useDecorators';
5
5
  import { useEditorFocus } from '../shared/useEditorFocus';
6
6
  import { useCanShowPlaceholder } from '../shared/useCanShowPlaceholder';
@@ -17,6 +17,7 @@ import User from '../User';
17
17
  import Widget from '../Widget';
18
18
  import { PREFIX } from './constants';
19
19
  import EventSkeleton from './Skeleton';
20
+ import { checkEventFinished } from '../../utils/events';
20
21
  const classes = {
21
22
  root: `${PREFIX}-root`,
22
23
  detailRoot: `${PREFIX}-detail-root`,
@@ -44,7 +45,8 @@ const classes = {
44
45
  snippetInProgress: `${PREFIX}-snippet-in-progress`,
45
46
  snippetPrimary: `${PREFIX}-snippet-primary`,
46
47
  snippetSecondary: `${PREFIX}-snippet-secondary`,
47
- snippetActions: `${PREFIX}-snippet-actions`
48
+ snippetActions: `${PREFIX}-snippet-actions`,
49
+ finishedChip: `${PREFIX}-finished-chip`
48
50
  };
49
51
  const Root = styled(Widget, {
50
52
  name: PREFIX,
@@ -108,6 +110,7 @@ export default function Event(inProps) {
108
110
  // STATE
109
111
  const { scEvent } = useSCFetchEvent({ id: eventId, event, autoSubscribe: false });
110
112
  const inProgress = useMemo(() => scEvent && scEvent.active && scEvent.running, [scEvent]);
113
+ const isEventFinished = useMemo(() => checkEventFinished(scEvent), [scEvent]);
111
114
  // CONTEXT
112
115
  const scRoutingContext = useSCRouting();
113
116
  // HOOKS
@@ -126,10 +129,10 @@ export default function Event(inProps) {
126
129
  contentObj = (_jsxs(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [_jsxs(Box, Object.assign({ className: classes.detailImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.detailInProgress })), _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() })] })), _jsxs(CardContent, Object.assign({ className: classes.detailContent }, { children: [scEvent.active ? (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))) : (_jsx(Box, Object.assign({ className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))), _jsx(EventInfoDetails, { event: scEvent }), !hideEventPlanner && (_jsx(User, { user: scEvent.managed_by, elevation: 0, secondary: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: _jsx(_Fragment, {}), className: classes.detailUser })), !hideEventParticipants && (_jsxs(_Fragment, { children: [_jsx(Divider, { className: classes.detailFirstDivider }), _jsx(EventParticipantsButton, Object.assign({ event: scEvent }, EventParticipantsButtonComponentProps))] })), _jsx(Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.detailActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
127
130
  }
128
131
  else if (template === SCEventTemplateType.PREVIEW) {
129
- contentObj = (_jsxs(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [_jsxs(Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.previewImage }), !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.previewInProgress }))] })), _jsxs(CardContent, Object.assign({ className: classes.previewContent }, { children: [_jsx(EventInfoDetails, { event: scEvent, hidePrivacyIcon: true, hasLocationInfo: false, beforePrivacyInfo: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.previewNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h5", className: classes.previewName }, { children: scEvent.name })) })) }), !hideEventParticipants && _jsx(EventParticipantsButton, Object.assign({ event: scEvent, hideCaption: true }, EventParticipantsButtonComponentProps))] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
132
+ contentObj = (_jsxs(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [_jsxs(Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.previewImage }), !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.previewInProgress })), isEventFinished && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.finished", defaultMessage: "ui.event.finished" }), className: classes.finishedChip }))] })), _jsxs(CardContent, Object.assign({ className: classes.previewContent }, { children: [_jsx(EventInfoDetails, { event: scEvent, hidePrivacyIcon: true, hasLocationInfo: false, beforePrivacyInfo: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.previewNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h5", className: classes.previewName }, { children: scEvent.name })) })) }), !hideEventParticipants && _jsx(EventParticipantsButton, Object.assign({ event: scEvent, hideCaption: true }, EventParticipantsButtonComponentProps))] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
130
133
  }
131
134
  else {
132
- contentObj = (_jsx(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), ' ', !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.snippetInProgress }))] })), primary: _jsxs(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
135
+ contentObj = (_jsx(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), ' ', !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.snippetInProgress })), isEventFinished && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.finished", defaultMessage: "ui.event.finished" }), className: classes.finishedChip }))] })), primary: _jsxs(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
133
136
  weekday: 'long',
134
137
  month: 'long',
135
138
  day: 'numeric'
@@ -155,5 +155,5 @@ export default function EventAddress(inProps) {
155
155
  }
156
156
  return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsxs(Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [isInPersonTabActive && (_jsx(Tab, { value: SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "add_location_alt" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) })), isOnlineTabActive && (_jsx(Tab, { value: SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "play_circle_outline" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) })), isLiveTabActive && (_jsx(Tab, { value: SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "photo_camera" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) }))] })), _jsxs(Box, Object.assign({ className: classes.tabContent }, { children: [isInPersonTabActive && location === SCEventLocationType.PERSON && (_jsx(Autocomplete, { disabled: !geocodingApiKey, size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => (_jsx(TextField, Object.assign({}, params, { label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (_jsxs(_Fragment, { children: [_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(Icon, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), isOnlineTabActive && location === SCEventLocationType.ONLINE && (_jsx(UrlTextField, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
157
157
  endAdornment: _jsx(Icon, { children: "play_circle_outline" })
158
- }, onChange: handleLinkChange })), isLiveTabActive && location === SCEventLocationType.LIVESTREAM && (_jsxs(_Fragment, { children: [_jsx(LiveStream, { template: SCLiveStreamTemplateType.SNIPPET, liveStream: liveStream, actions: _jsx(_Fragment, {}) }), _jsx(LiveStreamFormSettings, { settings: liveStream.settings || LIVESTREAM_DEFAULT_SETTINGS, onChange: handleLiveStreamSettingsChange })] }))] }))] })));
158
+ }, value: event ? event.link : '', onChange: handleLinkChange })), isLiveTabActive && location === SCEventLocationType.LIVESTREAM && (_jsxs(_Fragment, { children: [_jsx(LiveStream, { template: SCLiveStreamTemplateType.SNIPPET, liveStream: liveStream, actions: _jsx(_Fragment, {}) }), _jsx(LiveStreamFormSettings, { settings: liveStream.settings || LIVESTREAM_DEFAULT_SETTINGS, onChange: handleLiveStreamSettingsChange })] }))] }))] })));
159
159
  }
@@ -7,7 +7,7 @@ import { useThemeProps } from '@mui/system';
7
7
  import { LocalizationProvider, MobileDatePicker, MobileTimePicker } from '@mui/x-date-pickers';
8
8
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
9
9
  import { EventService, formatHttpErrorCode } from '@selfcommunity/api-services';
10
- import { SCPreferences, useSCContext, useSCPreferences } from '@selfcommunity/react-core';
10
+ import { SCPreferences, useSCContext, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
11
11
  import { SCEventLocationType, SCEventPrivacyType, SCEventRecurrenceType, SCFeatureName } from '@selfcommunity/types';
12
12
  import { Logger } from '@selfcommunity/utils';
13
13
  import classNames from 'classnames';
@@ -119,7 +119,7 @@ const Root = styled(Box, {
119
119
  * @param inProps
120
120
  */
121
121
  export default function EventForm(inProps) {
122
- var _a, _b, _c, _d, _e;
122
+ var _a, _b, _c, _d, _e, _f;
123
123
  //PROPS
124
124
  const props = useThemeProps({
125
125
  props: inProps,
@@ -128,6 +128,7 @@ export default function EventForm(inProps) {
128
128
  const { className, onSuccess, onError, event, presetLocation, EventAddressComponentProps = {} } = props, rest = __rest(props, ["className", "onSuccess", "onError", "event", "presetLocation", "EventAddressComponentProps"]);
129
129
  // CONTEXT
130
130
  const scContext = useSCContext();
131
+ const scUserContext = useSCUser();
131
132
  // INTL
132
133
  const intl = useIntl();
133
134
  const startDateTime = useMemo(() => getNewDate(event === null || event === void 0 ? void 0 : event.start_date), [event]);
@@ -142,9 +143,11 @@ export default function EventForm(inProps) {
142
143
  endDate: (event === null || event === void 0 ? void 0 : event.end_date) ? endDateTime : getNewDate(),
143
144
  endTime: (event === null || event === void 0 ? void 0 : event.end_date) ? endDateTime : getLaterHoursDate(3),
144
145
  location: (event === null || event === void 0 ? void 0 : event.location)
145
- ? event.location === SCEventLocationType.ONLINE && event.live_stream
146
- ? SCEventLocationType.LIVESTREAM
147
- : SCEventLocationType.ONLINE
146
+ ? event.location === SCEventLocationType.PERSON
147
+ ? SCEventLocationType.PERSON
148
+ : event.location === SCEventLocationType.ONLINE && event.live_stream
149
+ ? SCEventLocationType.LIVESTREAM
150
+ : SCEventLocationType.ONLINE
148
151
  : ((_a = EventAddressComponentProps.locations) === null || _a === void 0 ? void 0 : _a.length)
149
152
  ? presetLocation in EventAddressComponentProps.locations
150
153
  ? presetLocation
@@ -170,6 +173,7 @@ export default function EventForm(inProps) {
170
173
  scPreferences.features.includes(SCFeatureName.LIVE_STREAM) &&
171
174
  SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED in scPreferences.preferences &&
172
175
  scPreferences.preferences[SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
176
+ const canCreateLiveStream = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.permission]);
173
177
  const privateEnabled = useMemo(() => scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED].value, [scPreferences.preferences]);
174
178
  const visibilityEnabled = useMemo(() => scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED].value, [scPreferences.preferences]);
175
179
  const disablePastStartTime = useMemo(() => field.startDate.getDate() === getNewDate().getDate(), [field]);
@@ -238,6 +242,11 @@ export default function EventForm(inProps) {
238
242
  formData.append('link', '');
239
243
  formData.append('live_stream_settings', null);
240
244
  }
245
+ if (field.location !== SCEventLocationType.PERSON) {
246
+ formData.append('geolocation', '');
247
+ formData.append('geolocation_lat', '');
248
+ formData.append('geolocation_lng', '');
249
+ }
241
250
  if (privateEnabled) {
242
251
  formData.append('privacy', field.isPublic ? SCEventPrivacyType.PUBLIC : SCEventPrivacyType.PRIVATE);
243
252
  }
@@ -382,7 +391,7 @@ export default function EventForm(inProps) {
382
391
  start_date: field.startDate,
383
392
  location: field.location,
384
393
  geolocation: field.geolocation,
385
- live_stream: Object.assign(Object.assign({ title: field.name || `${intl.formatMessage(messages.name)}` }, (event && ((_b = event.live_stream) === null || _b === void 0 ? void 0 : _b.created_at) && { created_at: field.startDate })), { settings: field.liveStreamSettings })
394
+ live_stream: Object.assign(Object.assign({ title: field.name || `${intl.formatMessage(messages.name)}` }, (event && ((_c = event.live_stream) === null || _c === void 0 ? void 0 : _c.created_at) && { created_at: field.startDate })), { settings: field.liveStreamSettings })
386
395
  }) }, EventAddressComponentProps)), privateEnabled && (_jsxs(Box, Object.assign({ className: classes.privacySection }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [_jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), _jsx(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), _jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), _jsx(Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? (_jsx(FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
387
396
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
388
397
  // @ts-ignores
@@ -392,8 +401,8 @@ export default function EventForm(inProps) {
392
401
  // @ts-ignore
393
402
  b: (chunks) => _jsx("strong", { children: chunks })
394
403
  } })) }))] }))), _jsx(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
395
- endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) ? EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : EVENT_DESCRIPTION_MAX_LENGTH })))
396
- }, error: Boolean(((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) > EVENT_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), genericError && (_jsx(Box, Object.assign({ className: classes.genericError }, { children: _jsx(Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
404
+ endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) ? EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : EVENT_DESCRIPTION_MAX_LENGTH })))
405
+ }, error: Boolean(((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) > EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_f = field.description) === null || _f === void 0 ? void 0 : _f.length) > EVENT_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), genericError && (_jsx(Box, Object.assign({ className: classes.genericError }, { children: _jsx(Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
397
406
  !field.startDate ||
398
407
  !field.startTime ||
399
408
  !field.endDate ||
@@ -405,5 +414,5 @@ export default function EventForm(inProps) {
405
414
  field.isSubmitting ||
406
415
  field.name.length > EVENT_TITLE_MAX_LENGTH ||
407
416
  field.description.length > EVENT_DESCRIPTION_MAX_LENGTH ||
408
- (field.location === SCEventLocationType.LIVESTREAM && !liveStreamEnabled), variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? (_jsx(FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : (_jsx(FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }))] }))] })));
417
+ (field.location === SCEventLocationType.LIVESTREAM && (!liveStreamEnabled || !canCreateLiveStream)), variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? (_jsx(FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : (_jsx(FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }))] }))] })));
409
418
  }
@@ -18,7 +18,7 @@ export interface EventFormDialogProps extends BaseDialogProps {
18
18
  onClose?: () => void;
19
19
  /**
20
20
  * Props to spread to EventForm component
21
- * @default undefined
21
+ * @default {}
22
22
  */
23
23
  EventFormComponentProps?: EventFormProps;
24
24
  /**