@selfcommunity/react-ui 0.7.9-alpha.6 → 0.7.9-alpha.60

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 (160) hide show
  1. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +2 -2
  2. package/lib/cjs/components/CategoryHeader/Skeleton.js +3 -2
  3. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  4. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  5. package/lib/cjs/components/Composer/Attributes/Attributes.js +3 -3
  6. package/lib/cjs/components/Composer/Composer.js +3 -3
  7. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
  8. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
  9. package/lib/cjs/components/FeedObject/Contributors/Contributors.js +1 -1
  10. package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
  11. package/lib/cjs/components/FeedObject/FeedObject.js +23 -6
  12. package/lib/cjs/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
  13. package/lib/cjs/components/Group/Group.d.ts +8 -0
  14. package/lib/cjs/components/Group/Group.js +40 -5
  15. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
  16. package/lib/cjs/components/GroupForm/GroupForm.js +33 -10
  17. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
  18. package/lib/cjs/components/GroupHeader/GroupHeader.js +53 -11
  19. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +40 -7
  20. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +33 -11
  21. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
  22. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +221 -0
  23. package/lib/cjs/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
  24. package/lib/cjs/components/GroupInvitedWidget/Skeleton.js +38 -0
  25. package/lib/cjs/components/GroupInvitedWidget/constants.d.ts +1 -0
  26. package/lib/cjs/components/GroupInvitedWidget/constants.js +4 -0
  27. package/lib/cjs/components/GroupInvitedWidget/index.d.ts +4 -0
  28. package/lib/cjs/components/GroupInvitedWidget/index.js +8 -0
  29. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  30. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +8 -3
  31. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +25 -4
  32. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
  33. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
  34. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  35. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +145 -0
  36. package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
  37. package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
  38. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  39. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
  40. package/lib/cjs/components/Groups/Groups.d.ts +19 -16
  41. package/lib/cjs/components/Groups/Groups.js +85 -86
  42. package/lib/cjs/components/Groups/Skeleton.d.ts +4 -0
  43. package/lib/cjs/components/Groups/Skeleton.js +2 -2
  44. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  45. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +1 -1
  46. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
  47. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -4
  48. package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
  49. package/lib/cjs/components/Notification/Group/Group.js +78 -0
  50. package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
  51. package/lib/cjs/components/Notification/Group/index.js +5 -0
  52. package/lib/cjs/components/Notification/Notification.js +31 -1
  53. package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  54. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  55. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +12 -7
  56. package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  57. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  58. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
  59. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  60. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
  61. package/lib/cjs/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +6 -0
  62. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  63. package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
  64. package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
  65. package/lib/cjs/components/User/User.d.ts +6 -1
  66. package/lib/cjs/components/User/User.js +5 -4
  67. package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
  68. package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.js +46 -0
  69. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
  70. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +183 -0
  71. package/lib/cjs/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
  72. package/lib/cjs/components/UserSubscribedGroupsWidget/constants.js +4 -0
  73. package/lib/cjs/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
  74. package/lib/cjs/components/UserSubscribedGroupsWidget/index.js +8 -0
  75. package/lib/cjs/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
  76. package/lib/cjs/constants/PubSub.d.ts +28 -0
  77. package/lib/cjs/constants/PubSub.js +22 -0
  78. package/lib/cjs/index.d.ts +6 -2
  79. package/lib/cjs/index.js +15 -4
  80. package/lib/esm/components/BottomNavigation/BottomNavigation.js +2 -2
  81. package/lib/esm/components/CategoryHeader/Skeleton.js +3 -2
  82. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  83. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  84. package/lib/esm/components/Composer/Attributes/Attributes.js +3 -3
  85. package/lib/esm/components/Composer/Composer.js +3 -3
  86. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
  87. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
  88. package/lib/esm/components/FeedObject/Contributors/Contributors.js +1 -1
  89. package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
  90. package/lib/esm/components/FeedObject/FeedObject.js +24 -7
  91. package/lib/esm/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
  92. package/lib/esm/components/Group/Group.d.ts +8 -0
  93. package/lib/esm/components/Group/Group.js +44 -9
  94. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
  95. package/lib/esm/components/GroupForm/GroupForm.js +33 -10
  96. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
  97. package/lib/esm/components/GroupHeader/GroupHeader.js +55 -13
  98. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +40 -7
  99. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +33 -11
  100. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
  101. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +218 -0
  102. package/lib/esm/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
  103. package/lib/esm/components/GroupInvitedWidget/Skeleton.js +34 -0
  104. package/lib/esm/components/GroupInvitedWidget/constants.d.ts +1 -0
  105. package/lib/esm/components/GroupInvitedWidget/constants.js +1 -0
  106. package/lib/esm/components/GroupInvitedWidget/index.d.ts +4 -0
  107. package/lib/esm/components/GroupInvitedWidget/index.js +4 -0
  108. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  109. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +9 -4
  110. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +26 -5
  111. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
  112. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
  113. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  114. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +142 -0
  115. package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
  116. package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
  117. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  118. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
  119. package/lib/esm/components/Groups/Groups.d.ts +19 -16
  120. package/lib/esm/components/Groups/Groups.js +90 -91
  121. package/lib/esm/components/Groups/Skeleton.d.ts +4 -0
  122. package/lib/esm/components/Groups/Skeleton.js +2 -2
  123. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  124. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +1 -1
  125. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
  126. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +13 -6
  127. package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
  128. package/lib/esm/components/Notification/Group/Group.js +75 -0
  129. package/lib/esm/components/Notification/Group/index.d.ts +3 -0
  130. package/lib/esm/components/Notification/Group/index.js +2 -0
  131. package/lib/esm/components/Notification/Notification.js +31 -1
  132. package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  133. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  134. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +13 -8
  135. package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  136. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  137. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
  138. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  139. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
  140. package/lib/esm/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +7 -1
  141. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  142. package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
  143. package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
  144. package/lib/esm/components/User/User.d.ts +6 -1
  145. package/lib/esm/components/User/User.js +5 -4
  146. package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
  147. package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.js +42 -0
  148. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
  149. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +180 -0
  150. package/lib/esm/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
  151. package/lib/esm/components/UserSubscribedGroupsWidget/constants.js +1 -0
  152. package/lib/esm/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
  153. package/lib/esm/components/UserSubscribedGroupsWidget/index.js +4 -0
  154. package/lib/esm/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
  155. package/lib/esm/constants/PubSub.d.ts +28 -0
  156. package/lib/esm/constants/PubSub.js +19 -0
  157. package/lib/esm/index.d.ts +6 -2
  158. package/lib/esm/index.js +8 -4
  159. package/lib/umd/react-ui.js +1 -1
  160. package/package.json +6 -6
@@ -5,7 +5,7 @@ import { Grid, useMediaQuery, useTheme } from '@mui/material';
5
5
  import { useSCPreferences, useSCUser } from '@selfcommunity/react-core';
6
6
  import classNames from 'classnames';
7
7
  import { useThemeProps } from '@mui/system';
8
- import { SCFeatureName, SCPrivateMessageStatusType } from '@selfcommunity/types';
8
+ import { SCFeatureName, SCPrivateMessageStatusType, SCPrivateMessageType } from '@selfcommunity/types';
9
9
  import PrivateMessageThread from '../PrivateMessageThread';
10
10
  import PrivateMessageSnippets from '../PrivateMessageSnippets';
11
11
  import { PREFIX } from './constants';
@@ -65,6 +65,7 @@ export default function PrivateMessageComponent(inProps) {
65
65
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
66
66
  const [layout, setLayout] = useState('default');
67
67
  const [obj, setObj] = useState(id !== null && id !== void 0 ? id : null);
68
+ const [type, setType] = useState(null);
68
69
  const isNew = obj && obj === SCPrivateMessageStatusType.NEW;
69
70
  const [openNewMessage, setOpenNewMessage] = useState(isNew !== null && isNew !== void 0 ? isNew : false);
70
71
  const mobileSnippetsView = (layout === 'default' && !obj) || (layout === 'mobile' && !obj);
@@ -86,10 +87,12 @@ export default function PrivateMessageComponent(inProps) {
86
87
  /**
87
88
  * Handles thread opening on click
88
89
  * @param item
90
+ * @param type
89
91
  */
90
- const handleThreadOpening = (item) => {
91
- onItemClick && onItemClick(messageReceiver(item, authUserId));
92
- setObj(messageReceiver(item, authUserId));
92
+ const handleThreadOpening = (item, type) => {
93
+ onItemClick && onItemClick(item.group ? item.group.id : messageReceiver(item, authUserId), type);
94
+ setType(type);
95
+ setObj(item.group ? item : messageReceiver(item, authUserId));
93
96
  setOpenNewMessage(false);
94
97
  };
95
98
  /**
@@ -105,7 +108,8 @@ export default function PrivateMessageComponent(inProps) {
105
108
  const handleOpenNewMessage = () => {
106
109
  setOpenNewMessage(!openNewMessage);
107
110
  setObj(SCPrivateMessageStatusType.NEW);
108
- onItemClick && onItemClick(SCPrivateMessageStatusType.NEW);
111
+ setType(SCPrivateMessageType.NEW);
112
+ onItemClick && onItemClick(SCPrivateMessageStatusType.NEW, SCPrivateMessageType.NEW);
109
113
  };
110
114
  /**
111
115
  * Handles new messages open from user profile page or notifications section
@@ -121,13 +125,14 @@ export default function PrivateMessageComponent(inProps) {
121
125
  id && setLayout('mobile');
122
126
  setOpenNewMessage(false);
123
127
  setObj(null);
128
+ setType(null);
124
129
  onThreadBack && onThreadBack();
125
130
  };
126
131
  /**
127
132
  * Handles state update when a new message is sent
128
133
  */
129
134
  const handleOnNewMessageSent = (msg, isOne) => {
130
- onItemClick && onItemClick(isOne ? messageReceiver(msg, authUserId) : '');
135
+ onItemClick && onItemClick(isOne ? messageReceiver(msg, authUserId) : '', msg.group ? SCPrivateMessageType.GROUP : SCPrivateMessageType.USER);
131
136
  setObj(isOne ? messageReceiver(msg, authUserId) : null);
132
137
  setOpenNewMessage(false);
133
138
  };
@@ -147,14 +152,14 @@ export default function PrivateMessageComponent(inProps) {
147
152
  onSnippetClick: handleThreadOpening,
148
153
  onNewMessageClick: handleOpenNewMessage,
149
154
  onDeleteConfirm: handleDeleteThread
150
- }, userObj: obj, clearSearch: clear, elevation: 0 })));
155
+ }, threadObj: obj, clearSearch: clear, elevation: 0 })));
151
156
  }
152
157
  /**
153
158
  * Renders thread section
154
159
  */
155
160
  function renderThread() {
156
161
  return (React.createElement(Grid, { item: true, xs: 12, md: 7, className: classNames(classes.threadBox, { [classes.hide]: isMobile && mobileSnippetsView }) },
157
- React.createElement(PrivateMessageThread, { userObj: obj, openNewMessage: openNewMessage, onNewMessageClose: handleMessageBack, onNewMessageSent: handleOnNewMessageSent, onSingleMessageOpen: handleSingleMessage, elevation: 0 })));
162
+ React.createElement(PrivateMessageThread, { threadObj: obj, type: type, openNewMessage: openNewMessage, onNewMessageClose: handleMessageBack, onNewMessageSent: handleOnNewMessageSent, onSingleMessageOpen: handleSingleMessage, elevation: 0 })));
158
163
  }
159
164
  /**
160
165
  * Renders the component (if not hidden by autoHide prop)
@@ -72,10 +72,12 @@ export default function PrivateMessageSnippetItem(inProps) {
72
72
  // STATE
73
73
  const hasBadge = () => {
74
74
  var _a;
75
- if ((message === null || message === void 0 ? void 0 : message.receiver.id) !== ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id)) {
76
- return message === null || message === void 0 ? void 0 : message.receiver.community_badge;
75
+ if (message.receiver) {
76
+ if ((message === null || message === void 0 ? void 0 : message.receiver.id) !== ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id)) {
77
+ return message === null || message === void 0 ? void 0 : message.receiver.community_badge;
78
+ }
79
+ return message === null || message === void 0 ? void 0 : message.sender.community_badge;
77
80
  }
78
- return message === null || message === void 0 ? void 0 : message.sender.community_badge;
79
81
  };
80
82
  if (!message) {
81
83
  return React.createElement(PrivateMessageSnippetItemSkeleton, { elevation: 0 });
@@ -86,10 +88,13 @@ export default function PrivateMessageSnippetItem(inProps) {
86
88
  return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { secondaryAction: secondaryAction, disablePadding: true }),
87
89
  React.createElement(ListItemButton, { onClick: onItemClick, classes: { root: classNames({ [classes.unread]: message.thread_status === SCPrivateMessageStatusType.NEW }) } },
88
90
  React.createElement(ListItemAvatar, null,
89
- React.createElement(UserAvatar, { hide: !hasBadge() },
90
- React.createElement(Avatar, { alt: ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) === message.receiver.username ? message.sender.username : message.receiver.username, src: ((_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.username) === message.receiver.username ? message.sender.avatar : message.receiver.avatar }))),
91
+ React.createElement(UserAvatar, { hide: !hasBadge() }, message.group ? (React.createElement(Avatar, { alt: message.group.name, src: message.group.image_big })) : (React.createElement(Avatar, { alt: ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) === message.receiver.username ? message.sender.username : message.receiver.username, src: ((_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.username) === message.receiver.username ? message.sender.avatar : message.receiver.avatar })))),
91
92
  React.createElement(ListItemText, { primary: React.createElement(React.Fragment, null,
92
- React.createElement(Typography, { component: "span", className: classes.username }, ((_c = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _c === void 0 ? void 0 : _c.username) === message.receiver.username ? message.sender.username : message.receiver.username),
93
+ React.createElement(Typography, { component: "span", className: classes.username }, message.group
94
+ ? message.group.name
95
+ : ((_c = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _c === void 0 ? void 0 : _c.username) === message.receiver.username
96
+ ? message.sender.username
97
+ : message.receiver.username),
93
98
  hasBadge() && preferences && (React.createElement(Chip, { component: "span", className: classes.badgeLabel, size: "small", label: preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL] })),
94
99
  React.createElement(Typography, { color: "secondary", className: classes.time, component: "span" }, `${intl.formatDate(message.last_message_at, {
95
100
  day: '2-digit',
@@ -20,7 +20,7 @@ export interface PrivateMessageSnippetsProps extends CardProps {
20
20
  *
21
21
  */
22
22
  snippetActions?: {
23
- onSnippetClick?: (msg: any) => void;
23
+ onSnippetClick?: (msg: any, type: any) => void;
24
24
  onNewMessageClick?: () => void;
25
25
  onDeleteConfirm?: (msg: any) => void;
26
26
  };
@@ -29,10 +29,10 @@ export interface PrivateMessageSnippetsProps extends CardProps {
29
29
  */
30
30
  [p: string]: any;
31
31
  /**
32
- * thread user object
32
+ * thread user/ group object
33
33
  * @default null
34
34
  */
35
- userObj?: any;
35
+ threadObj?: any;
36
36
  }
37
37
  /**
38
38
  * > API documentation for the Community-JS PrivateMessageSnippets component. Learn about the available props and the CSS API.
@@ -1,9 +1,9 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useContext, useEffect, useRef, useState } from 'react';
2
+ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { Button, Card, CardContent, Icon, IconButton, List, TextField, useTheme } from '@mui/material';
5
5
  import PubSub from 'pubsub-js';
6
- import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType } from '@selfcommunity/types';
6
+ import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType, SCPrivateMessageType } from '@selfcommunity/types';
7
7
  import PrivateMessageSnippetsSkeleton from './Skeleton';
8
8
  import PrivateMessageSnippetItem from '../PrivateMessageSnippetItem';
9
9
  import classNames from 'classnames';
@@ -69,25 +69,30 @@ export default function PrivateMessageSnippets(inProps) {
69
69
  props: inProps,
70
70
  name: PREFIX
71
71
  });
72
- const { className = null, userObj = null, snippetActions, clearSearch } = props, rest = __rest(props, ["className", "userObj", "snippetActions", "clearSearch"]);
72
+ const { className = null, threadObj = null, snippetActions, clearSearch } = props, rest = __rest(props, ["className", "threadObj", "snippetActions", "clearSearch"]);
73
73
  // STATE
74
74
  const theme = useTheme();
75
75
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
76
76
  const { data, updateSnippets } = useSCFetchPrivateMessageSnippets({ cacheStrategy: CacheStrategies.CACHE_FIRST });
77
77
  const [search, setSearch] = useState('');
78
- const isObj = typeof userObj === 'object';
78
+ const isObj = typeof threadObj === 'object';
79
79
  const scUserContext = useContext(SCUserContext);
80
80
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
81
+ const [type, setType] = useState(null);
81
82
  // INTL
82
83
  const intl = useIntl();
83
84
  // REFS
84
85
  const refreshSubscription = useRef(null);
85
86
  // CONST
86
87
  const filteredSnippets = data.snippets.filter((el) => {
88
+ var _a;
87
89
  if (search === '') {
88
90
  return el;
89
91
  }
90
- else if (el.receiver.id === authUserId) {
92
+ else if (el.group) {
93
+ return el.group.slug.includes(search.toLowerCase());
94
+ }
95
+ else if (((_a = el === null || el === void 0 ? void 0 : el.receiver) === null || _a === void 0 ? void 0 : _a.id) === authUserId) {
91
96
  return el.sender.username.includes(search.toLowerCase());
92
97
  }
93
98
  return el.receiver.username.includes(search.toLowerCase());
@@ -99,6 +104,18 @@ export default function PrivateMessageSnippets(inProps) {
99
104
  }
100
105
  return ((_b = item === null || item === void 0 ? void 0 : item.receiver) === null || _b === void 0 ? void 0 : _b.id) !== loggedUserId ? (_c = item === null || item === void 0 ? void 0 : item.receiver) === null || _c === void 0 ? void 0 : _c.id : (_d = item === null || item === void 0 ? void 0 : item.sender) === null || _d === void 0 ? void 0 : _d.id;
101
106
  };
107
+ const isSelected = useMemo(() => {
108
+ return (message) => {
109
+ var _a, _b;
110
+ if (threadObj && type === SCPrivateMessageType.GROUP) {
111
+ return ((_a = message === null || message === void 0 ? void 0 : message.group) === null || _a === void 0 ? void 0 : _a.id) === (isObj ? (_b = threadObj === null || threadObj === void 0 ? void 0 : threadObj.group) === null || _b === void 0 ? void 0 : _b.id : threadObj);
112
+ }
113
+ else if (threadObj && type === SCPrivateMessageType.USER) {
114
+ return messageReceiver(message, authUserId) === (isObj ? messageReceiver(threadObj, authUserId) : threadObj);
115
+ }
116
+ return null;
117
+ };
118
+ }, [threadObj, authUserId, type]);
102
119
  //HANDLERS
103
120
  const handleChange = (event) => {
104
121
  setSearch(event.target.value);
@@ -114,7 +131,9 @@ export default function PrivateMessageSnippets(inProps) {
114
131
  snippetActions && snippetActions.onDeleteConfirm(msg);
115
132
  };
116
133
  function handleOpenThread(msg) {
117
- snippetActions && snippetActions.onSnippetClick(msg);
134
+ const _type = msg.group !== null ? SCPrivateMessageType.GROUP : SCPrivateMessageType.USER;
135
+ setType(_type);
136
+ snippetActions && snippetActions.onSnippetClick(msg, _type);
118
137
  handleClear();
119
138
  updateSnippetsParams(msg.id, 'seen');
120
139
  }
@@ -219,6 +238,5 @@ export default function PrivateMessageSnippets(inProps) {
219
238
  } }),
220
239
  React.createElement(List, null, filteredSnippets.map((message) => (React.createElement(PrivateMessageSnippetItem, { message: message, key: message.id, onItemClick: () => handleOpenThread(message), secondaryAction: React.createElement(React.Fragment, null,
221
240
  message.thread_status === SCPrivateMessageStatusType.NEW && (React.createElement(Icon, { fontSize: "small", color: "secondary" }, "fiber_manual_record")),
222
- !isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected: userObj !== SCPrivateMessageStatusType.NEW &&
223
- messageReceiver(message, authUserId) === (isObj ? messageReceiver(userObj, authUserId) : userObj) })))))))));
241
+ !isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected: isSelected(message) })))))))));
224
242
  }
@@ -1,10 +1,11 @@
1
+ import { SCPrivateMessageType } from '@selfcommunity/types';
1
2
  import { CardProps } from '@mui/material';
2
3
  export interface PrivateMessageThreadProps extends CardProps {
3
4
  /**
4
5
  * Thread object or thread id
5
6
  * default null
6
7
  */
7
- userObj?: any;
8
+ threadObj?: any;
8
9
  /**
9
10
  * Overrides or extends the styles applied to the component.
10
11
  * @default null
@@ -30,6 +31,10 @@ export interface PrivateMessageThreadProps extends CardProps {
30
31
  * @default null
31
32
  */
32
33
  onSingleMessageOpen?: (open: boolean) => void;
34
+ /**
35
+ * The Thread type
36
+ */
37
+ type?: SCPrivateMessageType;
33
38
  /**
34
39
  * Any other properties
35
40
  */
@@ -3,11 +3,11 @@ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState }
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { Endpoints, http, PrivateMessageService } from '@selfcommunity/api-services';
5
5
  import { SCUserContext, UserUtils, useSCFetchUser } from '@selfcommunity/react-core';
6
- import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType } from '@selfcommunity/types';
6
+ import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType, SCPrivateMessageType } from '@selfcommunity/types';
7
7
  import PrivateMessageThreadItem, { PrivateMessageThreadItemSkeleton } from '../PrivateMessageThreadItem';
8
8
  import PubSub from 'pubsub-js';
9
9
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
10
- import { Box, Card, CardContent, IconButton, List, ListSubheader, TextField, Typography } from '@mui/material';
10
+ import { Avatar, Box, Card, CardContent, IconButton, List, ListItemAvatar, ListSubheader, TextField, Typography } from '@mui/material';
11
11
  import PrivateMessageEditor from '../PrivateMessageEditor';
12
12
  import Autocomplete from '@mui/material/Autocomplete';
13
13
  import classNames from 'classnames';
@@ -41,6 +41,8 @@ const classes = {
41
41
  newMessageContent: `${PREFIX}-new-message-content`,
42
42
  sender: `${PREFIX}-sender`,
43
43
  receiver: `${PREFIX}-receiver`,
44
+ avatar: `${PREFIX}-avatar`,
45
+ item: `${PREFIX}-item`,
44
46
  autocomplete: `${PREFIX}-autocomplete`,
45
47
  autocompleteDialog: `${PREFIX}-autocomplete-dialog`,
46
48
  editor: `${PREFIX}-editor`
@@ -93,7 +95,7 @@ export default function PrivateMessageThread(inProps) {
93
95
  props: inProps,
94
96
  name: PREFIX
95
97
  });
96
- const { userObj, openNewMessage = false, onNewMessageClose = null, onNewMessageSent = null, onSingleMessageOpen = null, className } = props, rest = __rest(props, ["userObj", "openNewMessage", "onNewMessageClose", "onNewMessageSent", "onSingleMessageOpen", "className"]);
98
+ const { threadObj, openNewMessage = false, onNewMessageClose = null, onNewMessageSent = null, onSingleMessageOpen = null, className, type } = props, rest = __rest(props, ["threadObj", "openNewMessage", "onNewMessageClose", "onNewMessageSent", "onSingleMessageOpen", "className", "type"]);
97
99
  // CONTEXT
98
100
  const scUserContext = useContext(SCUserContext);
99
101
  // STATE
@@ -104,7 +106,7 @@ export default function PrivateMessageThread(inProps) {
104
106
  const [loading, setLoading] = useState(false);
105
107
  const [isHovered, setIsHovered] = useState({});
106
108
  const [followers, setFollowers] = useState([]);
107
- const isNew = userObj && userObj === SCPrivateMessageStatusType.NEW;
109
+ const isNew = threadObj && threadObj === SCPrivateMessageStatusType.NEW;
108
110
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
109
111
  const [singleMessageUser, setSingleMessageUser] = useState(null);
110
112
  const [receiver, setReceiver] = useState(null);
@@ -113,7 +115,7 @@ export default function PrivateMessageThread(inProps) {
113
115
  const [openDeleteMessageDialog, setOpenDeleteMessageDialog] = useState(false);
114
116
  const [recipients, setRecipients] = useState([]);
115
117
  const { enqueueSnackbar, closeSnackbar } = useSnackbar();
116
- const isNumber = typeof userObj === 'number';
118
+ const isNumber = typeof threadObj === 'number';
117
119
  const messageReceiver = (item, loggedUserId) => {
118
120
  var _a, _b, _c;
119
121
  return ((_a = item === null || item === void 0 ? void 0 : item.receiver) === null || _a === void 0 ? void 0 : _a.id) !== loggedUserId ? (_b = item === null || item === void 0 ? void 0 : item.receiver) === null || _b === void 0 ? void 0 : _b.id : (_c = item === null || item === void 0 ? void 0 : item.sender) === null || _c === void 0 ? void 0 : _c.id;
@@ -126,7 +128,7 @@ export default function PrivateMessageThread(inProps) {
126
128
  // HOOKS
127
129
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
128
130
  // @ts-ignore
129
- const { scUser } = useSCFetchUser({ id: userObj, userObj });
131
+ const { scUser } = useSCFetchUser({ id: threadObj, threadObj });
130
132
  const messagesEndRef = useRef(null);
131
133
  const scrollToBottom = () => {
132
134
  var _a;
@@ -254,9 +256,9 @@ export default function PrivateMessageThread(inProps) {
254
256
  * Fetches thread
255
257
  */
256
258
  function fetchThread() {
257
- if (userObj && typeof userObj !== 'string') {
259
+ if (threadObj && typeof threadObj !== 'string' && type !== SCPrivateMessageType.GROUP) {
258
260
  setLoadingMessageObjs(true);
259
- const _userObjId = isNumber ? userObj : messageReceiver(userObj, authUserId);
261
+ const _userObjId = isNumber ? threadObj : messageReceiver(threadObj, authUserId);
260
262
  PrivateMessageService.getAThread({ user: _userObjId, limit: 10 })
261
263
  .then((res) => {
262
264
  setMessageObjs(res.results);
@@ -289,6 +291,19 @@ export default function PrivateMessageThread(inProps) {
289
291
  Logger.error(SCOPE_SC_UI, { error });
290
292
  });
291
293
  }
294
+ else if (type === SCPrivateMessageType.GROUP) {
295
+ PrivateMessageService.getAThread({ group: isNumber ? threadObj : threadObj.group.id, limit: 10 })
296
+ .then((res) => {
297
+ setMessageObjs(res.results);
298
+ setPrevious(res.next && updateAndDeleteURLParameters(res.next, 'before_message', res.results[0].id, 'offset'));
299
+ setLoadingMessageObjs(false);
300
+ })
301
+ .catch((error) => {
302
+ setLoadingMessageObjs(false);
303
+ console.log(error);
304
+ Logger.error(SCOPE_SC_UI, { error });
305
+ });
306
+ }
292
307
  }
293
308
  const isNewerThan60Seconds = (creationTime) => {
294
309
  const date = new Date(creationTime);
@@ -353,11 +368,15 @@ export default function PrivateMessageThread(inProps) {
353
368
  .request({
354
369
  url: Endpoints.SendMessage.url(),
355
370
  method: Endpoints.SendMessage.method,
356
- data: {
357
- recipients: openNewMessage || isNew || singleMessageThread ? ids : [isNumber && userObj ? userObj : messageReceiver(userObj, authUserId)],
358
- message: message,
359
- file_uuid: file && !message ? file : null
360
- }
371
+ data: Object.assign(Object.assign({}, (type === SCPrivateMessageType.GROUP
372
+ ? { group: isNumber ? threadObj : threadObj.group.id }
373
+ : {
374
+ recipients: openNewMessage || isNew || singleMessageThread
375
+ ? ids
376
+ : [isNumber && threadObj ? threadObj : messageReceiver(threadObj, authUserId)]
377
+ })), {
378
+ // recipients: openNewMessage || isNew || singleMessageThread ? ids : [isNumber && threadObj ? threadObj : messageReceiver(threadObj, authUserId)],
379
+ message: message, file_uuid: file && !message ? file : null })
361
380
  })
362
381
  .then((res) => {
363
382
  const isOne = res.data.length <= 1;
@@ -403,13 +422,13 @@ export default function PrivateMessageThread(inProps) {
403
422
  if (!authUserId) {
404
423
  return;
405
424
  }
406
- if (userObj) {
425
+ if (threadObj) {
407
426
  fetchThread();
408
427
  }
409
428
  else {
410
429
  reset();
411
430
  }
412
- }, [userObj, authUserId, scUser]);
431
+ }, [threadObj, authUserId, scUser]);
413
432
  /**
414
433
  * Notification subscriber
415
434
  */
@@ -424,7 +443,7 @@ export default function PrivateMessageThread(inProps) {
424
443
  if (index !== -1) {
425
444
  setMessageObjs((prev) => [...prev, res.notification_obj.message]);
426
445
  }
427
- if (isNumber ? userObj === res.thread_id : userObj.id === res.thread_id) {
446
+ if (isNumber ? threadObj === res.thread_id : threadObj.id === res.thread_id) {
428
447
  scrollToBottom();
429
448
  }
430
449
  };
@@ -451,11 +470,17 @@ export default function PrivateMessageThread(inProps) {
451
470
  React.createElement("ul", null,
452
471
  React.createElement(ListSubheader, null,
453
472
  React.createElement(Typography, { align: "center", className: classes.subHeader }, key)),
454
- formattedMessages[key].map((msg) => (React.createElement(PrivateMessageThreadItem, { className: authUserId === msg.sender.id ? classes.sender : classes.receiver, message: msg, key: msg.id, mouseEvents: {
455
- onMouseEnter: () => handleMouseEnter(msg.id),
456
- onMouseLeave: () => handleMouseLeave(msg.id)
457
- }, isHovering: isHovered[msg.id], showMenuIcon: authUserId === msg.sender.id, onMenuIconClick: () => handleOpenDeleteMessageDialog(msg) }))))))))),
458
- React.createElement(PrivateMessageEditor, { className: classes.editor, send: handleSend, autoHide: !(scUser === null || scUser === void 0 ? void 0 : scUser.can_send_pm_to), autoHideDeletion: (receiver === null || receiver === void 0 ? void 0 : receiver.deleted) || (scUser === null || scUser === void 0 ? void 0 : scUser.deleted), onThreadChangeId: isNumber ? userObj : userObj.receiver.id, error: error, onErrorRemove: () => setError(false) }),
473
+ formattedMessages[key].map((msg) => {
474
+ var _a;
475
+ return (React.createElement(Box, { className: classes.item, key: msg.id },
476
+ msg.group && ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) !== msg.sender.username && (React.createElement(ListItemAvatar, null,
477
+ React.createElement(Avatar, { alt: msg.sender.username, src: msg.sender.avatar, className: classes.avatar }))),
478
+ React.createElement(PrivateMessageThreadItem, { className: authUserId === msg.sender.id ? classes.sender : classes.receiver, message: msg, key: msg.id, mouseEvents: {
479
+ onMouseEnter: () => handleMouseEnter(msg.id),
480
+ onMouseLeave: () => handleMouseLeave(msg.id)
481
+ }, isHovering: isHovered[msg.id], showMenuIcon: authUserId === msg.sender.id, onMenuIconClick: () => handleOpenDeleteMessageDialog(msg) })));
482
+ }))))))),
483
+ React.createElement(PrivateMessageEditor, { className: classes.editor, send: handleSend, autoHide: type !== SCPrivateMessageType.GROUP && !(scUser === null || scUser === void 0 ? void 0 : scUser.can_send_pm_to), autoHideDeletion: type === SCPrivateMessageType.USER && ((receiver === null || receiver === void 0 ? void 0 : receiver.deleted) || (scUser === null || scUser === void 0 ? void 0 : scUser.deleted)), onThreadChangeId: isNumber ? threadObj : type === SCPrivateMessageType.USER ? threadObj.receiver.id : threadObj.group.id, error: error, onErrorRemove: () => setError(false) }),
459
484
  openDeleteMessageDialog && (React.createElement(ConfirmDialog, { open: openDeleteMessageDialog, title: React.createElement(FormattedMessage, { id: "ui.privateMessage.component.delete.message.dialog.msg", defaultMessage: "ui.privateMessage.component.delete.message.dialog.msg" }), btnConfirm: React.createElement(FormattedMessage, { id: "ui.privateMessage.component.delete.message.dialog.confirm", defaultMessage: "ui.privateMessage.component.delete.message.dialog.confirm" }), onConfirm: handleDeleteMessage, onClose: handleCloseDeleteMessageDialog }))));
460
485
  }
461
486
  /**
@@ -483,5 +508,5 @@ export default function PrivateMessageThread(inProps) {
483
508
  /**
484
509
  * Renders the component
485
510
  */
486
- return (React.createElement(Root, Object.assign({}, rest, { className: classNames(classes.root, className) }), userObj !== null && !isNew && !singleMessageThread ? renderThread() : renderNewOrNoMessageBox()));
511
+ return (React.createElement(Root, Object.assign({}, rest, { className: classNames(classes.root, className) }), threadObj !== null && !isNew && !singleMessageThread ? renderThread() : renderNewOrNoMessageBox()));
487
512
  }
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __rest } from "tslib";
2
- import React, { useState } from 'react';
2
+ import React, { useContext, useState } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { ListItem, Typography, IconButton, Box, useTheme, Button } from '@mui/material';
5
5
  import PrivateMessageThreadItemSkeleton from './Skeleton';
@@ -8,6 +8,7 @@ import { SCMessageFileType, SCPrivateMessageStatusType } from '@selfcommunity/ty
8
8
  import Icon from '@mui/material/Icon';
9
9
  import classNames from 'classnames';
10
10
  import { useThemeProps } from '@mui/system';
11
+ import { SCUserContext } from '@selfcommunity/react-core';
11
12
  import useMediaQuery from '@mui/material/useMediaQuery';
12
13
  import PrivateMessageSettingsIconButton from '../PrivateMessageSettingsIconButton';
13
14
  import { bytesToSize } from '../../utils/sizeCoverter';
@@ -19,6 +20,7 @@ import { PREFIX } from './constants';
19
20
  import { isSupportedVideoFormat } from '../../utils/thumbnailCoverter';
20
21
  const classes = {
21
22
  root: `${PREFIX}-root`,
23
+ username: `${PREFIX}-username`,
22
24
  text: `${PREFIX}-text`,
23
25
  img: `${PREFIX}-img`,
24
26
  document: `${PREFIX}-document`,
@@ -70,6 +72,7 @@ const Root = styled(ListItem, {
70
72
  * @param inProps
71
73
  */
72
74
  export default function PrivateMessageThreadItem(inProps) {
75
+ var _a;
73
76
  // PROPS
74
77
  const props = useThemeProps({
75
78
  props: inProps,
@@ -78,6 +81,8 @@ export default function PrivateMessageThreadItem(inProps) {
78
81
  const { message = null, className = null, mouseEvents = {}, isHovering = null, showMenuIcon = false, onMenuIconClick = null } = props, rest = __rest(props, ["message", "className", "mouseEvents", "isHovering", "showMenuIcon", "onMenuIconClick"]);
79
82
  // INTL
80
83
  const intl = useIntl();
84
+ // CONTEXT
85
+ const scUserContext = useContext(SCUserContext);
81
86
  // STATE
82
87
  const theme = useTheme();
83
88
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
@@ -165,6 +170,7 @@ export default function PrivateMessageThreadItem(inProps) {
165
170
  return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, getMouseEvents(mouseEvents.onMouseEnter, mouseEvents.onMouseLeave), rest, { secondaryAction: (isHovering || isMobile) &&
166
171
  showMenuIcon &&
167
172
  message.status !== SCPrivateMessageStatusType.HIDDEN && React.createElement(PrivateMessageSettingsIconButton, { onMenuItemDeleteClick: handleMenuItemClick }) }),
173
+ message.group && ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) !== message.sender.username && (React.createElement(Typography, { color: "secondary", variant: "h4", className: classes.username }, message.sender.username)),
168
174
  React.createElement(React.Fragment, null,
169
175
  hasFile && message.status !== SCPrivateMessageStatusType.HIDDEN ? (renderMessageFile(message)) : (React.createElement(Box, { className: classes.text },
170
176
  React.createElement(Typography, { component: "span", dangerouslySetInnerHTML: { __html: message.message } }))),
@@ -73,6 +73,25 @@ export default function SearchAutocomplete(inProps) {
73
73
  setOptions([]);
74
74
  onClear && onClear();
75
75
  };
76
+ const getOptionData = (option) => {
77
+ let data = {};
78
+ if (option.type === SuggestionType.USER) {
79
+ data.name = option[SuggestionType.USER]['username'];
80
+ data.image = option[SuggestionType.USER]['avatar'];
81
+ data.variant = 'circular';
82
+ }
83
+ else if (option.type === SuggestionType.CATEGORY) {
84
+ data.name = option[SuggestionType.CATEGORY]['name'];
85
+ data.image = option[SuggestionType.CATEGORY]['image_medium'];
86
+ data.variant = 'square';
87
+ }
88
+ else if (option.type === SuggestionType.GROUP) {
89
+ data.name = option[SuggestionType.GROUP]['name'];
90
+ data.image = option[SuggestionType.GROUP]['image_big'];
91
+ data.variant = 'circular';
92
+ }
93
+ return data;
94
+ };
76
95
  function fetchResults() {
77
96
  setIsLoading(true);
78
97
  SuggestionService.getSearchSuggestion(value)
@@ -96,11 +115,9 @@ export default function SearchAutocomplete(inProps) {
96
115
  return option;
97
116
  }
98
117
  return (_a = option[option.type]['username']) !== null && _a !== void 0 ? _a : option[option.type]['name'];
99
- }, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props), option.type === SuggestionType.USER ? (React.createElement(React.Fragment, null,
100
- React.createElement(Avatar, { alt: option[SuggestionType.USER]['username'], src: option[SuggestionType.USER]['avatar'] }),
101
- React.createElement(Typography, { ml: 1 }, option[SuggestionType.USER]['username']))) : (React.createElement(React.Fragment, null,
102
- React.createElement(Avatar, { alt: option[SuggestionType.CATEGORY]['name'], src: option[SuggestionType.CATEGORY]['image_medium'], variant: "square" }),
103
- React.createElement(Typography, { ml: 1 }, option[SuggestionType.CATEGORY]['name']))))), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { placeholder: `${intl.formatMessage(messages.placeholder, {
118
+ }, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props),
119
+ React.createElement(Avatar, { alt: getOptionData(option).name, src: getOptionData(option).image, variant: getOptionData(option).variant }),
120
+ React.createElement(Typography, { ml: 1 }, getOptionData(option).name))), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { placeholder: `${intl.formatMessage(messages.placeholder, {
104
121
  community: scPreferences.preferences[SCPreferences.TEXT_APPLICATION_NAME].value
105
122
  })}`, InputProps: Object.assign(Object.assign({}, params.InputProps), { autoFocus, name: 'search-autocomplete', className: classes.input, startAdornment: React.createElement(Icon, { className: classes.icon }, "search"), endAdornment: (React.createElement(Fade, { in: value.length > 0 || Boolean(onClear), appear: false },
106
123
  React.createElement(IconButton, { className: classes.clear, onClick: handleClear, size: "small" },
@@ -31,6 +31,7 @@ import { useThemeProps } from '@mui/system';
31
31
  import ContributionNotification from '../Notification/Contribution';
32
32
  import NotificationItem from '../../shared/NotificationItem';
33
33
  import { PREFIX } from './constants';
34
+ import GroupNotification from '../Notification/Group';
34
35
  const classes = {
35
36
  root: `${PREFIX}-root`,
36
37
  notificationsWrap: `${PREFIX}-notifications-wrap`,
@@ -252,6 +253,12 @@ export default function SnippetNotifications(inProps) {
252
253
  else if (type === SCNotificationTypologyType.CONTRIBUTION) {
253
254
  content = React.createElement(ContributionNotification, { notificationObject: n, key: i, template: SCNotificationObjectTemplateType.SNIPPET });
254
255
  }
256
+ else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
257
+ n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
258
+ n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
259
+ n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
260
+ return React.createElement(GroupNotification, { notificationObject: n, key: i, template: SCNotificationObjectTemplateType.SNIPPET });
261
+ }
255
262
  if (type && handleNotification) {
256
263
  /** Override content */
257
264
  content = handleNotification(type, n, content);
@@ -21,6 +21,7 @@ import Message from '../BroadcastMessages/Message';
21
21
  import { useThemeProps } from '@mui/system';
22
22
  import ContributionNotification from '../Notification/Contribution';
23
23
  import { PREFIX } from './constants';
24
+ import GroupNotification from '../Notification/Group';
24
25
  const Root = styled(Box, {
25
26
  name: PREFIX,
26
27
  slot: 'Root'
@@ -108,6 +109,12 @@ export default function UserToastNotifications(inProps) {
108
109
  else if (type === SCNotificationTypologyType.CONTRIBUTION) {
109
110
  content = React.createElement(ContributionNotification, { notificationObject: n.notification_obj, template: SCNotificationObjectTemplateType.TOAST });
110
111
  }
112
+ else if (type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
113
+ type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
114
+ type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
115
+ type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
116
+ content = React.createElement(GroupNotification, { notificationObject: n.notification_obj, template: SCNotificationObjectTemplateType.TOAST });
117
+ }
111
118
  }
112
119
  if (n.activity_type && n.activity_type === SCNotificationTypologyType.NOTIFICATION_BANNER) {
113
120
  /** Notification of type: 'notification_banner' */
@@ -34,6 +34,11 @@ export interface UserProps extends WidgetProps {
34
34
  * Badge content to show as user avatar badge if show reaction is true.
35
35
  */
36
36
  badgeContent?: any;
37
+ /**
38
+ * If true, shows a custom label next to the user username
39
+ * @default false
40
+ */
41
+ isGroupAdmin?: boolean;
37
42
  /**
38
43
  * Prop to add actions
39
44
  * @default null
@@ -43,7 +48,7 @@ export interface UserProps extends WidgetProps {
43
48
  * Props to spread to the button
44
49
  * @default {}
45
50
  */
46
- buttonProps?: ButtonBaseProps;
51
+ buttonProps?: ButtonBaseProps | null;
47
52
  /**
48
53
  * Any other properties
49
54
  */
@@ -21,7 +21,8 @@ const messages = defineMessages({
21
21
  const classes = {
22
22
  root: `${PREFIX}-root`,
23
23
  avatar: `${PREFIX}-avatar`,
24
- staffBadgeLabel: `${PREFIX}-staff-badge-label`
24
+ staffBadgeLabel: `${PREFIX}-staff-badge-label`,
25
+ groupAdminBadgeLabel: `${PREFIX}-group-admin-badge-label`
25
26
  };
26
27
  const Root = styled(BaseItemButton, {
27
28
  name: PREFIX,
@@ -64,7 +65,7 @@ export default function User(inProps) {
64
65
  props: inProps,
65
66
  name: PREFIX
66
67
  });
67
- const { userId = null, user = null, handleIgnoreAction, className = null, followConnectUserButtonProps = {}, showFollowers = false, elevation, badgeContent = null, actions = null, buttonProps = {} } = props, rest = __rest(props, ["userId", "user", "handleIgnoreAction", "className", "followConnectUserButtonProps", "showFollowers", "elevation", "badgeContent", "actions", "buttonProps"]);
68
+ const { userId = null, user = null, handleIgnoreAction, className = null, followConnectUserButtonProps = {}, showFollowers = false, elevation, badgeContent = null, actions = null, isGroupAdmin = false, buttonProps = null } = props, rest = __rest(props, ["userId", "user", "handleIgnoreAction", "className", "followConnectUserButtonProps", "showFollowers", "elevation", "badgeContent", "actions", "isGroupAdmin", "buttonProps"]);
68
69
  // STATE
69
70
  const { scUser, setSCUser } = useSCFetchUser({ id: userId, user });
70
71
  // CONTEXT
@@ -104,8 +105,8 @@ export default function User(inProps) {
104
105
  ? { onClick: () => setOpenAlert(true) }
105
106
  : { component: Link, to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scUser) }), image: badgeContent ? (React.createElement(Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: badgeContent },
106
107
  React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))) : (React.createElement(UserAvatar, { hide: !hasBadge },
107
- React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))), primary: hasBadge && preferences ? (React.createElement(React.Fragment, null,
108
+ React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))), primary: (hasBadge && preferences) || isGroupAdmin ? (React.createElement(React.Fragment, null,
108
109
  scUser.username,
109
- React.createElement(Chip, { component: "span", className: classes.staffBadgeLabel, size: "small", label: preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL] }))) : (scUser.username), secondary: showFollowers ? `${intl.formatMessage(messages.userFollowers, { total: scUser.followers_counter })}` : scUser.description, actions: actions !== null && actions !== void 0 ? actions : renderAuthenticatedActions() })),
110
+ React.createElement(Chip, { component: "span", className: isGroupAdmin ? classes.groupAdminBadgeLabel : classes.staffBadgeLabel, size: "small", label: isGroupAdmin ? (React.createElement(FormattedMessage, { defaultMessage: "ui.user.group.admin", id: "ui.user.group.admin" })) : (preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL]) }))) : (scUser.username), secondary: showFollowers ? `${intl.formatMessage(messages.userFollowers, { total: scUser.followers_counter })}` : scUser.description, actions: actions !== null && actions !== void 0 ? actions : renderAuthenticatedActions() })),
110
111
  openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
111
112
  }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * > API documentation for the Community-JS User Profile Categories Followed Widget Skeleton component. Learn about the available props and the CSS API.
3
+
4
+ #### Import
5
+
6
+ ```jsx
7
+ import {UserSubscribedGroupsWidgetSkeleton} from '@selfcommunity/react-ui';
8
+ ```
9
+
10
+ #### Component Name
11
+
12
+ The name `SCUserCategoriesFollowedWidget-skeleton-root` can be used when providing style overrides in the theme.
13
+
14
+ #### CSS
15
+
16
+ |Rule Name|Global class|Description|
17
+ |---|---|---|
18
+ |root|.SCUserSubscribedGroupsWidget-skeleton-root|Styles applied to the root element.|
19
+ *
20
+ */
21
+ export default function UserSubscribedGroupsWidgetSkeleton(props: any): JSX.Element;