@selfcommunity/react-ui 0.7.9-alpha.3 → 0.7.9-alpha.30

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 (167) hide show
  1. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  2. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  3. package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
  4. package/lib/cjs/components/Composer/Attributes/Attributes.js +9 -2
  5. package/lib/cjs/components/Composer/Composer.d.ts +2 -1
  6. package/lib/cjs/components/Composer/Composer.js +39 -12
  7. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  8. package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +4 -3
  9. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
  10. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +46 -12
  11. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  12. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
  13. package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
  14. package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  15. package/lib/cjs/components/EditGroupButton/EditGroupButton.js +61 -0
  16. package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
  17. package/lib/cjs/components/EditGroupButton/index.js +5 -0
  18. package/lib/cjs/components/FeedObject/Actions/Follow/Follow.js +18 -0
  19. package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -0
  20. package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
  21. package/lib/cjs/components/FeedObject/FeedObject.js +43 -9
  22. package/lib/cjs/components/Group/Group.d.ts +4 -3
  23. package/lib/cjs/components/Group/Group.js +5 -4
  24. package/lib/cjs/components/Group/Skeleton.js +1 -1
  25. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  26. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
  27. package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
  28. package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
  29. package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
  30. package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
  31. package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
  32. package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
  33. package/lib/cjs/components/GroupForm/index.d.ts +3 -0
  34. package/lib/cjs/components/GroupForm/index.js +5 -0
  35. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
  36. package/lib/cjs/components/GroupHeader/GroupHeader.js +21 -11
  37. package/lib/cjs/components/GroupHeader/Skeleton.d.ts +2 -4
  38. package/lib/cjs/components/GroupHeader/Skeleton.js +10 -10
  39. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
  40. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +7 -6
  41. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  42. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +3 -2
  43. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +36 -16
  44. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
  45. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
  46. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  47. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +132 -0
  48. package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
  49. package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
  50. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  51. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +24 -9
  52. package/lib/cjs/components/Groups/Groups.d.ts +16 -16
  53. package/lib/cjs/components/Groups/Groups.js +47 -96
  54. package/lib/cjs/components/Groups/Skeleton.d.ts +14 -2
  55. package/lib/cjs/components/Groups/Skeleton.js +12 -5
  56. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  57. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  58. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
  59. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
  60. package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
  61. package/lib/cjs/components/Notification/Group/Group.js +79 -0
  62. package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
  63. package/lib/cjs/components/Notification/Group/index.js +5 -0
  64. package/lib/cjs/components/Notification/Notification.js +32 -1
  65. package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  66. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  67. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +10 -7
  68. package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  69. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  70. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
  71. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  72. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
  73. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  74. package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
  75. package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
  76. package/lib/cjs/components/VoteButton/VoteButton.js +19 -0
  77. package/lib/cjs/index.d.ts +7 -4
  78. package/lib/cjs/index.js +13 -6
  79. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  80. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  81. package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
  82. package/lib/esm/components/Composer/Attributes/Attributes.js +9 -2
  83. package/lib/esm/components/Composer/Composer.d.ts +2 -1
  84. package/lib/esm/components/Composer/Composer.js +39 -12
  85. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  86. package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +4 -3
  87. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
  88. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +45 -12
  89. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  90. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
  91. package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
  92. package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  93. package/lib/esm/components/EditGroupButton/EditGroupButton.js +58 -0
  94. package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
  95. package/lib/esm/components/EditGroupButton/index.js +2 -0
  96. package/lib/esm/components/FeedObject/Actions/Follow/Follow.js +20 -2
  97. package/lib/esm/components/FeedObject/Actions/Share/Share.js +20 -2
  98. package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
  99. package/lib/esm/components/FeedObject/FeedObject.js +45 -11
  100. package/lib/esm/components/Group/Group.d.ts +4 -3
  101. package/lib/esm/components/Group/Group.js +5 -4
  102. package/lib/esm/components/Group/Skeleton.js +1 -1
  103. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  104. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
  105. package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
  106. package/lib/esm/components/GroupAutocomplete/index.js +2 -0
  107. package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
  108. package/lib/esm/components/GroupForm/GroupForm.js +236 -0
  109. package/lib/esm/components/GroupForm/constants.d.ts +1 -0
  110. package/lib/esm/components/GroupForm/constants.js +1 -0
  111. package/lib/esm/components/GroupForm/index.d.ts +3 -0
  112. package/lib/esm/components/GroupForm/index.js +2 -0
  113. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
  114. package/lib/esm/components/GroupHeader/GroupHeader.js +21 -11
  115. package/lib/esm/components/GroupHeader/Skeleton.d.ts +2 -4
  116. package/lib/esm/components/GroupHeader/Skeleton.js +10 -10
  117. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
  118. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +7 -6
  119. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  120. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +4 -3
  121. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +38 -18
  122. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
  123. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
  124. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  125. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +129 -0
  126. package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
  127. package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
  128. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  129. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +25 -10
  130. package/lib/esm/components/Groups/Groups.d.ts +16 -16
  131. package/lib/esm/components/Groups/Groups.js +52 -101
  132. package/lib/esm/components/Groups/Skeleton.d.ts +14 -2
  133. package/lib/esm/components/Groups/Skeleton.js +13 -5
  134. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  135. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  136. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
  137. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
  138. package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
  139. package/lib/esm/components/Notification/Group/Group.js +76 -0
  140. package/lib/esm/components/Notification/Group/index.d.ts +3 -0
  141. package/lib/esm/components/Notification/Group/index.js +2 -0
  142. package/lib/esm/components/Notification/Notification.js +32 -1
  143. package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  144. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  145. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +11 -8
  146. package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  147. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  148. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
  149. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  150. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
  151. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  152. package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
  153. package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
  154. package/lib/esm/components/VoteButton/VoteButton.js +20 -1
  155. package/lib/esm/index.d.ts +7 -4
  156. package/lib/esm/index.js +8 -5
  157. package/lib/umd/react-ui.js +1 -1
  158. package/package.json +6 -6
  159. package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
  160. package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
  161. package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
  162. package/lib/cjs/components/CreateGroup/index.js +0 -5
  163. package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
  164. package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
  165. package/lib/esm/components/CreateGroup/constants.js +0 -1
  166. package/lib/esm/components/CreateGroup/index.d.ts +0 -3
  167. package/lib/esm/components/CreateGroup/index.js +0 -2
@@ -1,12 +1,10 @@
1
- import { __rest } from "tslib";
2
- import React, { useEffect, useMemo, useReducer } from 'react';
1
+ import { __awaiter, __rest } from "tslib";
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
- import List from '@mui/material/List';
5
- import { Box, Button, ListItem, Typography } from '@mui/material';
4
+ import { Box, Grid, Typography } from '@mui/material';
6
5
  import { http } from '@selfcommunity/api-services';
7
- import { CacheStrategies, Logger } from '@selfcommunity/utils';
8
- import { SCCache, SCPreferences, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
9
- import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
6
+ import { Logger } from '@selfcommunity/utils';
7
+ import { SCPreferences, useIsComponentMountedRef, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
10
8
  import Skeleton from './Skeleton';
11
9
  import { FormattedMessage } from 'react-intl';
12
10
  import classNames from 'classnames';
@@ -17,6 +15,7 @@ import { PREFIX } from './constants';
17
15
  import Group from '../Group';
18
16
  const classes = {
19
17
  root: `${PREFIX}-root`,
18
+ groups: `${PREFIX}-groups`,
20
19
  item: `${PREFIX}-item`,
21
20
  noResults: `${PREFIX}-no-results`,
22
21
  showMore: `${PREFIX}-show-more`,
@@ -63,119 +62,71 @@ export default function Groups(inProps) {
63
62
  props: inProps,
64
63
  name: PREFIX
65
64
  });
66
- const { endpoint, autoHide = false, limit = 5, className, cacheStrategy = CacheStrategies.NETWORK_ONLY, onHeightChange, onStateChange, GroupProps = {} } = props, rest = __rest(props, ["endpoint", "autoHide", "limit", "className", "cacheStrategy", "onHeightChange", "onStateChange", "GroupProps"]);
65
+ const { endpoint, className, GroupComponentProps = { variant: 'outlined', ButtonBaseProps: { disableRipple: true, component: Box } }, prefetchedGroups = [], general } = props, rest = __rest(props, ["endpoint", "className", "GroupComponentProps", "prefetchedGroups", "general"]);
67
66
  // STATE
68
- const [state, dispatch] = useReducer(dataWidgetReducer, {
69
- isLoadingNext: false,
70
- next: null,
71
- cacheKey: SCCache.getWidgetStateCacheKey(SCCache.GROUPS_LIST_TOOLS_STATE_CACHE_PREFIX_KEY),
72
- cacheStrategy,
73
- visibleItems: limit
74
- }, stateWidgetInitializer);
67
+ const [groups, setGroups] = useState([]);
68
+ const [loading, setLoading] = useState(true);
75
69
  // CONTEXT
76
70
  const scUserContext = useSCUser();
77
71
  const scPreferencesContext = useSCPreferences();
78
72
  // MEMO
79
73
  const contentAvailability = useMemo(() => SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in scPreferencesContext.preferences &&
80
74
  scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value, [scPreferencesContext.preferences]);
81
- // HOOKS
82
- // const theme = useTheme<SCThemeType>();
83
- // const isMobile = useMediaQuery(theme.breakpoints.down('md'));
75
+ // CONST
76
+ const authUserId = scUserContext.user ? scUserContext.user.id : null;
77
+ // REFS
78
+ const isMountedRef = useIsComponentMountedRef();
84
79
  /**
85
- * Initialize component
86
- * Fetch data only if the component is not initialized, and it is not loading data
80
+ * Fetches groups list
81
+ */
82
+ const fetchGroups = (next = endpoint.url({})) => __awaiter(this, void 0, void 0, function* () {
83
+ const response = yield http.request({
84
+ url: next,
85
+ method: endpoint.method
86
+ });
87
+ const data = response.data;
88
+ return data.next ? data.results.concat(yield fetchGroups(data.next)) : data.results;
89
+ });
90
+ /**
91
+ * On mount, fetches groups list
87
92
  */
88
- const _initComponent = useMemo(() => () => {
89
- if (!state.initialized && !state.isLoadingNext) {
90
- dispatch({ type: actionWidgetTypes.LOADING_NEXT });
91
- http
92
- .request({
93
- url: endpoint.url({ limit }),
94
- method: endpoint.method
95
- })
96
- .then((payload) => {
97
- dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload.data), { initialized: true }) });
98
- })
99
- .catch((error) => {
100
- dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
101
- Logger.error(SCOPE_SC_UI, error);
102
- });
103
- }
104
- }, [state.isLoadingNext, state.initialized, endpoint, limit, dispatch]);
105
- // EFFECTS
106
93
  useEffect(() => {
107
- var _a;
108
- let _t;
109
- if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) && scUserContext.user !== undefined) {
110
- _t = setTimeout(_initComponent);
111
- return () => {
112
- _t && clearTimeout(_t);
113
- };
94
+ if (!contentAvailability && !authUserId) {
95
+ return;
114
96
  }
115
- }, [scUserContext.user, contentAvailability]);
116
- useEffect(() => {
117
- if (state.next && state.results.length === limit && state.initialized) {
118
- dispatch({ type: actionWidgetTypes.LOADING_NEXT });
119
- http
120
- .request({
121
- url: endpoint.url({ offset: limit, limit: 10 }),
122
- method: endpoint.method
123
- })
124
- .then((payload) => {
125
- dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: payload.data });
97
+ else if (prefetchedGroups.length) {
98
+ setGroups(prefetchedGroups);
99
+ setLoading(false);
100
+ }
101
+ else {
102
+ fetchGroups()
103
+ .then((data) => {
104
+ if (isMountedRef.current) {
105
+ setGroups(data);
106
+ setLoading(false);
107
+ }
126
108
  })
127
109
  .catch((error) => {
128
- dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
129
110
  Logger.error(SCOPE_SC_UI, error);
130
111
  });
131
112
  }
132
- }, [state.next, state.results.length, state.initialized, limit]);
133
- /**
134
- * Virtual feed update
135
- */
136
- useEffect(() => {
137
- onHeightChange && onHeightChange();
138
- }, [state.results]);
139
- useEffect(() => {
140
- if (!endpoint || (!contentAvailability && !scUserContext.user)) {
141
- return;
113
+ }, [contentAvailability, authUserId, prefetchedGroups.length]);
114
+ const handleSubscribe = (group) => {
115
+ if (!general) {
116
+ const newGroups = [...groups];
117
+ const _updated = newGroups.filter((g) => g.id !== group.id);
118
+ setGroups(_updated);
142
119
  }
143
- else if (cacheStrategy === CacheStrategies.NETWORK_ONLY) {
144
- onStateChange && onStateChange({ cacheStrategy: CacheStrategies.CACHE_FIRST });
145
- }
146
- }, [scUserContext.user, endpoint, contentAvailability]);
147
- useEffect(() => {
148
- if (!endpoint || !scUserContext.user || !state.initialized) {
149
- return;
150
- }
151
- }, []);
152
- // HANDLERS
153
- // const handleNext = useMemo(
154
- // () => (): void => {
155
- // dispatch({type: actionWidgetTypes.LOADING_NEXT});
156
- // http
157
- // .request({
158
- // url: state.next,
159
- // method: endpoint
160
- // })
161
- // .then((res: AxiosResponse<any>) => {
162
- // dispatch({type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: res.data});
163
- // });
164
- // },
165
- // [dispatch, state.next, state.isLoadingNext, state.initialized]
166
- // );
120
+ };
167
121
  // RENDER
168
- if ((autoHide && !state.count && state.initialized) || (!contentAvailability && !scUserContext.user) || !endpoint) {
122
+ if (!contentAvailability && !scUserContext.user) {
169
123
  return React.createElement(HiddenPlaceholder, null);
170
124
  }
171
- if (!state.initialized) {
172
- return React.createElement(Skeleton, null);
173
- }
174
- const content = (React.createElement(React.Fragment, null, !state.count ? (React.createElement(Typography, { className: classes.noResults, variant: "body2" },
175
- React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.subtitle.noResults", defaultMessage: "" }))) : (React.createElement(React.Fragment, null,
176
- React.createElement(List, null, state.results.slice(0, state.visibleItems).map((group) => (React.createElement(ListItem, { key: group.id, className: classes.item },
177
- React.createElement(Group, Object.assign({ elevation: 1, actions: React.createElement(React.Fragment, null), group: group, groupId: group.id, buttonProps: { onClick: () => console.log(group) } }, GroupProps)))))),
178
- state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: () => console.log('load more') },
179
- React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.button.showMore", defaultMessage: "ui.groupRequestsWidget.button.showMore" })))))));
125
+ const content = (React.createElement(React.Fragment, null, loading ? (React.createElement(Skeleton, null)) : (React.createElement(Grid, { container: true, spacing: { xs: 3 }, className: classes.groups }, !groups.length ? (React.createElement(Box, { className: classes.noResults },
126
+ React.createElement(Typography, { variant: "h4" },
127
+ React.createElement(FormattedMessage, { id: "ui.groups.noGroups.title", defaultMessage: "ui.groups.noGroups.title" })),
128
+ React.createElement(Typography, { variant: "body1" },
129
+ React.createElement(FormattedMessage, { id: "ui.groups.noGroups.subtitle", defaultMessage: "ui.groups.noGroups.subtitle" })))) : (React.createElement(React.Fragment, null, groups.map((group) => (React.createElement(Grid, { item: true, xs: 12, sm: 8, md: 6, key: group.id, className: classes.item },
130
+ React.createElement(Group, Object.assign({ group: group, groupId: group.id, groupSubscribeButtonProps: { onSubscribe: handleSubscribe } }, GroupComponentProps)))))))))));
180
131
  return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest), content));
181
132
  }
@@ -1,4 +1,15 @@
1
- import { WidgetProps } from '../Widget';
1
+ export interface GroupsSkeletonProps {
2
+ /**
3
+ * Overrides or extends the styles applied to the component.
4
+ * @default null
5
+ */
6
+ className?: string;
7
+ /**
8
+ * Overrides or extends the styles applied to the component.
9
+ * @default null
10
+ */
11
+ GroupSkeletonProps?: any;
12
+ }
2
13
  /**
3
14
  * > API documentation for the Community-JS Groups Skeleton component. Learn about the available props and the CSS API.
4
15
 
@@ -17,6 +28,7 @@ import { WidgetProps } from '../Widget';
17
28
  |Rule Name|Global class|Description|
18
29
  |---|---|---|
19
30
  |root|.SCGroups-skeleton-root|Styles applied to the root element.|
31
+ |groups|.SCGroups-skeleton-groups|Styles applied to the group elements.|
20
32
  *
21
33
  */
22
- export default function GroupsSkeleton(props: WidgetProps): JSX.Element;
34
+ export default function GroupsSkeleton(inProps: GroupsSkeletonProps): JSX.Element;
@@ -1,11 +1,15 @@
1
+ import { __rest } from "tslib";
1
2
  import React from 'react';
2
- import { CategoryTrendingPeopleWidgetSkeleton } from '../CategoryTrendingUsersWidget';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { PREFIX } from './constants';
5
+ import { Box, Grid } from '@mui/material';
6
+ import classNames from 'classnames';
7
+ import { GroupSkeleton } from '../Group';
5
8
  const classes = {
6
- root: `${PREFIX}-skeleton-root`
9
+ root: `${PREFIX}-skeleton-root`,
10
+ groups: `${PREFIX}-groups`
7
11
  };
8
- const Root = styled(CategoryTrendingPeopleWidgetSkeleton, {
12
+ const Root = styled(Box, {
9
13
  name: PREFIX,
10
14
  slot: 'SkeletonRoot'
11
15
  })(() => ({}));
@@ -27,8 +31,12 @@ const Root = styled(CategoryTrendingPeopleWidgetSkeleton, {
27
31
  |Rule Name|Global class|Description|
28
32
  |---|---|---|
29
33
  |root|.SCGroups-skeleton-root|Styles applied to the root element.|
34
+ |groups|.SCGroups-skeleton-groups|Styles applied to the group elements.|
30
35
  *
31
36
  */
32
- export default function GroupsSkeleton(props) {
33
- return React.createElement(Root, Object.assign({ className: classes.root }, props));
37
+ export default function GroupsSkeleton(inProps) {
38
+ const { className, GroupSkeletonProps = {} } = inProps, rest = __rest(inProps, ["className", "GroupSkeletonProps"]);
39
+ return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest),
40
+ React.createElement(Grid, { container: true, spacing: { xs: 3 }, className: classes.groups }, [...Array(15)].map((category, index) => (React.createElement(Grid, { item: true, xs: 12, sm: 8, md: 6, key: index },
41
+ React.createElement(GroupSkeleton, Object.assign({ elevation: 0, variant: 'outlined' }, GroupSkeletonProps))))))));
34
42
  }
@@ -1,4 +1,4 @@
1
- import { SCCategoryType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
1
+ import { SCCategoryType, SCGroupType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
2
2
  import { SCMediaObjectType } from '../../types/media';
3
3
  import { WidgetProps } from '../Widget';
4
4
  export interface InlineComposerWidgetProps extends Omit<WidgetProps, 'defaultValue'> {
@@ -15,6 +15,7 @@ export interface InlineComposerWidgetProps extends Omit<WidgetProps, 'defaultVal
15
15
  title?: string;
16
16
  text?: string;
17
17
  categories?: SCCategoryType[];
18
+ group?: SCGroupType;
18
19
  audience?: string;
19
20
  addressing?: SCTagType[];
20
21
  medias?: SCMediaType[];
@@ -60,7 +60,7 @@ export default function NavigationMenuIconButton(inProps) {
60
60
  props: inProps,
61
61
  name: PREFIX
62
62
  });
63
- const { className = null, DrawerProps = { anchor: 'left' }, drawerContent = React.createElement(DefaultDrawerContent, null), drawerHeaderContent = React.createElement(DefaultHeaderContent, null), ScrollContainerProps = {} } = props, rest = __rest(props, ["className", "DrawerProps", "drawerContent", "drawerHeaderContent", "ScrollContainerProps"]);
63
+ const { className = null, DrawerProps = { anchor: 'left' }, drawerHeaderContent = React.createElement(DefaultHeaderContent, null), drawerContent = React.createElement(DefaultDrawerContent, null), ScrollContainerProps = {} } = props, rest = __rest(props, ["className", "DrawerProps", "drawerHeaderContent", "drawerContent", "ScrollContainerProps"]);
64
64
  // STATE
65
65
  const [anchorEl, setAnchorEl] = useState(null);
66
66
  // CONTEXT
@@ -8,6 +8,10 @@ export interface NavigationToolbarMobileProps extends ToolbarProps {
8
8
  * Disable search action if possible
9
9
  */
10
10
  disableSearch?: boolean;
11
+ /**
12
+ * Preserve the same as the desktop version
13
+ */
14
+ preserveDesktopLogo?: boolean;
11
15
  /**
12
16
  * Props spread to SearchAutocomplete component
13
17
  */
@@ -62,7 +62,7 @@ export default function NavigationToolbarMobile(inProps) {
62
62
  props: inProps,
63
63
  name: PREFIX
64
64
  });
65
- const { className = '', disableSearch = false, SearchAutocompleteProps = {}, children = null, startActions = null, endActions = null, NavigationMenuIconButtonComponent = NavigationMenuIconButton, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton } = props, rest = __rest(props, ["className", "disableSearch", "SearchAutocompleteProps", "children", "startActions", "endActions", "NavigationMenuIconButtonComponent", "NavigationSettingsIconButtonComponent"]);
65
+ const { className = '', disableSearch = false, preserveDesktopLogo = false, SearchAutocompleteProps = {}, children = null, startActions = null, endActions = null, NavigationMenuIconButtonComponent = NavigationMenuIconButton, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton } = props, rest = __rest(props, ["className", "disableSearch", "preserveDesktopLogo", "SearchAutocompleteProps", "children", "startActions", "endActions", "NavigationMenuIconButtonComponent", "NavigationSettingsIconButtonComponent"]);
66
66
  // CONTEXT
67
67
  const scUserContext = useSCUser();
68
68
  const scRoutingContext = useSCRouting();
@@ -83,8 +83,7 @@ export default function NavigationToolbarMobile(inProps) {
83
83
  }
84
84
  const _children = children || (React.createElement(React.Fragment, null,
85
85
  React.createElement(NavigationMenuIconButtonComponent, null),
86
- React.createElement(Link, { to: scRoutingContext.url(SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo },
87
- React.createElement("img", { src: preferences[SCPreferences.LOGO_NAVBAR_LOGO_MOBILE].value, alt: "logo" }))));
86
+ React.createElement(Link, { to: scRoutingContext.url(SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo }, !preserveDesktopLogo ? (React.createElement("img", { src: preferences[SCPreferences.LOGO_NAVBAR_LOGO_MOBILE].value, alt: "logo" })) : (React.createElement("img", { src: preferences[SCPreferences.LOGO_NAVBAR_LOGO].value, alt: "logo" })))));
88
87
  return (React.createElement(Root, Object.assign({ className: classNames(className, classes.root) }, rest),
89
88
  _children,
90
89
  startActions,
@@ -0,0 +1,15 @@
1
+ import { SCNotificationGroupActivityType } from '@selfcommunity/types';
2
+ import { NotificationItemProps } from '../../../shared/NotificationItem';
3
+ export interface NotificationGroupProps extends Pick<NotificationItemProps, Exclude<keyof NotificationItemProps, 'image' | 'disableTypography' | 'primary' | 'primaryTypographyProps' | 'secondary' | 'secondaryTypographyProps' | 'actions' | 'footer' | 'isNew'>> {
4
+ /**
5
+ * Notification obj
6
+ * @default null
7
+ */
8
+ notificationObject: SCNotificationGroupActivityType;
9
+ }
10
+ /**
11
+ * This component render the content of the notification of type group
12
+ * @constructor
13
+ * @param props
14
+ */
15
+ export default function GroupNotification(props: NotificationGroupProps): JSX.Element;
@@ -0,0 +1,76 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useContext, useEffect, useState } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { Avatar, Box, Stack, Typography } from '@mui/material';
5
+ import { Link, SCRoutes, SCUserContext, useSCRouting } from '@selfcommunity/react-core';
6
+ import { SCGroupSubscriptionStatusType, SCNotificationTypologyType } from '@selfcommunity/types';
7
+ import { FormattedMessage } from 'react-intl';
8
+ import DateTimeAgo from '../../../shared/DateTimeAgo';
9
+ import classNames from 'classnames';
10
+ import { SCNotificationObjectTemplateType } from '../../../types';
11
+ import NotificationItem from '../../../shared/NotificationItem';
12
+ import { LoadingButton } from '@mui/lab';
13
+ import UserDeletedSnackBar from '../../../shared/UserDeletedSnackBar';
14
+ import UserAvatar from '../../../shared/UserAvatar';
15
+ import { PREFIX } from '../constants';
16
+ const classes = {
17
+ root: `${PREFIX}-group-root`,
18
+ avatar: `${PREFIX}-avatar`,
19
+ actions: `${PREFIX}-actions`,
20
+ replyButton: `${PREFIX}-reply-button`,
21
+ activeAt: `${PREFIX}-active-at`,
22
+ username: `${PREFIX}-username`
23
+ };
24
+ const Root = styled(NotificationItem, {
25
+ name: PREFIX,
26
+ slot: 'GroupRoot'
27
+ })(() => ({}));
28
+ /**
29
+ * This component render the content of the notification of type group
30
+ * @constructor
31
+ * @param props
32
+ */
33
+ export default function GroupNotification(props) {
34
+ // PROPS
35
+ const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = SCNotificationObjectTemplateType.DETAIL } = props, rest = __rest(props, ["notificationObject", "id", "className", "template"]);
36
+ // CONTEXT
37
+ const scRoutingContext = useSCRouting();
38
+ const scUserContext = useContext(SCUserContext);
39
+ const manager = scUserContext.managers.groups;
40
+ // STATE
41
+ const [status, setStatus] = useState(null);
42
+ const [openAlert, setOpenAlert] = useState(false);
43
+ // CONST
44
+ const isSnippetTemplate = template === SCNotificationObjectTemplateType.SNIPPET;
45
+ const isToastTemplate = template === SCNotificationObjectTemplateType.TOAST;
46
+ useEffect(() => {
47
+ setStatus(manager.subscriptionStatus(notificationObject.group));
48
+ }, [manager.subscriptionStatus, notificationObject.group]);
49
+ // RENDER
50
+ if (isSnippetTemplate || isToastTemplate) {
51
+ return (React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: React.createElement(Link, Object.assign({}, (!notificationObject.user.deleted && {
52
+ to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
53
+ }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }),
54
+ React.createElement(UserAvatar, { hide: !notificationObject.user.community_badge, smaller: true },
55
+ React.createElement(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }))), primary: React.createElement(Box, null,
56
+ notificationObject.type !== SCNotificationTypologyType.USER_ADDED_TO_GROUP && (React.createElement(React.Fragment, null,
57
+ React.createElement(Link, Object.assign({}, (!notificationObject.user.deleted && {
58
+ to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
59
+ }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), notificationObject.user.username),
60
+ ' ')),
61
+ React.createElement(FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
62
+ group: notificationObject.group.name,
63
+ link: (...chunks) => React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) }, chunks)
64
+ } })), footer: isToastTemplate && (React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
65
+ React.createElement(DateTimeAgo, { date: notificationObject.active_at }),
66
+ status && status !== SCGroupSubscriptionStatusType.SUBSCRIBED && (React.createElement(Typography, { color: "primary" },
67
+ React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
68
+ React.createElement(FormattedMessage, { id: "ui.groupSubscribeButton.accept", defaultMessage: "ui.groupSubscribeButton.accept" })))))) }, rest)));
69
+ }
70
+ return (React.createElement(React.Fragment, null,
71
+ React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, actions: React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
72
+ React.createElement(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }),
73
+ status && status !== SCGroupSubscriptionStatusType.SUBSCRIBED && (React.createElement(LoadingButton, { color: 'primary', variant: "outlined", size: "small", classes: { root: classes.replyButton }, component: Link, loading: scUserContext.user ? status === null || manager.isLoading(notificationObject.group) : null, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
74
+ React.createElement(FormattedMessage, { id: "ui.groupSubscribeButton.accept", defaultMessage: "ui.groupSubscribeButton.accept" })))) }, rest)),
75
+ openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
76
+ }
@@ -0,0 +1,3 @@
1
+ import GroupNotification, { NotificationGroupProps } from './Group';
2
+ export default GroupNotification;
3
+ export { NotificationGroupProps };
@@ -0,0 +1,2 @@
1
+ import GroupNotification from './Group';
2
+ export default GroupNotification;
@@ -33,6 +33,7 @@ import { SCNotificationTypologyType } from '@selfcommunity/types';
33
33
  import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
34
34
  import UserAvatar from '../../shared/UserAvatar';
35
35
  import { PREFIX } from './constants';
36
+ import GroupNotification from './Group';
36
37
  const messages = defineMessages({
37
38
  receivePrivateMessage: {
38
39
  id: 'ui.notification.receivePrivateMessage',
@@ -149,7 +150,7 @@ export default function UserNotification(inProps) {
149
150
  }
150
151
  /**
151
152
  * Handles vote
152
- * @param comment
153
+ * @param index
153
154
  */
154
155
  const handleVote = (index) => {
155
156
  return (contribution) => {
@@ -194,6 +195,30 @@ export default function UserNotification(inProps) {
194
195
  b: (...chunks) => React.createElement("strong", null, chunks)
195
196
  })) }));
196
197
  }
198
+ /**
199
+ * Group notifications header
200
+ */
201
+ if (notificationObject.aggregated &&
202
+ (notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
203
+ notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
204
+ notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
205
+ notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP)) {
206
+ let groupNotification = notificationObject.aggregated[0];
207
+ return (React.createElement(CardHeader, { className: classes.header, avatar: React.createElement(Link, Object.assign({}, (!groupNotification.user.deleted && {
208
+ to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
209
+ }), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null }),
210
+ React.createElement(UserAvatar, { hide: !groupNotification.user.community_badge, smaller: true },
211
+ React.createElement(Avatar, { className: classes.avatar, alt: groupNotification.user.username, variant: "circular", src: groupNotification.user.avatar }))), titleTypographyProps: { className: classes.title, variant: 'subtitle1' }, title: React.createElement(React.Fragment, null,
212
+ notificationObject.aggregated[0].type !== SCNotificationTypologyType.USER_ADDED_TO_GROUP && (React.createElement(React.Fragment, null,
213
+ React.createElement(Link, Object.assign({}, (!groupNotification.user.deleted && {
214
+ to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
215
+ }), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), groupNotification.user.username),
216
+ ' ')),
217
+ React.createElement(FormattedMessage, { id: `ui.notification.${notificationObject.aggregated[0].type}`, defaultMessage: `ui.notification.${notificationObject.aggregated[0].type}`, values: {
218
+ group: groupNotification.group.name,
219
+ link: (...chunks) => React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, groupNotification.group) }, chunks)
220
+ } })) }));
221
+ }
197
222
  /**
198
223
  * Comment, NestedComment, Follow Contribution header
199
224
  */
@@ -276,6 +301,12 @@ export default function UserNotification(inProps) {
276
301
  else if (n.type === SCNotificationTypologyType.CONTRIBUTION) {
277
302
  return React.createElement(ContributionNotification, { notificationObject: n, key: i, onVote: handleVote(i) });
278
303
  }
304
+ else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
305
+ n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
306
+ n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
307
+ n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
308
+ return React.createElement(GroupNotification, { notificationObject: n, key: i });
309
+ }
279
310
  return null;
280
311
  }
281
312
  /**
@@ -39,6 +39,7 @@ const Root = styled(NotificationItem, {
39
39
  * @param props
40
40
  */
41
41
  export default function PrivateMessageNotification(props) {
42
+ var _a, _b, _c, _d, _e;
42
43
  // PROPS
43
44
  const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = SCNotificationObjectTemplateType.DETAIL } = props, rest = __rest(props, ["notificationObject", "id", "className", "template"]);
44
45
  // CONTEXT
@@ -89,7 +90,9 @@ export default function PrivateMessageNotification(props) {
89
90
  React.createElement(FormattedMessage, { id: 'ui.userToastNotifications.privateMessage.sentMessage', defaultMessage: 'ui.userToastNotifications.privateMessage.sentMessage' }),
90
91
  ":",
91
92
  React.createElement(Box, { className: classes.messageWrap },
92
- React.createElement(Link, { to: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.message },
93
+ React.createElement(Link, { to: ((_a = notificationObject.message) === null || _a === void 0 ? void 0 : _a.group)
94
+ ? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
95
+ : scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.message },
93
96
  React.createElement(Typography, { variant: "body2", dangerouslySetInnerHTML: { __html: notificationObject.message.message } }))))),
94
97
  isSnippetTemplate && (React.createElement(Box, null,
95
98
  React.createElement(Typography, { component: "div", color: "inherit" },
@@ -97,13 +100,17 @@ export default function PrivateMessageNotification(props) {
97
100
  to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.message.sender)
98
101
  }), { onClick: notificationObject.message.sender.deleted ? () => setOpenAlert(true) : null, className: classes.username }), notificationObject.message.sender.username),
99
102
  ' ',
100
- React.createElement(Link, { to: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.messageLabel }, intl.formatMessage(messages.receivePrivateMessage, {
103
+ React.createElement(Link, { to: ((_b = notificationObject.message) === null || _b === void 0 ? void 0 : _b.group)
104
+ ? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
105
+ : scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.messageLabel }, intl.formatMessage(messages.receivePrivateMessage, {
101
106
  total: 1,
102
107
  b: (...chunks) => React.createElement("strong", null, chunks)
103
108
  })))))), footer: isToastTemplate && (React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
104
109
  React.createElement(DateTimeAgo, { date: notificationObject.active_at }),
105
110
  React.createElement(Typography, { color: "primary" },
106
- React.createElement(Link, { to: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender) }, scUserContext.user && follower ? (React.createElement(FormattedMessage, { id: "ui.userToastNotifications.replyMessage", defaultMessage: 'ui.userToastNotifications.replyMessage' })) : (React.createElement(FormattedMessage, { id: "ui.userToastNotifications.viewMessage", defaultMessage: 'ui.userToastNotifications.viewMessage' })))))) }, rest)));
111
+ React.createElement(Link, { to: ((_c = notificationObject.message) === null || _c === void 0 ? void 0 : _c.group)
112
+ ? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
113
+ : scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender) }, scUserContext.user && follower ? (React.createElement(FormattedMessage, { id: "ui.userToastNotifications.replyMessage", defaultMessage: 'ui.userToastNotifications.replyMessage' })) : (React.createElement(FormattedMessage, { id: "ui.userToastNotifications.viewMessage", defaultMessage: 'ui.userToastNotifications.viewMessage' })))))) }, rest)));
107
114
  }
108
115
  return (React.createElement(React.Fragment, null,
109
116
  React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, actions: React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
@@ -112,8 +119,12 @@ export default function PrivateMessageNotification(props) {
112
119
  ? null
113
120
  : scUserContext.user
114
121
  ? follower === null || manager.isLoading(notificationObject.message.sender)
115
- : null, to: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender) }, scUserContext.user && follower ? (React.createElement(FormattedMessage, { id: "ui.notification.privateMessage.btnReplyLabel", defaultMessage: "ui.notification.privateMessage.btnReplyLabel" })) : (React.createElement(FormattedMessage, { id: "ui.notification.privateMessage.btnViewLabel", defaultMessage: "ui.notification.privateMessage.btnViewLabel" })))), primary: React.createElement(Box, { className: classes.messageWrap },
116
- React.createElement(Link, { to: scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.message },
122
+ : null, to: ((_d = notificationObject.message) === null || _d === void 0 ? void 0 : _d.group)
123
+ ? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
124
+ : scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender) }, scUserContext.user && follower ? (React.createElement(FormattedMessage, { id: "ui.notification.privateMessage.btnReplyLabel", defaultMessage: "ui.notification.privateMessage.btnReplyLabel" })) : (React.createElement(FormattedMessage, { id: "ui.notification.privateMessage.btnViewLabel", defaultMessage: "ui.notification.privateMessage.btnViewLabel" })))), primary: React.createElement(Box, { className: classes.messageWrap },
125
+ React.createElement(Link, { to: ((_e = notificationObject.message) === null || _e === void 0 ? void 0 : _e.group)
126
+ ? scRoutingContext.url(SCRoutes.GROUP_MESSAGES_ROUTE_NAME, notificationObject.message.group)
127
+ : scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, notificationObject.message.sender), className: classes.message },
117
128
  React.createElement(Typography, { variant: "body2", dangerouslySetInnerHTML: { __html: notificationObject.message.message } }))) }, rest)),
118
129
  openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
119
130
  }
@@ -8,7 +8,7 @@ export interface PrivateMessageComponentProps {
8
8
  * Handler on message click
9
9
  * @default null
10
10
  */
11
- onItemClick?: (id: any) => void;
11
+ onItemClick?: (id: any, type: any) => void;
12
12
  /**
13
13
  * Handler on single message open
14
14
  * @default null
@@ -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,7 @@ export default function PrivateMessageComponent(inProps) {
105
108
  const handleOpenNewMessage = () => {
106
109
  setOpenNewMessage(!openNewMessage);
107
110
  setObj(SCPrivateMessageStatusType.NEW);
108
- onItemClick && onItemClick(SCPrivateMessageStatusType.NEW);
111
+ onItemClick && onItemClick(SCPrivateMessageStatusType.NEW, SCPrivateMessageType.NEW);
109
112
  };
110
113
  /**
111
114
  * Handles new messages open from user profile page or notifications section
@@ -127,7 +130,7 @@ export default function PrivateMessageComponent(inProps) {
127
130
  * Handles state update when a new message is sent
128
131
  */
129
132
  const handleOnNewMessageSent = (msg, isOne) => {
130
- onItemClick && onItemClick(isOne ? messageReceiver(msg, authUserId) : '');
133
+ onItemClick && onItemClick(isOne ? messageReceiver(msg, authUserId) : '', msg.group ? SCPrivateMessageType.GROUP : SCPrivateMessageType.USER);
131
134
  setObj(isOne ? messageReceiver(msg, authUserId) : null);
132
135
  setOpenNewMessage(false);
133
136
  };
@@ -147,14 +150,14 @@ export default function PrivateMessageComponent(inProps) {
147
150
  onSnippetClick: handleThreadOpening,
148
151
  onNewMessageClick: handleOpenNewMessage,
149
152
  onDeleteConfirm: handleDeleteThread
150
- }, userObj: obj, clearSearch: clear, elevation: 0 })));
153
+ }, threadObj: obj, clearSearch: clear, elevation: 0 })));
151
154
  }
152
155
  /**
153
156
  * Renders thread section
154
157
  */
155
158
  function renderThread() {
156
159
  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 })));
160
+ React.createElement(PrivateMessageThread, { threadObj: obj, type: type, openNewMessage: openNewMessage, onNewMessageClose: handleMessageBack, onNewMessageSent: handleOnNewMessageSent, onSingleMessageOpen: handleSingleMessage, elevation: 0 })));
158
161
  }
159
162
  /**
160
163
  * Renders the component (if not hidden by autoHide prop)