@selfcommunity/react-ui 0.8.0-live.80 → 0.8.0-live.85

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 (139) hide show
  1. package/lib/cjs/assets/onBoarding/android.d.ts +1 -1
  2. package/lib/cjs/assets/onBoarding/android.js +1 -1
  3. package/lib/cjs/components/CategoryFollowersButton/CategoryFollowersButton.d.ts +2 -2
  4. package/lib/cjs/components/CategoryFollowersButton/CategoryFollowersButton.js +20 -15
  5. package/lib/cjs/components/CommentObject/CommentObject.js +6 -3
  6. package/lib/cjs/components/CommentObjectReply/CommentObjectReply.js +4 -1
  7. package/lib/cjs/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  8. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +1 -1
  9. package/lib/cjs/components/EditEventButton/EditEventButton.js +2 -2
  10. package/lib/cjs/components/Editor/plugins/AutoLinkPlugin.js +7 -1
  11. package/lib/cjs/components/Event/Event.js +4 -4
  12. package/lib/cjs/components/EventForm/EventAddress.js +5 -8
  13. package/lib/cjs/components/EventForm/EventForm.js +32 -25
  14. package/lib/cjs/components/EventForm/constants.d.ts +4 -4
  15. package/lib/cjs/components/EventForm/constants.js +4 -4
  16. package/lib/cjs/components/EventForm/utils.d.ts +3 -3
  17. package/lib/cjs/components/EventForm/utils.js +8 -5
  18. package/lib/cjs/components/EventHeader/EventHeader.js +4 -35
  19. package/lib/cjs/components/EventInviteButton/EventInviteButton.js +5 -5
  20. package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +3 -7
  21. package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +1 -1
  22. package/lib/cjs/components/EventParticipantsButton/EventParticipantsButton.js +9 -5
  23. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  24. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +14 -16
  25. package/lib/cjs/components/Events/Events.js +12 -35
  26. package/lib/cjs/components/Events/PastEventsFilter.js +2 -12
  27. package/lib/cjs/components/FeedObject/Actions/Share/Share.js +1 -1
  28. package/lib/cjs/components/FeedObject/FeedObject.js +5 -6
  29. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +2 -2
  30. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +20 -15
  31. package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +6 -1
  32. package/lib/cjs/components/NavigationMenuIconButton/DefaultDrawerContent.js +24 -2
  33. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +1 -1
  34. package/lib/cjs/components/Notification/Comment/Comment.js +2 -2
  35. package/lib/cjs/components/Notification/Notification.js +1 -1
  36. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +2 -2
  37. package/lib/cjs/components/OnBoardingWidget/Steps/App/App.js +2 -1
  38. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +65 -104
  39. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +4 -7
  40. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +3 -2
  41. package/lib/cjs/components/Skeleton/AvatarGroupSkeleton.js +4 -4
  42. package/lib/cjs/components/SuggestedEventsWidget/Arrow.js +2 -1
  43. package/lib/cjs/components/TagAutocomplete/TagAutocomplete.d.ts +44 -0
  44. package/lib/cjs/components/TagAutocomplete/TagAutocomplete.js +92 -0
  45. package/lib/cjs/components/TagAutocomplete/index.d.ts +3 -0
  46. package/lib/cjs/components/TagAutocomplete/index.js +5 -0
  47. package/lib/cjs/components/UserActionIconButton/UserActionIconButton.js +24 -2
  48. package/lib/cjs/components/UserProfileEdit/Section/PublicInfo.js +1 -1
  49. package/lib/cjs/components/UserProfileEdit/UserProfileEdit.d.ts +1 -1
  50. package/lib/cjs/components/UserProfileEdit/UserProfileEdit.js +1 -1
  51. package/lib/cjs/components/UserSocialAssociation/UserSocialAssociation.js +16 -4
  52. package/lib/cjs/constants/SocialShare.d.ts +12 -0
  53. package/lib/cjs/constants/SocialShare.js +15 -2
  54. package/lib/cjs/index.d.ts +3 -2
  55. package/lib/cjs/index.js +6 -2
  56. package/lib/cjs/shared/CopyTextArea/index.d.ts +10 -0
  57. package/lib/cjs/shared/CopyTextArea/index.js +77 -0
  58. package/lib/cjs/utils/buttonCounters.d.ts +1 -0
  59. package/lib/cjs/utils/buttonCounters.js +15 -0
  60. package/lib/cjs/utils/contribution.d.ts +7 -0
  61. package/lib/cjs/utils/contribution.js +13 -1
  62. package/lib/cjs/utils/string.js +1 -1
  63. package/lib/esm/assets/onBoarding/android.d.ts +1 -1
  64. package/lib/esm/assets/onBoarding/android.js +1 -1
  65. package/lib/esm/components/CategoryFollowersButton/CategoryFollowersButton.d.ts +2 -2
  66. package/lib/esm/components/CategoryFollowersButton/CategoryFollowersButton.js +20 -15
  67. package/lib/esm/components/CommentObject/CommentObject.js +8 -5
  68. package/lib/esm/components/CommentObjectReply/CommentObjectReply.js +5 -2
  69. package/lib/esm/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  70. package/lib/esm/components/CreateEventButton/CreateEventButton.js +1 -1
  71. package/lib/esm/components/EditEventButton/EditEventButton.js +2 -2
  72. package/lib/esm/components/Editor/plugins/AutoLinkPlugin.js +7 -1
  73. package/lib/esm/components/Event/Event.js +4 -4
  74. package/lib/esm/components/EventForm/EventAddress.js +6 -9
  75. package/lib/esm/components/EventForm/EventForm.js +32 -25
  76. package/lib/esm/components/EventForm/constants.d.ts +4 -4
  77. package/lib/esm/components/EventForm/constants.js +4 -4
  78. package/lib/esm/components/EventForm/utils.d.ts +3 -3
  79. package/lib/esm/components/EventForm/utils.js +8 -5
  80. package/lib/esm/components/EventHeader/EventHeader.js +5 -36
  81. package/lib/esm/components/EventInviteButton/EventInviteButton.js +5 -5
  82. package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +5 -9
  83. package/lib/esm/components/EventMembersWidget/TabContentComponent.js +1 -1
  84. package/lib/esm/components/EventParticipantsButton/EventParticipantsButton.js +9 -5
  85. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  86. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +16 -18
  87. package/lib/esm/components/Events/Events.js +11 -34
  88. package/lib/esm/components/Events/PastEventsFilter.js +2 -12
  89. package/lib/esm/components/FeedObject/Actions/Share/Share.js +1 -1
  90. package/lib/esm/components/FeedObject/FeedObject.js +5 -6
  91. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +2 -2
  92. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +20 -15
  93. package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +8 -3
  94. package/lib/esm/components/NavigationMenuIconButton/DefaultDrawerContent.js +27 -5
  95. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +1 -1
  96. package/lib/esm/components/Notification/Comment/Comment.js +2 -2
  97. package/lib/esm/components/Notification/Notification.js +1 -1
  98. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +2 -2
  99. package/lib/esm/components/OnBoardingWidget/Steps/App/App.js +2 -1
  100. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +67 -106
  101. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +4 -7
  102. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +3 -2
  103. package/lib/esm/components/Skeleton/AvatarGroupSkeleton.js +4 -4
  104. package/lib/esm/components/SuggestedEventsWidget/Arrow.js +2 -1
  105. package/lib/esm/components/TagAutocomplete/TagAutocomplete.d.ts +44 -0
  106. package/lib/esm/components/TagAutocomplete/TagAutocomplete.js +90 -0
  107. package/lib/esm/components/TagAutocomplete/index.d.ts +3 -0
  108. package/lib/esm/components/TagAutocomplete/index.js +2 -0
  109. package/lib/esm/components/UserActionIconButton/UserActionIconButton.js +24 -2
  110. package/lib/esm/components/UserProfileEdit/Section/PublicInfo.js +1 -1
  111. package/lib/esm/components/UserProfileEdit/UserProfileEdit.d.ts +1 -1
  112. package/lib/esm/components/UserProfileEdit/UserProfileEdit.js +1 -1
  113. package/lib/esm/components/UserSocialAssociation/UserSocialAssociation.js +18 -6
  114. package/lib/esm/constants/SocialShare.d.ts +12 -0
  115. package/lib/esm/constants/SocialShare.js +13 -0
  116. package/lib/esm/index.d.ts +3 -2
  117. package/lib/esm/index.js +3 -2
  118. package/lib/esm/shared/CopyTextArea/index.d.ts +10 -0
  119. package/lib/esm/shared/CopyTextArea/index.js +74 -0
  120. package/lib/esm/utils/buttonCounters.d.ts +1 -0
  121. package/lib/esm/utils/buttonCounters.js +11 -0
  122. package/lib/esm/utils/contribution.d.ts +7 -0
  123. package/lib/esm/utils/contribution.js +11 -0
  124. package/lib/esm/utils/string.js +1 -1
  125. package/lib/umd/2aa155858f48b8f3911a.eot +0 -0
  126. package/lib/umd/36f3af7f155d916c26ff.woff2 +0 -0
  127. package/lib/umd/749.js +2 -0
  128. package/lib/umd/80884d7cc0fcb1a47982.svg +1 -0
  129. package/lib/umd/a221d3aba0f6753cfbb7.ttf +0 -0
  130. package/lib/umd/assets/icons.svg +251 -0
  131. package/lib/umd/c3528e120c4e831db2ae.woff +0 -0
  132. package/lib/umd/react-ui.js +1 -1
  133. package/package.json +9 -8
  134. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/reducer.d.ts +0 -15
  135. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/reducer.js +0 -42
  136. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/reducer.d.ts +0 -15
  137. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/reducer.js +0 -37
  138. package/lib/umd/32.js +0 -2
  139. /package/lib/umd/{32.js.LICENSE.txt → 749.js.LICENSE.txt} +0 -0
@@ -38,13 +38,13 @@ const classes = {
38
38
  const Root = styled(Button, {
39
39
  name: PREFIX,
40
40
  slot: 'Root',
41
- overridesResolver: (props, styles) => styles.root
42
- })(({ theme }) => ({}));
41
+ overridesResolver: (_props, styles) => styles.root
42
+ })(() => ({}));
43
43
  const DialogRoot = styled(BaseDialog, {
44
44
  name: PREFIX,
45
45
  slot: 'Root',
46
- overridesResolver: (props, styles) => styles.dialogRoot
47
- })(({ theme }) => ({}));
46
+ overridesResolver: (_props, styles) => styles.dialogRoot
47
+ })(() => ({}));
48
48
  /**
49
49
  *> API documentation for the Community-JS Event Invite Button component. Learn about the available props and the CSS API.
50
50
  *
@@ -194,7 +194,7 @@ export default function EventInviteButton(inProps) {
194
194
  });
195
195
  };
196
196
  // Autocomplete Handlers
197
- const handleInputChange = (event, value, reason) => {
197
+ const handleInputChange = (_event, value, reason) => {
198
198
  switch (reason) {
199
199
  case 'input':
200
200
  setValue(value);
@@ -3,8 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Box, CardContent, Typography } from '@mui/material';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
6
- import { GoogleMap, MarkerF, useLoadScript } from '@react-google-maps/api';
7
- import { useSCContext, useSCFetchEvent } from '@selfcommunity/react-core';
6
+ import { GoogleMap, MarkerF } from '@react-google-maps/api';
7
+ import { useSCGoogleApiLoader, useSCFetchEvent } from '@selfcommunity/react-core';
8
8
  import { SCEventLocationType } from '@selfcommunity/types';
9
9
  import classNames from 'classnames';
10
10
  import { FormattedMessage } from 'react-intl';
@@ -56,7 +56,6 @@ const Root = styled(Widget, {
56
56
  * @param inProps
57
57
  */
58
58
  export default function EventLocationWidget(inProps) {
59
- var _a, _b, _c;
60
59
  // PROPS
61
60
  const props = useThemeProps({
62
61
  props: inProps,
@@ -65,18 +64,15 @@ export default function EventLocationWidget(inProps) {
65
64
  const { className, event, eventId } = props, rest = __rest(props, ["className", "event", "eventId"]);
66
65
  // STATE
67
66
  const { scEvent } = useSCFetchEvent({ id: eventId, event });
68
- const scContext = useSCContext();
69
- const { isLoaded } = useLoadScript({
70
- googleMapsApiKey: scContext.settings.integrations.geocoding.apiKey,
71
- libraries: ['maps']
72
- });
67
+ // HOOKS
68
+ const { isLoaded, geocodingApiKey } = useSCGoogleApiLoader();
73
69
  const mapOptions = {
74
70
  fullscreenControl: false,
75
71
  mapTypeControl: false,
76
72
  streetViewControl: false,
77
73
  zoomControl: false // Disables the zoom control (+/- buttons)
78
74
  };
79
- if (!((_c = (_b = (_a = scContext === null || scContext === void 0 ? void 0 : scContext.settings) === null || _a === void 0 ? void 0 : _a.integrations) === null || _b === void 0 ? void 0 : _b.geocoding) === null || _c === void 0 ? void 0 : _c.apiKey) || (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === SCEventLocationType.ONLINE) {
75
+ if (!geocodingApiKey || (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === SCEventLocationType.ONLINE) {
80
76
  return _jsx(HiddenPlaceholder, {});
81
77
  }
82
78
  /**
@@ -44,7 +44,7 @@ export default function TabContentComponent(props) {
44
44
  // EFFECTS
45
45
  useEffect(() => {
46
46
  updatesInvited.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
47
- updatesParticipants.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.ADD_MEMBER}`, handleToggleMember);
47
+ updatesParticipants.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.MEMBERS}`, handleToggleMember);
48
48
  return () => {
49
49
  updatesInvited.current && PubSub.unsubscribe(updatesInvited.current);
50
50
  updatesParticipants.current && PubSub.unsubscribe(updatesParticipants.current);
@@ -14,12 +14,12 @@ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
14
14
  import { SCOPE_SC_UI } from '../../constants/Errors';
15
15
  import BaseDialog from '../../shared/BaseDialog';
16
16
  import InfiniteScroll from '../../shared/InfiniteScroll';
17
+ import { numberFormatter } from '../../utils/buttonCounters';
17
18
  import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
18
19
  import User, { UserSkeleton } from '../User';
19
20
  const PREFIX = 'SCEventParticipantsButton';
20
21
  const classes = {
21
22
  root: `${PREFIX}-root`,
22
- avatar: `${PREFIX}-avatar`,
23
23
  participants: `${PREFIX}-participants`,
24
24
  dialogRoot: `${PREFIX}-dialog-root`,
25
25
  infiniteScroll: `${PREFIX}-infinite-scroll`,
@@ -28,7 +28,8 @@ const classes = {
28
28
  const Root = styled(Button, {
29
29
  name: PREFIX,
30
30
  slot: 'Root',
31
- overridesResolver: (_props, styles) => styles.root
31
+ overridesResolver: (_props, styles) => styles.root,
32
+ shouldForwardProp: (prop) => prop !== 'followers'
32
33
  })(() => ({}));
33
34
  const DialogRoot = styled(BaseDialog, {
34
35
  name: PREFIX,
@@ -71,8 +72,8 @@ export default function EventParticipantsButton(inProps) {
71
72
  const [open, setOpen] = useState(false);
72
73
  // HOOKS
73
74
  const { scEvent } = useSCFetchEvent({ id: eventId, event });
74
- const participantsAvailable = useMemo(() => scEvent.privacy === SCEventPrivacyType.PUBLIC ||
75
- [SCEventSubscriptionStatusType.SUBSCRIBED, SCEventSubscriptionStatusType.GOING, SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent.subscription_status) > -1, [scEvent]);
75
+ const participantsAvailable = useMemo(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PUBLIC ||
76
+ [SCEventSubscriptionStatusType.SUBSCRIBED, SCEventSubscriptionStatusType.GOING, SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
76
77
  useDeepCompareEffectNoCheck(() => {
77
78
  setFollowers([]);
78
79
  setLoading(true);
@@ -123,11 +124,14 @@ export default function EventParticipantsButton(inProps) {
123
124
  .catch((error) => Logger.error(SCOPE_SC_UI, error))
124
125
  .then(() => setLoading(false));
125
126
  }, [followers, scEvent, next]);
127
+ const renderSurplus = useCallback(() => numberFormatter(followers.length), [followers]);
126
128
  /**
127
129
  * Opens dialog votes
128
130
  */
129
131
  const handleToggleDialogOpen = useCallback(() => {
130
132
  setOpen((prev) => !prev);
131
133
  }, [setOpen]);
132
- return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0 }, rest, { children: [!hideCaption && (_jsx(Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : (_jsx(AvatarGroup, Object.assign({ total: followers.length }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar, className: classes.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.dialogTitle", id: "ui.eventParticipantsButton.dialogTitle", values: { total: scEvent.goings_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: followers.length, next: fetchFollowers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventParticipantsButton.noOtherParticipants", defaultMessage: "ui.eventParticipantsButton.noOtherParticipants" }) })) }, { children: _jsx(List, { children: followers.map((follower) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
134
+ return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0,
135
+ // @ts-expect-error this is needed to use followers into SCEventParticipantsButton
136
+ followers: followers }, rest, { children: [!hideCaption && (_jsx(Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : (_jsx(AvatarGroup, Object.assign({ total: followers.length, renderSurplus: renderSurplus }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.dialogTitle", id: "ui.eventParticipantsButton.dialogTitle", values: { total: scEvent.goings_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: followers.length, next: fetchFollowers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventParticipantsButton.noOtherParticipants", defaultMessage: "ui.eventParticipantsButton.noOtherParticipants" }) })) }, { children: _jsx(List, { children: followers.map((follower) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
133
137
  }
@@ -1,4 +1,4 @@
1
- import { SCEventSubscriptionStatusType, SCEventType, SCUserType } from '@selfcommunity/types';
1
+ import { SCEventType, SCUserType } from '@selfcommunity/types';
2
2
  export interface EventSubscribeButtonProps {
3
3
  /**
4
4
  * Overrides or extends the styles applied to the component.
@@ -25,7 +25,7 @@ export interface EventSubscribeButtonProps {
25
25
  * @param user
26
26
  * @param joined
27
27
  */
28
- onSubscribe?: (event: SCEventType, status: SCEventSubscriptionStatusType | null) => any;
28
+ onSubscribe?: (event: SCEventType) => any;
29
29
  /**
30
30
  * Others properties
31
31
  */
@@ -4,12 +4,12 @@ import { LoadingButton } from '@mui/lab';
4
4
  import { Box, Button, Checkbox, CircularProgress, FormControlLabel, Icon, Menu, MenuItem, SwipeableDrawer, useMediaQuery, useTheme } from '@mui/material';
5
5
  import { styled } from '@mui/material/styles';
6
6
  import { useThemeProps } from '@mui/system';
7
- import { getEventStatus, useSCContext, useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
7
+ import { useSCContext, useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
8
8
  import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
9
9
  import { CacheStrategies, Logger } from '@selfcommunity/utils';
10
10
  import classNames from 'classnames';
11
11
  import PubSub from 'pubsub-js';
12
- import { useEffect, useMemo, useState } from 'react';
12
+ import { useCallback, useEffect, useMemo, useState } from 'react';
13
13
  import { FormattedMessage } from 'react-intl';
14
14
  import { SCOPE_SC_UI } from '../../constants/Errors';
15
15
  import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
@@ -93,19 +93,19 @@ export default function EventSubscribeButton(inProps) {
93
93
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
94
94
  // CONST
95
95
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
96
- const { scEvent } = useSCFetchEvent({
96
+ const { scEvent, setSCEvent } = useSCFetchEvent({
97
97
  id: eventId,
98
98
  event,
99
99
  cacheStrategy: authUserId ? CacheStrategies.CACHE_FIRST : CacheStrategies.STALE_WHILE_REVALIDATE
100
100
  });
101
101
  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]);
102
102
  // HANDLERS
103
- const handleOpen = (event) => {
103
+ const handleOpen = useCallback((event) => {
104
104
  setAnchorEl(event.currentTarget);
105
- };
106
- const handleClose = () => {
105
+ }, [setAnchorEl]);
106
+ const handleClose = useCallback(() => {
107
107
  setAnchorEl(null);
108
- };
108
+ }, [setAnchorEl]);
109
109
  useEffect(() => {
110
110
  /**
111
111
  * Call scEventsManager.subscriptionStatus inside an effect
@@ -115,25 +115,23 @@ export default function EventSubscribeButton(inProps) {
115
115
  setStatus(scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus(scEvent));
116
116
  }
117
117
  }, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent]);
118
- const toggleEventAttendance = (eventStatus) => {
118
+ const toggleEventAttendance = useCallback((eventStatus) => {
119
119
  setLoading(true);
120
120
  const isGoing = eventStatus === SCEventSubscriptionStatusType.GOING ||
121
121
  !(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) ||
122
122
  (scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) === SCEventSubscriptionStatusType.INVITED;
123
- const toggleAction = isGoing
124
- ? scEventsManager.toggleEventAttendance(scEvent, (user === null || user === void 0 ? void 0 : user.id) || null)
125
- : scEventsManager.toggleEventNonattendance(scEvent);
123
+ const toggleAction = isGoing ? scEventsManager.toggleEventAttendance(scEvent) : scEventsManager.toggleEventNonattendance(scEvent);
126
124
  toggleAction
127
- .then(() => {
128
- onSubscribe === null || onSubscribe === void 0 ? void 0 : onSubscribe(scEvent, getEventStatus(scEvent, isGoing));
125
+ .then((data) => {
126
+ onSubscribe ? onSubscribe(data) : setSCEvent(data);
129
127
  setLoading(false);
130
- PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.ADD_MEMBER}`, scUserContext.user);
128
+ PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.MEMBERS}`);
131
129
  })
132
130
  .catch((e) => {
133
131
  Logger.error(SCOPE_SC_UI, e);
134
132
  });
135
- };
136
- const handleToggleAction = (event) => {
133
+ }, [scEvent, scEventsManager, onSubscribe, setLoading]);
134
+ const handleToggleAction = useCallback((event) => {
137
135
  setAnchorEl(null);
138
136
  if (!scUserContext.user) {
139
137
  scContext.settings.handleAnonymousAction();
@@ -141,9 +139,9 @@ export default function EventSubscribeButton(inProps) {
141
139
  else if (status !== undefined) {
142
140
  toggleEventAttendance(event.target.value);
143
141
  }
144
- };
142
+ }, [scUserContext.user, status, scContext.settings]);
145
143
  function renderMenuItems() {
146
- return (_jsx(Box, { children: options.map((option) => (_jsx(MenuItem, Object.assign({ className: classes.item, disabled: loading }, { children: _jsx(FormControlLabel, { label: option.label, control: loading ? (_jsx(CircularProgress, { color: 'primary', size: 20 })) : (_jsx(Checkbox, { size: "small", checked: status === option.value, value: option.value, onChange: handleToggleAction, name: `${option.value}-option`, inputProps: { 'aria-label': `${option.label}` } })), labelPlacement: "start" }) }), option.value))) }));
144
+ return (_jsx(Box, { children: options.map((option) => (_jsx(MenuItem, Object.assign({ className: classes.item, disabled: loading }, { children: _jsx(FormControlLabel, { label: option.label, control: loading ? (_jsx(CircularProgress, { color: "primary", size: 20 })) : (_jsx(Checkbox, { size: "small", checked: status === option.value, value: option.value, onChange: handleToggleAction, name: `${option.value}-option`, inputProps: { 'aria-label': `${option.label}` } })), labelPlacement: "start" }) }), option.value))) }));
147
145
  }
148
146
  /**
149
147
  * Get current translated status
@@ -1,25 +1,23 @@
1
1
  import { __rest } from "tslib";
2
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
- import { styled } from '@mui/material/styles';
5
- import { useThemeProps } from '@mui/system';
3
+ import { Box, Button, Chip, FormControl, Grid, Icon, IconButton, InputAdornment, InputLabel, MenuItem, Radio, Select, styled, TextField, Typography, useMediaQuery, useTheme, useThemeProps } from '@mui/material';
6
4
  import { Endpoints, http } from '@selfcommunity/api-services';
7
5
  import { SCPreferences, SCPreferencesContext, SCUserContext, UserUtils } from '@selfcommunity/react-core';
8
- import { SCEventDateFilterType, SCEventSubscriptionStatusType, SCEventLocationFilterType } from '@selfcommunity/types';
6
+ import { SCEventDateFilterType, SCEventLocationFilterType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
9
7
  import { Logger } from '@selfcommunity/utils';
10
8
  import classNames from 'classnames';
9
+ import PubSub from 'pubsub-js';
11
10
  import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
12
11
  import { FormattedMessage } from 'react-intl';
13
12
  import { SCOPE_SC_UI } from '../../constants/Errors';
14
13
  import { DEFAULT_PAGINATION_OFFSET } from '../../constants/Pagination';
14
+ import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
15
15
  import CreateEventButton from '../CreateEventButton';
16
16
  import Event, { EventSkeleton } from '../Event';
17
17
  import Skeleton from '../Events/Skeleton';
18
18
  import { PREFIX } from './constants';
19
- import PastEventsFilter from './PastEventsFilter';
20
- import PubSub from 'pubsub-js';
21
- import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
22
19
  import LocationEventsFilter from './LocationEventsFilter';
20
+ import PastEventsFilter from './PastEventsFilter';
23
21
  const classes = {
24
22
  root: `${PREFIX}-root`,
25
23
  filters: `${PREFIX}-filters`,
@@ -211,39 +209,18 @@ export default function Events(inProps) {
211
209
  /**
212
210
  * Renders events list
213
211
  */
214
- const c = (_jsxs(_Fragment, { children: [showFilters && (_jsx(Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? (_jsxs(_Fragment, { children: [(events.length !== 0 || (events.length === 0 && showMyEvents)) && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
215
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
216
- // @ts-ignore
217
- , {
218
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
219
- // @ts-ignore
220
- color: showMyEvents ? 'secondary' : 'default',
221
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
222
- // @ts-ignore
223
- variant: showMyEvents ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
224
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
225
- // @ts-ignore
226
- showFollowed: showMyEvents, deleteIcon: showMyEvents ? _jsx(Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, autoHide: !loading && !events.length, disabled: loading }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !loading && !events.length && !showPastEvents, disabled: loading }) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, autoHide: !loading && !events.length, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, md: 3 }, { 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 || (!events.length && !query), onKeyUp: (e) => {
212
+ const c = (_jsxs(_Fragment, { children: [showFilters && (_jsx(Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? (_jsxs(_Fragment, { children: [(events.length !== 0 || (events.length === 0 && showMyEvents)) && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot, { color: showMyEvents ? 'secondary' : 'default', variant: showMyEvents ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
213
+ // @ts-expect-error this is needed to use showFollowed into SCEvents
214
+ showFollowed: showMyEvents, deleteIcon: showMyEvents ? _jsx(Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: loading }) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, autoHide: !loading && !events.length, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, md: 3 }, { 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 || (!events.length && !query), onKeyUp: (e) => {
227
215
  e.preventDefault();
228
216
  if (e.key === 'Enter') {
229
217
  fetchEvents(true);
230
218
  }
231
219
  }, InputProps: {
232
220
  endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? (_jsx(IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading || (!events.length && !query) }, { children: _jsx(Icon, { children: "search" }) }))) : (_jsx(Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: _jsx(Icon, { children: "search" }), disabled: loading || (!events.length && !query) })) })))
233
- } }) })), _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 || loading || (!events.length && dateSearch === SCEventDateFilterType.ANY), 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))) }))] })) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) })), authUserId && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
234
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
235
- // @ts-ignore
236
- , {
237
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
238
- // @ts-ignore
239
- color: showFollowed ? 'secondary' : 'default',
240
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
241
- // @ts-ignore
242
- variant: showFollowed ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByFollowedInterest", defaultMessage: "ui.events.filterByFollowedInterest" }), onClick: handleChipClick,
243
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
244
- // @ts-ignore
245
- showFollowed: showFollowed, deleteIcon: showFollowed ? _jsx(Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading || (!events.length && !showFollowed) }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== SCEventDateFilterType.ANY || loading || (!events.length && !showPastEvents) }) }))] })) }))), _jsx(_Fragment, { children: loading ? (_jsx(Skeleton, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : (_jsx(_Fragment, { children: !events.length ? (_jsx(Box, Object.assign({ className: classes.noResults }, { children: (onlyStaffEnabled && !UserUtils.isStaff(scUserContext.user)) ||
246
- (onlyStaffEnabled && UserUtils.isStaff(scUserContext.user) && general) ? (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps)), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: _jsx(CreateEventButton, {}) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title.onlyStaff", defaultMessage: "ui.events.noEvents.title.onlyStaff" }) }))] })) }))) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, GridContainerComponentProps, { children: _jsxs(_Fragment, { children: [events.map((event) => (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.item }, GridItemComponentProps, { children: _jsx(Event, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), authUserId && events.length % 2 !== 0 && (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.itemSkeleton }, GridItemComponentProps, { children: _jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: _jsx(CreateEventButton, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: _jsx(FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && (_jsx(Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: _jsx(FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })) })] }));
221
+ } }) })), _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 || loading || (!events.length && dateSearch === SCEventDateFilterType.ANY), 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))) }))] })) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) })), authUserId && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot, { color: showFollowed ? 'secondary' : 'default', variant: showFollowed ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByFollowedInterest", defaultMessage: "ui.events.filterByFollowedInterest" }), onClick: handleChipClick,
222
+ // @ts-expect-error this is needed to use showFollowed into SCEvents
223
+ showFollowed: showFollowed, deleteIcon: showFollowed ? _jsx(Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading || (!events.length && !showFollowed) }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== SCEventDateFilterType.ANY || loading }) }))] })) }))), _jsx(_Fragment, { children: loading ? (_jsx(Skeleton, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : (_jsx(_Fragment, { children: !events.length ? (_jsx(Box, Object.assign({ className: classes.noResults }, { children: general ? (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (onlyStaffEnabled && UserUtils.isStaff(scUserContext.user)) || !onlyStaffEnabled ? _jsx(CreateEventButton, {}) : null })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (onlyStaffEnabled && UserUtils.isStaff(scUserContext.user)) || !onlyStaffEnabled ? _jsx(CreateEventButton, {}) : null })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title.personal", defaultMessage: "ui.events.noEvents.title.personal" }) }))] })) }))) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, GridContainerComponentProps, { children: _jsxs(_Fragment, { children: [events.map((event) => (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.item }, GridItemComponentProps, { children: _jsx(Event, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), authUserId && events.length % 2 !== 0 && (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.itemSkeleton }, GridItemComponentProps, { children: _jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: _jsx(CreateEventButton, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: _jsx(FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && (_jsx(Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: _jsx(FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })) })] }));
247
224
  /**
248
225
  * Renders root object (if content availability community option is false and user is anonymous, component is hidden)
249
226
  */
@@ -1,8 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Icon } from '@mui/material';
3
+ import { Icon, useThemeProps } from '@mui/material';
4
4
  import { FormattedMessage } from 'react-intl';
5
- import { useThemeProps } from '@mui/system';
6
5
  import { PREFIX } from './constants';
7
6
  import { EventsChipRoot } from './Events';
8
7
  export default function PastEventsFilter(inProps) {
@@ -15,16 +14,7 @@ export default function PastEventsFilter(inProps) {
15
14
  if (autoHide) {
16
15
  return null;
17
16
  }
18
- return (_jsx(EventsChipRoot
19
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
20
- // @ts-ignore
21
- , Object.assign({
22
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
23
- // @ts-ignore
24
- color: showPastEvents ? 'secondary' : 'default',
25
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
26
- // @ts-ignore
27
- variant: showPastEvents ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByPastEvents", defaultMessage: "ui.events.filterByPastEvents" }), onClick: handleClick,
17
+ return (_jsx(EventsChipRoot, Object.assign({ color: showPastEvents ? 'secondary' : 'default', variant: showPastEvents ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByPastEvents", defaultMessage: "ui.events.filterByPastEvents" }), onClick: handleClick,
28
18
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
29
19
  // @ts-ignore
30
20
  showPastEvents: showPastEvents, deleteIcon: showPastEvents ? _jsx(Icon, { children: "close" }) : null, onDelete: showPastEvents ? handleDeleteClick : undefined }, rest)));
@@ -114,7 +114,7 @@ export default function Share(props) {
114
114
  if (shareMedias.length) {
115
115
  sharedObjectId = shareMedias[0].embed.metadata.id;
116
116
  }
117
- const isMediaEvent = obj.medias.some((media) => media.embed.embed_type === MEDIA_EMBED_SC_SHARED_EVENT);
117
+ const isMediaEvent = obj.medias.some((media) => { var _a; return ((_a = media.embed) === null || _a === void 0 ? void 0 : _a.embed_type) === MEDIA_EMBED_SC_SHARED_EVENT; });
118
118
  return http
119
119
  .request({
120
120
  url: Endpoints.ComposerMediaCreate.url(),
@@ -135,7 +135,7 @@ const Root = styled(Widget, {
135
135
  * @param inProps
136
136
  */
137
137
  export default function FeedObject(inProps) {
138
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m;
138
+ var _a, _b, _c, _d, _f, _g, _h;
139
139
  // PROPS
140
140
  const props = useThemeProps({
141
141
  props: inProps,
@@ -164,7 +164,7 @@ export default function FeedObject(inProps) {
164
164
  const [isReplying, setIsReplying] = useState(false);
165
165
  const [selectedActivities, setSelectedActivities] = useState(getInitialSelectedActivitiesType());
166
166
  const [expanded, setExpanded] = useState(summaryExpanded);
167
- const hasEvent = useMemo(() => { var _a; return (obj === null || obj === void 0 ? void 0 : obj.medias.length) && ((_a = obj.medias[0].embed) === null || _a === void 0 ? void 0 : _a.embed_type) === MEDIA_EMBED_SC_SHARED_EVENT; }, [obj === null || obj === void 0 ? void 0 : obj.medias]);
167
+ const hasEvent = useMemo(() => { var _a; return (obj === null || obj === void 0 ? void 0 : obj.medias.length) > 0 && ((_a = obj.medias[0].embed) === null || _a === void 0 ? void 0 : _a.embed_type) === MEDIA_EMBED_SC_SHARED_EVENT; }, [obj === null || obj === void 0 ? void 0 : obj.medias]);
168
168
  const _hideFollowAction = useMemo(() => { var _a, _b, _c, _d; return hideFollowAction || (hasEvent && ((_d = (_c = (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.embed) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.active) === false); }, [hideFollowAction, hasEvent, obj]);
169
169
  // INTL
170
170
  const intl = useIntl();
@@ -429,16 +429,15 @@ export default function FeedObject(inProps) {
429
429
  else if (template === SCFeedObjectTemplateType.PREVIEW ||
430
430
  template === SCFeedObjectTemplateType.DETAIL ||
431
431
  template === SCFeedObjectTemplateType.SEARCH) {
432
- objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", label: obj.event.name, icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) })))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) }))), _jsx(CardHeader, { className: classes.header, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: 'span', date: obj.added_at }) })), obj.location && (_jsxs(_Fragment, { children: [_jsx(Bullet, {}), _jsxs(Box, Object.assign({ className: classes.location }, { children: [_jsx(Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), _jsx(Bullet, {}), _jsx(Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? (_jsx(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) }))) }))] }), action: renderHeaderAction() }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(_Fragment, { children: template === SCFeedObjectTemplateType.DETAIL ? (_jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ visible: pollVisible ||
432
+ objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx(Chip, { className: classes.group, color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id)), obj.event && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", label: obj.event.name, icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id)), _jsx(CardHeader, { className: classes.header, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: 'span', date: obj.added_at }) })), obj.location && (_jsxs(_Fragment, { children: [_jsx(Bullet, {}), _jsxs(Box, Object.assign({ className: classes.location }, { children: [_jsx(Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), _jsx(Bullet, {}), _jsx(Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? (_jsx(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) }))) }))] }), action: renderHeaderAction() }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(_Fragment, { children: template === SCFeedObjectTemplateType.DETAIL ? (_jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ visible: pollVisible ||
433
433
  template === SCFeedObjectTemplateType.DETAIL ||
434
- Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), _jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy }))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideCommentAction: template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, hideVoteAction: hasEvent && !((_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _d === void 0 ? void 0 : _d.metadata) === null || _f === void 0 ? void 0 : _f.active), hideShareAction: hasEvent && !((_h = (_g = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active), VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), (template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_m = (_l = (_k = (_j = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.embed) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.active) === true)) ||
435
- (expandedActivities && (_jsx(Box, Object.assign({ className: classes.replyContent }, { children: _jsx(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) }))))] })), template === SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (_jsx(Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: _jsx(CardContent, Object.assign({ className: classes.activitiesContent }, { children: _jsx(Activities, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
434
+ Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), _jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy }))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideCommentAction: template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), ((template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_h = (_g = (_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _d === void 0 ? void 0 : _d[0]) === null || _f === void 0 ? void 0 : _f.embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active))) || expandedActivities) && (_jsx(Box, Object.assign({ className: classes.replyContent }, { children: _jsx(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), template === SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (_jsx(Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: _jsx(CardContent, Object.assign({ className: classes.activitiesContent }, { children: _jsx(Activities, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
436
435
  CommentComponentProps: Object.assign({ onDelete: handleDeleteComment, truncateContent: true, CommentsObjectComponentProps: { inPlaceLoadMoreContents: false } }, CommentComponentProps),
437
436
  CommentObjectSkeletonProps: CommentObjectSkeletonProps
438
437
  }, cacheStrategy: cacheStrategy }, ActivitiesProps), selectedActivities) })) }))), composerOpen && (_jsx(Composer, { open: composerOpen, feedObject: obj, onClose: handleToggleEdit, onSuccess: handleEditSuccess, maxWidth: "sm", fullWidth: true }))] }))) : (_jsx(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
439
438
  }
440
439
  else if (template === SCFeedObjectTemplateType.SHARE) {
441
- objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(React.Fragment, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) })))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) }))), _jsx(CardHeader, { classes: { root: classes.header }, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { date: obj.added_at }) })) }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, visible: Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length) }, PollObjectProps))) }))] }))] })) : (_jsx(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
440
+ objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(React.Fragment, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) }))), _jsx(CardHeader, { classes: { root: classes.header }, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { date: obj.added_at }) })) }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, visible: Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length) }, PollObjectProps))) }))] }))] })) : (_jsx(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
442
441
  }
443
442
  else {
444
443
  objElement = (_jsx(React.Fragment, { children: obj ? (_jsx(BaseItem, { elevation: 0, className: classes.snippet, image: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, { alt: obj.author.username, variant: "circular", src: obj.author.avatar, className: classes.avatar }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), _jsx(Typography, Object.assign({ variant: "body2", className: classes.snippetContent }, { children: _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: getContributionSnippet(obj) })) }))] }), disableTypography: true, secondary: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", spacing: 2, alignItems: "center" }, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: "span", date: obj.added_at }) })), _jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), variant: "text", color: "secondary", size: "small" }, { children: _jsx(FormattedMessage, { id: "ui.feedObject.comment", defaultMessage: "ui.feedObject.comment" }) }))] })) })) : (_jsx(FeedObjectSkeleton, Object.assign({}, FeedObjectSkeletonProps))) }));
@@ -1,6 +1,6 @@
1
- import { BaseDialogProps } from '../../shared/BaseDialog';
2
- import { SCGroupType } from '@selfcommunity/types';
3
1
  import { ButtonProps } from '@mui/material/Button/Button';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ import { BaseDialogProps } from '../../shared/BaseDialog';
4
4
  export interface GroupMembersButtonProps extends Pick<ButtonProps, Exclude<keyof ButtonProps, 'onClick' | 'disabled'>> {
5
5
  /**
6
6
  * Group Object
@@ -1,22 +1,23 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useEffect, useMemo, useState } from 'react';
4
- import { styled } from '@mui/material/styles';
5
3
  import { Avatar, AvatarGroup, Button, List, ListItem, Typography, useTheme } from '@mui/material';
6
- import BaseDialog from '../../shared/BaseDialog';
7
- import { FormattedMessage } from 'react-intl';
8
- import InfiniteScroll from '../../shared/InfiniteScroll';
9
- import User, { UserSkeleton } from '../User';
4
+ import { styled } from '@mui/material/styles';
5
+ import useMediaQuery from '@mui/material/useMediaQuery';
6
+ import { useThemeProps } from '@mui/system';
10
7
  import { Endpoints, GroupService, http } from '@selfcommunity/api-services';
11
8
  import { useSCFetchGroup } from '@selfcommunity/react-core';
12
9
  import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
13
- import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
14
- import classNames from 'classnames';
15
- import { useThemeProps } from '@mui/system';
16
- import useMediaQuery from '@mui/material/useMediaQuery';
17
10
  import { Logger } from '@selfcommunity/utils';
18
- import { SCOPE_SC_UI } from '../../constants/Errors';
11
+ import classNames from 'classnames';
12
+ import { useCallback, useEffect, useMemo, useState } from 'react';
13
+ import { FormattedMessage } from 'react-intl';
19
14
  import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
15
+ import { SCOPE_SC_UI } from '../../constants/Errors';
16
+ import BaseDialog from '../../shared/BaseDialog';
17
+ import InfiniteScroll from '../../shared/InfiniteScroll';
18
+ import { numberFormatter } from '../../utils/buttonCounters';
19
+ import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
20
+ import User, { UserSkeleton } from '../User';
20
21
  const PREFIX = 'SCGroupMembersButton';
21
22
  const classes = {
22
23
  root: `${PREFIX}-root`,
@@ -26,12 +27,13 @@ const classes = {
26
27
  const Root = styled(Button, {
27
28
  name: PREFIX,
28
29
  slot: 'Root',
29
- overridesResolver: (props, styles) => styles.root
30
+ overridesResolver: (_props, styles) => styles.root,
31
+ shouldForwardProp: (prop) => prop !== 'subscribers'
30
32
  })(() => ({}));
31
33
  const DialogRoot = styled(BaseDialog, {
32
34
  name: PREFIX,
33
- slot: 'Root',
34
- overridesResolver: (props, styles) => styles.dialogRoot
35
+ slot: 'DialogRoot',
36
+ overridesResolver: (_props, styles) => styles.dialogRoot
35
37
  })(() => ({}));
36
38
  /**
37
39
  *> API documentation for the Community-JS Group Members Button component. Learn about the available props and the CSS API.
@@ -125,8 +127,11 @@ export default function GroupMembersButton(inProps) {
125
127
  const handleToggleDialogOpen = useMemo(() => () => {
126
128
  setOpen((prev) => !prev);
127
129
  }, [setOpen]);
130
+ const renderSurplus = useCallback(() => numberFormatter(scGroup.subscribers_counter), [scGroup]);
128
131
  // RENDER
129
132
  const theme = useTheme();
130
133
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
131
- return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scGroup || scGroup.subscribers_counter === 0 }, rest, { children: loading || !scGroup ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scGroup.subscribers_counter }, { children: members.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) }))) })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: members.length, next: fetchMembers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: _jsx(List, { children: members.map((member) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
134
+ return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scGroup || scGroup.subscribers_counter === 0,
135
+ // @ts-expect-error this is needed to use subscribers into SCGroupMembersButton
136
+ subscribers: scGroup === null || scGroup === void 0 ? void 0 : scGroup.subscribers_counter }, rest, { children: loading || !scGroup ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scGroup.subscribers_counter, renderSurplus: renderSurplus }, { children: members.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) }))) })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: members.length, next: fetchMembers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: _jsx(List, { children: members.map((member) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
132
137
  }