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

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 (169) 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/CommentObject/CommentObject.js +18 -0
  4. package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
  5. package/lib/cjs/components/Composer/Attributes/Attributes.js +9 -2
  6. package/lib/cjs/components/Composer/Composer.d.ts +2 -1
  7. package/lib/cjs/components/Composer/Composer.js +39 -12
  8. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  9. package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +4 -3
  10. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
  11. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +46 -12
  12. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  13. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
  14. package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
  15. package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  16. package/lib/cjs/components/EditGroupButton/EditGroupButton.js +61 -0
  17. package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
  18. package/lib/cjs/components/EditGroupButton/index.js +5 -0
  19. package/lib/cjs/components/FeedObject/Actions/Follow/Follow.js +18 -0
  20. package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -0
  21. package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
  22. package/lib/cjs/components/FeedObject/FeedObject.js +43 -9
  23. package/lib/cjs/components/Group/Group.d.ts +4 -3
  24. package/lib/cjs/components/Group/Group.js +5 -4
  25. package/lib/cjs/components/Group/Skeleton.js +1 -1
  26. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  27. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
  28. package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
  29. package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
  30. package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
  31. package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
  32. package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
  33. package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
  34. package/lib/cjs/components/GroupForm/index.d.ts +3 -0
  35. package/lib/cjs/components/GroupForm/index.js +5 -0
  36. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
  37. package/lib/cjs/components/GroupHeader/GroupHeader.js +21 -11
  38. package/lib/cjs/components/GroupHeader/Skeleton.d.ts +2 -4
  39. package/lib/cjs/components/GroupHeader/Skeleton.js +10 -10
  40. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
  41. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +7 -6
  42. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  43. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +3 -2
  44. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +36 -16
  45. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
  46. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
  47. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  48. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +132 -0
  49. package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
  50. package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
  51. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  52. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +24 -9
  53. package/lib/cjs/components/Groups/Groups.d.ts +16 -16
  54. package/lib/cjs/components/Groups/Groups.js +47 -96
  55. package/lib/cjs/components/Groups/Skeleton.d.ts +14 -2
  56. package/lib/cjs/components/Groups/Skeleton.js +12 -5
  57. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  58. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  59. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
  60. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
  61. package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
  62. package/lib/cjs/components/Notification/Group/Group.js +79 -0
  63. package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
  64. package/lib/cjs/components/Notification/Group/index.js +5 -0
  65. package/lib/cjs/components/Notification/Notification.js +32 -1
  66. package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  67. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  68. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +10 -7
  69. package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  70. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  71. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
  72. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  73. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
  74. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  75. package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
  76. package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
  77. package/lib/cjs/components/VoteButton/VoteButton.js +19 -0
  78. package/lib/cjs/index.d.ts +7 -4
  79. package/lib/cjs/index.js +13 -6
  80. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  81. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  82. package/lib/esm/components/CommentObject/CommentObject.js +20 -2
  83. package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
  84. package/lib/esm/components/Composer/Attributes/Attributes.js +9 -2
  85. package/lib/esm/components/Composer/Composer.d.ts +2 -1
  86. package/lib/esm/components/Composer/Composer.js +39 -12
  87. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  88. package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +4 -3
  89. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
  90. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +45 -12
  91. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  92. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
  93. package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
  94. package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  95. package/lib/esm/components/EditGroupButton/EditGroupButton.js +58 -0
  96. package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
  97. package/lib/esm/components/EditGroupButton/index.js +2 -0
  98. package/lib/esm/components/FeedObject/Actions/Follow/Follow.js +20 -2
  99. package/lib/esm/components/FeedObject/Actions/Share/Share.js +20 -2
  100. package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
  101. package/lib/esm/components/FeedObject/FeedObject.js +45 -11
  102. package/lib/esm/components/Group/Group.d.ts +4 -3
  103. package/lib/esm/components/Group/Group.js +5 -4
  104. package/lib/esm/components/Group/Skeleton.js +1 -1
  105. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  106. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
  107. package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
  108. package/lib/esm/components/GroupAutocomplete/index.js +2 -0
  109. package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
  110. package/lib/esm/components/GroupForm/GroupForm.js +236 -0
  111. package/lib/esm/components/GroupForm/constants.d.ts +1 -0
  112. package/lib/esm/components/GroupForm/constants.js +1 -0
  113. package/lib/esm/components/GroupForm/index.d.ts +3 -0
  114. package/lib/esm/components/GroupForm/index.js +2 -0
  115. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
  116. package/lib/esm/components/GroupHeader/GroupHeader.js +21 -11
  117. package/lib/esm/components/GroupHeader/Skeleton.d.ts +2 -4
  118. package/lib/esm/components/GroupHeader/Skeleton.js +10 -10
  119. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
  120. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +7 -6
  121. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  122. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +4 -3
  123. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +38 -18
  124. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
  125. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
  126. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  127. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +129 -0
  128. package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
  129. package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
  130. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  131. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +25 -10
  132. package/lib/esm/components/Groups/Groups.d.ts +16 -16
  133. package/lib/esm/components/Groups/Groups.js +52 -101
  134. package/lib/esm/components/Groups/Skeleton.d.ts +14 -2
  135. package/lib/esm/components/Groups/Skeleton.js +13 -5
  136. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  137. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  138. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
  139. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
  140. package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
  141. package/lib/esm/components/Notification/Group/Group.js +76 -0
  142. package/lib/esm/components/Notification/Group/index.d.ts +3 -0
  143. package/lib/esm/components/Notification/Group/index.js +2 -0
  144. package/lib/esm/components/Notification/Notification.js +32 -1
  145. package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  146. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  147. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +11 -8
  148. package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  149. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  150. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
  151. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  152. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
  153. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  154. package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
  155. package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
  156. package/lib/esm/components/VoteButton/VoteButton.js +20 -1
  157. package/lib/esm/index.d.ts +7 -4
  158. package/lib/esm/index.js +8 -5
  159. package/lib/umd/react-ui.js +1 -1
  160. package/package.json +6 -6
  161. package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
  162. package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
  163. package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
  164. package/lib/cjs/components/CreateGroup/index.js +0 -5
  165. package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
  166. package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
  167. package/lib/esm/components/CreateGroup/constants.js +0 -1
  168. package/lib/esm/components/CreateGroup/index.d.ts +0 -3
  169. package/lib/esm/components/CreateGroup/index.js +0 -2
@@ -1,5 +1,5 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useEffect, useState } from 'react';
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { CacheStrategies, Logger } from '@selfcommunity/utils';
5
5
  import { useSCContext, useSCFetchGroup, useSCUser } from '@selfcommunity/react-core';
@@ -41,12 +41,13 @@ const Root = styled(LoadingButton, {
41
41
  * @param inProps
42
42
  */
43
43
  export default function GroupSubscribeButton(inProps) {
44
+ var _a;
44
45
  // PROPS
45
46
  const props = useThemeProps({
46
47
  props: inProps,
47
48
  name: PREFIX
48
49
  });
49
- const { className, groupId, group, onJoin } = props, rest = __rest(props, ["className", "groupId", "group", "onJoin"]);
50
+ const { className, groupId, group, user, onSubscribe } = props, rest = __rest(props, ["className", "groupId", "group", "user", "onSubscribe"]);
50
51
  // STATE
51
52
  const [status, setStatus] = useState(null);
52
53
  // CONTEXT
@@ -60,6 +61,7 @@ export default function GroupSubscribeButton(inProps) {
60
61
  group,
61
62
  cacheStrategy: authUserId ? CacheStrategies.CACHE_FIRST : CacheStrategies.STALE_WHILE_REVALIDATE
62
63
  });
64
+ const isGroupAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
63
65
  useEffect(() => {
64
66
  /**
65
67
  * Call scGroupsManager.subscriptionStatus inside an effect
@@ -69,11 +71,21 @@ export default function GroupSubscribeButton(inProps) {
69
71
  setStatus(scGroupsManager.subscriptionStatus(scGroup));
70
72
  }
71
73
  }, [authUserId, scGroupsManager.subscriptionStatus]);
72
- const subscribe = () => {
74
+ const subscribe = (userId) => {
73
75
  scGroupsManager
74
- .subscribe(scGroup)
76
+ .subscribe(scGroup, userId)
75
77
  .then(() => {
76
- // onJoin && onJoin(scGroup, !joined);
78
+ onSubscribe && onSubscribe(scGroup, SCGroupSubscriptionStatusType.SUBSCRIBED);
79
+ })
80
+ .catch((e) => {
81
+ Logger.error(SCOPE_SC_UI, e);
82
+ });
83
+ };
84
+ const unsubscribe = () => {
85
+ scGroupsManager
86
+ .unsubscribe(scGroup)
87
+ .then(() => {
88
+ onSubscribe && onSubscribe(scGroup, null);
77
89
  })
78
90
  .catch((e) => {
79
91
  Logger.error(SCOPE_SC_UI, e);
@@ -84,7 +96,7 @@ export default function GroupSubscribeButton(inProps) {
84
96
  scContext.settings.handleAnonymousAction();
85
97
  }
86
98
  else {
87
- subscribe();
99
+ status === SCGroupSubscriptionStatusType.SUBSCRIBED && !(user === null || user === void 0 ? void 0 : user.id) ? unsubscribe() : (user === null || user === void 0 ? void 0 : user.id) ? subscribe(user === null || user === void 0 ? void 0 : user.id) : subscribe();
88
100
  }
89
101
  };
90
102
  /**
@@ -94,21 +106,24 @@ export default function GroupSubscribeButton(inProps) {
94
106
  let _status;
95
107
  switch (status) {
96
108
  case SCGroupSubscriptionStatusType.REQUESTED:
97
- _status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupJoinButton.waitingApproval", id: "ui.groupJoinButton.waitingApproval" });
109
+ _status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.waitingApproval", id: "ui.groupSubscribeButton.waitingApproval" });
98
110
  break;
99
111
  case SCGroupSubscriptionStatusType.SUBSCRIBED:
100
112
  _status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.exit", id: "ui.groupSubscribeButton.exit" });
101
113
  break;
114
+ case SCGroupSubscriptionStatusType.INVITED:
115
+ _status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.accept", id: "ui.groupSubscribeButton.accept" });
116
+ break;
102
117
  default:
103
118
  scGroup.privacy === SCGroupPrivacyType.PUBLIC
104
119
  ? (_status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.enter", id: "ui.groupSubscribeButton.enter" }))
105
- : (_status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupJoinButton.requestAccess", id: "ui.groupJoinButton.requestAccess" }));
120
+ : (_status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.requestAccess", id: "ui.groupSubscribeButton.requestAccess" }));
106
121
  break;
107
122
  }
108
123
  return _status;
109
124
  };
110
- if (!scGroup || (scGroup && !scGroup.subscription_status)) {
125
+ if (!scGroup || (isGroupAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) || (isGroupAdmin && !(user === null || user === void 0 ? void 0 : user.id))) {
111
126
  return null;
112
127
  }
113
- return (React.createElement(Root, Object.assign({ size: "small", variant: "outlined", onClick: handleSubscribeAction, loading: scUserContext.user ? scGroupsManager.isLoading(scGroup) : null, className: classNames(classes.root, className) }, rest), getStatus()));
128
+ return (React.createElement(Root, Object.assign({ size: "small", variant: "outlined", onClick: handleSubscribeAction, loading: scUserContext.user ? scGroupsManager.isLoading(scGroup) : null, disabled: status === SCGroupSubscriptionStatusType.REQUESTED, className: classNames(classes.root, className) }, rest), isGroupAdmin ? React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.accept", id: "ui.groupSubscribeButton.accept" }) : getStatus()));
114
129
  }
@@ -1,31 +1,31 @@
1
+ import { SCGroupType } from '@selfcommunity/types';
1
2
  import { EndpointType } from '@selfcommunity/api-services';
2
- import { CacheStrategies } from '@selfcommunity/utils';
3
3
  import { GroupProps } from '../Group';
4
4
  export interface GroupsProps {
5
5
  /**
6
- * Endpoint to call
6
+ * Overrides or extends the styles applied to the component.
7
+ * @default null
7
8
  */
8
- endpoint: EndpointType;
9
+ className?: string;
9
10
  /**
10
- * Hides this component
11
- * @default false
11
+ * Endpoint to call
12
12
  */
13
- autoHide?: boolean;
13
+ endpoint: EndpointType;
14
14
  /**
15
- * Limit the number of users to show
16
- * @default false
15
+ * Props to spread to single group object
16
+ * @default {variant: 'outlined', ButtonBaseProps: {disableRipple: 'true'}}
17
17
  */
18
- limit?: number;
18
+ GroupComponentProps?: GroupProps;
19
19
  /**
20
- * Caching strategies
21
- * @default CacheStrategies.CACHE_FIRST
20
+ * Prefetch groups. Useful for SSR.
21
+ * Use this to init the component with groups
22
+ * @default null
22
23
  */
23
- cacheStrategy?: CacheStrategies;
24
- /**
25
- * Props to spread to single user object
26
- * @default empty object
24
+ prefetchedGroups?: SCGroupType[];
25
+ /** If true, it means that the endpoint fetches all groups available
26
+ * @default null
27
27
  */
28
- GroupProps?: GroupProps;
28
+ general?: boolean;
29
29
  /**
30
30
  * Other props
31
31
  */
@@ -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
  /**