@selfcommunity/react-ui 0.7.9-alpha.9 → 0.7.10-alpha.0

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 (181) hide show
  1. package/lib/cjs/components/AccountRecover/AccountRecover.js +6 -1
  2. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +4 -3
  3. package/lib/cjs/components/CategoryHeader/Skeleton.js +3 -2
  4. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +6 -6
  5. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +19 -16
  6. package/lib/cjs/components/Composer/Attributes/Attributes.js +3 -3
  7. package/lib/cjs/components/Composer/Composer.js +3 -3
  8. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
  9. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
  10. package/lib/cjs/components/Editor/Editor.js +2 -0
  11. package/lib/cjs/components/Editor/nodes/ImageNode.js +6 -0
  12. package/lib/cjs/components/Editor/plugins/ImagePlugin.js +4 -0
  13. package/lib/cjs/components/Editor/plugins/ToolbarPlugin.js +17 -3
  14. package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -16
  15. package/lib/cjs/components/FeedObject/Contributors/Contributors.js +1 -1
  16. package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
  17. package/lib/cjs/components/FeedObject/FeedObject.js +27 -8
  18. package/lib/cjs/components/FeedObject/Poll/Poll.js +20 -20
  19. package/lib/cjs/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
  20. package/lib/cjs/components/Footer/Footer.js +1 -1
  21. package/lib/cjs/components/Group/Group.d.ts +9 -1
  22. package/lib/cjs/components/Group/Group.js +18 -6
  23. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +0 -1
  24. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -2
  25. package/lib/cjs/components/GroupForm/GroupForm.js +64 -13
  26. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +2 -3
  27. package/lib/cjs/components/GroupHeader/GroupHeader.js +38 -5
  28. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +65 -9
  29. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +29 -7
  30. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +73 -0
  31. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +220 -0
  32. package/lib/cjs/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
  33. package/lib/cjs/components/GroupInvitedWidget/Skeleton.js +38 -0
  34. package/lib/cjs/components/GroupInvitedWidget/constants.d.ts +1 -0
  35. package/lib/cjs/components/GroupInvitedWidget/constants.js +4 -0
  36. package/lib/cjs/components/GroupInvitedWidget/index.d.ts +4 -0
  37. package/lib/cjs/components/GroupInvitedWidget/index.js +8 -0
  38. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +6 -2
  39. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +21 -6
  40. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +12 -2
  41. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +13 -12
  42. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +4 -12
  43. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +33 -19
  44. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +3 -3
  45. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +22 -6
  46. package/lib/cjs/components/Groups/Groups.d.ts +15 -8
  47. package/lib/cjs/components/Groups/Groups.js +86 -32
  48. package/lib/cjs/components/Groups/Skeleton.d.ts +4 -0
  49. package/lib/cjs/components/Groups/Skeleton.js +2 -2
  50. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +7 -0
  51. package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
  52. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +10 -2
  53. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -0
  54. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +9 -1
  55. package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
  56. package/lib/cjs/components/Notification/Group/Group.js +87 -0
  57. package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
  58. package/lib/cjs/components/Notification/Group/index.js +5 -0
  59. package/lib/cjs/components/Notification/Notification.js +34 -1
  60. package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  61. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +7 -1
  62. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +16 -8
  63. package/lib/cjs/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
  64. package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  65. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +9 -4
  66. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
  67. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  68. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +46 -20
  69. package/lib/cjs/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +6 -0
  70. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  71. package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
  72. package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
  73. package/lib/cjs/components/User/User.d.ts +6 -1
  74. package/lib/cjs/components/User/User.js +5 -4
  75. package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
  76. package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.js +46 -0
  77. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
  78. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +183 -0
  79. package/lib/cjs/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
  80. package/lib/cjs/components/UserSubscribedGroupsWidget/constants.js +4 -0
  81. package/lib/cjs/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
  82. package/lib/cjs/components/UserSubscribedGroupsWidget/index.js +8 -0
  83. package/lib/cjs/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
  84. package/lib/cjs/constants/PubSub.d.ts +28 -0
  85. package/lib/cjs/constants/PubSub.js +22 -0
  86. package/lib/cjs/index.d.ts +5 -3
  87. package/lib/cjs/index.js +11 -4
  88. package/lib/cjs/types/index.d.ts +2 -1
  89. package/lib/esm/components/AccountRecover/AccountRecover.js +6 -1
  90. package/lib/esm/components/BottomNavigation/BottomNavigation.js +5 -4
  91. package/lib/esm/components/CategoryHeader/Skeleton.js +3 -2
  92. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +6 -6
  93. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +19 -16
  94. package/lib/esm/components/Composer/Attributes/Attributes.js +3 -3
  95. package/lib/esm/components/Composer/Composer.js +3 -3
  96. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
  97. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
  98. package/lib/esm/components/Editor/Editor.js +2 -0
  99. package/lib/esm/components/Editor/nodes/ImageNode.js +6 -0
  100. package/lib/esm/components/Editor/plugins/ImagePlugin.js +4 -0
  101. package/lib/esm/components/Editor/plugins/ToolbarPlugin.js +19 -5
  102. package/lib/esm/components/FeedObject/Actions/Share/Share.js +19 -17
  103. package/lib/esm/components/FeedObject/Contributors/Contributors.js +1 -1
  104. package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
  105. package/lib/esm/components/FeedObject/FeedObject.js +28 -9
  106. package/lib/esm/components/FeedObject/Poll/Poll.js +20 -20
  107. package/lib/esm/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
  108. package/lib/esm/components/Footer/Footer.js +2 -2
  109. package/lib/esm/components/Group/Group.d.ts +9 -1
  110. package/lib/esm/components/Group/Group.js +22 -10
  111. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +0 -1
  112. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -2
  113. package/lib/esm/components/GroupForm/GroupForm.js +64 -13
  114. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +2 -3
  115. package/lib/esm/components/GroupHeader/GroupHeader.js +40 -7
  116. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +65 -9
  117. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +29 -7
  118. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +73 -0
  119. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +217 -0
  120. package/lib/esm/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
  121. package/lib/esm/components/GroupInvitedWidget/Skeleton.js +34 -0
  122. package/lib/esm/components/GroupInvitedWidget/constants.d.ts +1 -0
  123. package/lib/esm/components/GroupInvitedWidget/constants.js +1 -0
  124. package/lib/esm/components/GroupInvitedWidget/index.d.ts +4 -0
  125. package/lib/esm/components/GroupInvitedWidget/index.js +4 -0
  126. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +7 -3
  127. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +22 -7
  128. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +12 -2
  129. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +13 -12
  130. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +4 -12
  131. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +33 -19
  132. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +3 -3
  133. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +22 -6
  134. package/lib/esm/components/Groups/Groups.d.ts +15 -8
  135. package/lib/esm/components/Groups/Groups.js +91 -37
  136. package/lib/esm/components/Groups/Skeleton.d.ts +4 -0
  137. package/lib/esm/components/Groups/Skeleton.js +2 -2
  138. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +9 -2
  139. package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
  140. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +11 -3
  141. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -0
  142. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -3
  143. package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
  144. package/lib/esm/components/Notification/Group/Group.js +84 -0
  145. package/lib/esm/components/Notification/Group/index.d.ts +3 -0
  146. package/lib/esm/components/Notification/Group/index.js +2 -0
  147. package/lib/esm/components/Notification/Notification.js +34 -1
  148. package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  149. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +7 -1
  150. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +17 -9
  151. package/lib/esm/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
  152. package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  153. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +9 -4
  154. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
  155. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  156. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +48 -22
  157. package/lib/esm/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +7 -1
  158. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  159. package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
  160. package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
  161. package/lib/esm/components/User/User.d.ts +6 -1
  162. package/lib/esm/components/User/User.js +5 -4
  163. package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
  164. package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.js +42 -0
  165. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
  166. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +180 -0
  167. package/lib/esm/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
  168. package/lib/esm/components/UserSubscribedGroupsWidget/constants.js +1 -0
  169. package/lib/esm/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
  170. package/lib/esm/components/UserSubscribedGroupsWidget/index.js +4 -0
  171. package/lib/esm/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
  172. package/lib/esm/constants/PubSub.d.ts +28 -0
  173. package/lib/esm/constants/PubSub.js +19 -0
  174. package/lib/esm/index.d.ts +5 -3
  175. package/lib/esm/index.js +4 -2
  176. package/lib/esm/types/index.d.ts +2 -1
  177. package/lib/umd/311.js +2 -0
  178. package/lib/umd/react-ui.js +1 -1
  179. package/package.json +10 -10
  180. package/lib/umd/871.js +0 -2
  181. /package/lib/umd/{871.js.LICENSE.txt → 311.js.LICENSE.txt} +0 -0
@@ -69,36 +69,36 @@ function PollObject(props) {
69
69
  * Handles choice upvote
70
70
  */
71
71
  const handleVote = (id) => {
72
+ const prevChoices = [...choices];
73
+ let updatedChoices;
72
74
  if (multipleChoices) {
73
- setChoices((prevChoices) => {
74
- return prevChoices.map((choice) => Object.assign({}, choice, {
75
- voted: choice.id === id ? true : choice.voted,
76
- vote_count: choice.id === id ? choice.vote_count + 1 : choice.vote_count
77
- }));
78
- });
75
+ updatedChoices = prevChoices.map((choice) => Object.assign({}, choice, {
76
+ voted: choice.id === id ? true : choice.voted,
77
+ vote_count: choice.id === id ? choice.vote_count + 1 : choice.vote_count
78
+ }));
79
79
  setVotes((prevVotes) => prevVotes + 1);
80
80
  }
81
81
  else {
82
- setChoices((prevChoices) => {
83
- const updatedChoices = prevChoices.map((choice) => {
84
- return Object.assign(Object.assign({}, choice), { voted: choice.id === id, vote_count: choice.id === id ? choice.vote_count + 1 : choice.vote_count > 0 && choice.voted ? choice.vote_count - 1 : choice.vote_count });
85
- });
86
- const newVotes = updatedChoices.reduce((totalVotes, choice) => totalVotes + choice.vote_count, 0);
87
- setVotes(newVotes);
88
- return updatedChoices;
89
- });
82
+ updatedChoices = prevChoices.map((choice) => Object.assign({}, choice, {
83
+ voted: choice.id === id,
84
+ vote_count: choice.id === id ? choice.vote_count + 1 : choice.vote_count > 0 && choice.voted ? choice.vote_count - 1 : choice.vote_count
85
+ }));
86
+ setVotes(updatedChoices.reduce((totalVotes, choice) => totalVotes + choice.vote_count, 0));
90
87
  }
88
+ setChoices(updatedChoices);
89
+ onChange(updatedChoices);
91
90
  };
92
91
  /**
93
92
  * Handles choice unvote
94
93
  */
95
94
  const handleUnVote = (id) => {
96
- setChoices((prevChoices) => {
97
- return prevChoices.map((choice) => Object.assign({}, choice, {
98
- voted: choice.id === id ? false : choice.voted,
99
- vote_count: choice.id === id && choice.vote_count > 0 ? choice.vote_count - 1 : choice.vote_count
100
- }));
101
- });
95
+ const prevChoices = [...choices];
96
+ const updatedChoices = prevChoices.map((choice) => Object.assign({}, choice, {
97
+ voted: choice.id === id ? false : choice.voted,
98
+ vote_count: choice.id === id && choice.vote_count > 0 ? choice.vote_count - 1 : choice.vote_count
99
+ }));
100
+ setChoices(updatedChoices);
101
+ onChange(updatedChoices);
102
102
  setVotes((prevVotes) => prevVotes - 1);
103
103
  };
104
104
  /**
@@ -57,7 +57,7 @@ function FeedUpdatesWidget(inProps) {
57
57
  const [updates, setUpdates] = (0, react_1.useState)(false);
58
58
  // REFS
59
59
  const updatesSubscription = (0, react_1.useRef)(null);
60
- // Subscripber for pubsub callback
60
+ // Subscriber for pubsub callback
61
61
  const subscriber = (msg, data) => {
62
62
  if (subscriptionChannelUpdatesCallback(msg, data)) {
63
63
  setUpdates(true);
@@ -96,7 +96,7 @@ function Footer(inProps) {
96
96
  }
97
97
  return (react_1.default.createElement(Root, Object.assign({}, rest, { className: (0, classnames_1.default)(classes.root, className) }),
98
98
  startActions,
99
- react_1.default.createElement(material_1.Box, { className: classes.itemList }, _menu.items.map((item, index) => (react_1.default.createElement(material_1.Button, { component: react_core_1.Link, key: item.id, className: classes.item, to: item.url, variant: "text" }, item.label)))),
99
+ react_1.default.createElement(material_1.Box, { className: classes.itemList }, (0, utils_1.sortByAttr)(_menu.items, 'order').map((item, index) => (react_1.default.createElement(material_1.Button, { component: react_core_1.Link, key: item.id, className: classes.item, to: item.url, variant: "text" }, item.label)))),
100
100
  endActions,
101
101
  react_1.default.createElement(material_1.Typography, { textAlign: "center", className: classes.copyright, variant: "body2", dangerouslySetInnerHTML: { __html: copyright } })));
102
102
  }
@@ -27,6 +27,11 @@ export interface GroupProps extends WidgetProps {
27
27
  * @default false
28
28
  */
29
29
  hideActions?: boolean;
30
+ /**
31
+ * Prop to redirect the user to the group page
32
+ * @default false
33
+ */
34
+ actionRedirect?: boolean;
30
35
  /**
31
36
  * Props to spread to the button
32
37
  * @default {}
@@ -42,7 +47,7 @@ export interface GroupProps extends WidgetProps {
42
47
  *
43
48
  *
44
49
  * This component renders a group item.
45
- * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/User)
50
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/Group)
46
51
 
47
52
  #### Import
48
53
 
@@ -61,6 +66,9 @@ export interface GroupProps extends WidgetProps {
61
66
  |---|---|---|
62
67
  |root|.SCGroup-root|Styles applied to the root element.|
63
68
  |avatar|.SCGroup-avatar|Styles applied to the avatar element.|
69
+ |actions|.SCGroup-actions|Styles applied to the actions section.|
70
+ |icon|.SCGroup-icon|Styles applied to the group privacy icon element.|
71
+
64
72
 
65
73
  *
66
74
  * @param inProps
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importStar(require("react"));
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const material_1 = require("@mui/material");
7
+ const types_1 = require("@selfcommunity/types");
7
8
  const react_core_1 = require("@selfcommunity/react-core");
8
9
  const react_intl_1 = require("react-intl");
9
10
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
@@ -22,7 +23,8 @@ const messages = (0, react_intl_1.defineMessages)({
22
23
  const classes = {
23
24
  root: `${constants_1.PREFIX}-root`,
24
25
  avatar: `${constants_1.PREFIX}-avatar`,
25
- actions: `${constants_1.PREFIX}-actions`
26
+ actions: `${constants_1.PREFIX}-actions`,
27
+ icon: `${constants_1.PREFIX}-icon`
26
28
  };
27
29
  const Root = (0, styles_1.styled)(BaseItemButton_1.default, {
28
30
  name: constants_1.PREFIX,
@@ -34,7 +36,7 @@ const Root = (0, styles_1.styled)(BaseItemButton_1.default, {
34
36
  *
35
37
  *
36
38
  * This component renders a group item.
37
- * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/User)
39
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/Group)
38
40
 
39
41
  #### Import
40
42
 
@@ -53,21 +55,28 @@ const Root = (0, styles_1.styled)(BaseItemButton_1.default, {
53
55
  |---|---|---|
54
56
  |root|.SCGroup-root|Styles applied to the root element.|
55
57
  |avatar|.SCGroup-avatar|Styles applied to the avatar element.|
58
+ |actions|.SCGroup-actions|Styles applied to the actions section.|
59
+ |icon|.SCGroup-icon|Styles applied to the group privacy icon element.|
60
+
56
61
 
57
62
  *
58
63
  * @param inProps
59
64
  */
60
65
  function Group(inProps) {
66
+ var _a;
61
67
  // PROPS
62
68
  const props = (0, system_1.useThemeProps)({
63
69
  props: inProps,
64
70
  name: constants_1.PREFIX
65
71
  });
66
- const { groupId = null, group = null, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {}, visible = true } = props, rest = tslib_1.__rest(props, ["groupId", "group", "className", "elevation", "hideActions", "groupSubscribeButtonProps", "visible"]);
72
+ const { groupId = null, group = null, className = null, elevation, hideActions = false, actionRedirect = false, groupSubscribeButtonProps = {} } = props, rest = tslib_1.__rest(props, ["groupId", "group", "className", "elevation", "hideActions", "actionRedirect", "groupSubscribeButtonProps"]);
67
73
  // STATE
68
74
  const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
69
75
  // CONTEXT
70
76
  const scRoutingContext = (0, react_core_1.useSCRouting)();
77
+ const scUserContext = (0, react_core_1.useSCUser)();
78
+ // CONST
79
+ const isGroupAdmin = (0, react_1.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]);
71
80
  const [openAlert, setOpenAlert] = (0, react_1.useState)(false);
72
81
  // INTL
73
82
  const intl = (0, react_intl_1.useIntl)();
@@ -77,8 +86,8 @@ function Group(inProps) {
77
86
  */
78
87
  function renderAuthenticatedActions() {
79
88
  return (react_1.default.createElement(material_1.Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
80
- react_1.default.createElement(material_1.Icon, null, !visible ? 'private' : 'public'),
81
- react_1.default.createElement(GroupSubscribeButton_1.default, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
89
+ isGroupAdmin && react_1.default.createElement(material_1.Icon, null, "face"),
90
+ actionRedirect ? (react_1.default.createElement(material_1.Button, { size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup) }, scGroup.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED ? (react_1.default.createElement(react_intl_1.FormattedMessage, { defaultMessage: "ui.group.status.enter", id: "ui.group.status.enter" })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { defaultMessage: "ui.group.status.discover", id: "ui.group.status.discover" })))) : (react_1.default.createElement(GroupSubscribeButton_1.default, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps)))));
82
91
  }
83
92
  /**
84
93
  * Renders group object
@@ -90,7 +99,10 @@ function Group(inProps) {
90
99
  * Renders root object
91
100
  */
92
101
  return (react_1.default.createElement(react_1.default.Fragment, null,
93
- react_1.default.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: react_1.default.createElement(material_1.Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary: scGroup.name, secondary: `${intl.formatMessage(messages.groupMembers, { total: scGroup.subscribers_counter })}`, actions: hideActions ? null : renderAuthenticatedActions() })),
102
+ react_1.default.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: react_1.default.createElement(material_1.Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary: react_1.default.createElement(react_1.default.Fragment, null,
103
+ scGroup.name,
104
+ " ",
105
+ react_1.default.createElement(material_1.Icon, { className: classes.icon }, (group === null || group === void 0 ? void 0 : group.privacy) === types_1.SCGroupPrivacyType.PRIVATE ? 'private' : 'public')), secondary: `${intl.formatMessage(messages.groupMembers, { total: scGroup.subscribers_counter })}`, actions: hideActions ? null : renderAuthenticatedActions() })),
94
106
  openAlert && react_1.default.createElement(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })));
95
107
  }
96
108
  exports.default = Group;
@@ -28,7 +28,6 @@ export interface GroupAutocompleteProps extends Pick<AutocompleteProps<SCGroupTy
28
28
  *
29
29
  *
30
30
  * This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
31
- * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
32
31
  *
33
32
  * #### Import
34
33
  * ```jsx
@@ -26,7 +26,6 @@ const Root = (0, styles_1.styled)(Autocomplete_1.default, {
26
26
  *
27
27
  *
28
28
  * This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
29
- * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
30
29
  *
31
30
  * #### Import
32
31
  * ```jsx
@@ -80,7 +79,7 @@ const GroupAutocomplete = (inProps) => {
80
79
  setValue(value);
81
80
  };
82
81
  // Render
83
- return (react_1.default.createElement(Root, Object.assign({ freeSolo: true, className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: groups || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
82
+ return (react_1.default.createElement(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: groups || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
84
83
  // renderTags={(value, getTagProps) => {
85
84
  // return value.map((option: any, index) => (
86
85
  // <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
@@ -15,10 +15,12 @@ const ChangeGroupPicture_1 = tslib_1.__importDefault(require("../ChangeGroupPict
15
15
  const ChangeGroupCover_1 = tslib_1.__importDefault(require("../ChangeGroupCover"));
16
16
  const Group_1 = require("../../constants/Group");
17
17
  const GroupInviteButton_1 = tslib_1.__importDefault(require("../GroupInviteButton"));
18
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
18
19
  const types_1 = require("@selfcommunity/types");
19
20
  const Errors_1 = require("../../constants/Errors");
20
21
  const api_services_1 = require("@selfcommunity/api-services");
21
22
  const utils_1 = require("@selfcommunity/utils");
23
+ const PubSub_1 = require("../../constants/PubSub");
22
24
  const messages = (0, react_intl_1.defineMessages)({
23
25
  name: {
24
26
  id: 'ui.groupForm.name.placeholder',
@@ -90,6 +92,7 @@ const Root = (0, styles_1.styled)(BaseDialog_1.default, {
90
92
  * @param inProps
91
93
  */
92
94
  function GroupForm(inProps) {
95
+ var _a;
93
96
  //PROPS
94
97
  const props = (0, system_1.useThemeProps)({
95
98
  props: inProps,
@@ -142,6 +145,22 @@ function GroupForm(inProps) {
142
145
  setError(error);
143
146
  }
144
147
  }
148
+ /**
149
+ * Notify when a group info changed
150
+ * @param data
151
+ */
152
+ function notifyChanges(data) {
153
+ if (data) {
154
+ if (group) {
155
+ // Edit group
156
+ pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.EDIT}`, data);
157
+ }
158
+ else {
159
+ // Create group
160
+ pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.CREATE}`, data);
161
+ }
162
+ }
163
+ }
145
164
  const handleSubmit = () => {
146
165
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
147
166
  const formData = new FormData();
@@ -155,8 +174,10 @@ function GroupForm(inProps) {
155
174
  if (field.emotionalImageOriginalFile) {
156
175
  formData.append('emotional_image_original', field.emotionalImageOriginalFile);
157
176
  }
158
- for (const key in field.invitedUsers) {
159
- formData.append(key, field.invitedUsers[key]);
177
+ if (!group) {
178
+ for (const key in field.invitedUsers) {
179
+ formData.append(key, field.invitedUsers[key]);
180
+ }
160
181
  }
161
182
  let groupService;
162
183
  if (group) {
@@ -168,6 +189,7 @@ function GroupForm(inProps) {
168
189
  groupService
169
190
  .then((data) => {
170
191
  onSuccess && onSuccess(data);
192
+ notifyChanges(data);
171
193
  onClose && onClose();
172
194
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
173
195
  })
@@ -206,34 +228,63 @@ function GroupForm(inProps) {
206
228
  endAdornment: react_1.default.createElement(material_1.Typography, { variant: "body2" }, Group_1.GROUP_TITLE_MAX_LENGTH - field.name.length)
207
229
  } }),
208
230
  react_1.default.createElement(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
209
- endAdornment: react_1.default.createElement(material_1.Typography, { variant: "body2" }, Group_1.GROUP_DESCRIPTION_MAX_LENGTH - field.description.length)
231
+ endAdornment: (react_1.default.createElement(material_1.Typography, { variant: "body2" }, ((_a = field.description) === null || _a === void 0 ? void 0 : _a.length) ? Group_1.GROUP_DESCRIPTION_MAX_LENGTH - field.description.length : Group_1.GROUP_DESCRIPTION_MAX_LENGTH))
210
232
  } }),
211
233
  react_1.default.createElement(material_1.Box, { className: classes.privacySection },
212
234
  react_1.default.createElement(material_1.Typography, { variant: "h4" },
213
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })),
235
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: {
236
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
237
+ // @ts-ignore
238
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
239
+ } })),
214
240
  react_1.default.createElement(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center" },
215
241
  react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) },
216
242
  react_1.default.createElement(material_1.Icon, null, "private"),
217
243
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
218
- react_1.default.createElement(material_1.Switch, { className: classes.switch, checked: field.isPublic, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))) }),
244
+ react_1.default.createElement(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: group && group.privacy === types_1.SCGroupPrivacyType.PRIVATE }),
219
245
  react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) },
220
246
  react_1.default.createElement(material_1.Icon, null, "public"),
221
247
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" }))),
222
- react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))),
223
- react_1.default.createElement(material_1.Box, { className: classes.visibilitySection }, !field.isPublic && (react_1.default.createElement(react_1.default.Fragment, null,
248
+ react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: {
249
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
250
+ // @ts-ignore
251
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
252
+ } })) : (react_1.default.createElement(react_1.default.Fragment, null, group && group.privacy === types_1.SCGroupPrivacyType.PRIVATE ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private.info.edit", defaultMessage: "ui.groupForm.private.public.info.edit", values: {
253
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
254
+ // @ts-ignore
255
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
256
+ } })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: {
257
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
258
+ // @ts-ignore
259
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
260
+ } })))))),
261
+ react_1.default.createElement(material_1.Box, { className: classes.visibilitySection }, ((!field.isPublic && !group) || (group && !field.isPublic)) && (react_1.default.createElement(react_1.default.Fragment, null,
224
262
  react_1.default.createElement(material_1.Typography, { variant: "h4" },
225
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })),
263
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: {
264
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
265
+ // @ts-ignore
266
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
267
+ } })),
226
268
  react_1.default.createElement(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center" },
227
269
  react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isVisible }) },
228
270
  react_1.default.createElement(material_1.Icon, null, "visibility_off"),
229
271
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
230
- react_1.default.createElement(material_1.Switch, { className: classes.switch, checked: field.isVisible, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isVisible']: !field.isVisible }))) }),
272
+ react_1.default.createElement(material_1.Switch, { className: classes.switch, checked: field.isVisible, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isVisible']: !field.isVisible }))) }),
231
273
  react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isVisible }) },
232
274
  react_1.default.createElement(material_1.Icon, null, "visibility"),
233
275
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" }))),
234
- react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } }))))))),
235
- react_1.default.createElement(material_1.Divider, null),
236
- react_1.default.createElement(material_1.Box, { className: classes.inviteSection },
237
- react_1.default.createElement(GroupInviteButton_1.default, { handleInvitations: handleInviteSection })))));
276
+ react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: {
277
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
278
+ // @ts-ignore
279
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
280
+ } })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: {
281
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
282
+ // @ts-ignore
283
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
284
+ } }))))))),
285
+ !group && (react_1.default.createElement(react_1.default.Fragment, null,
286
+ react_1.default.createElement(material_1.Divider, null),
287
+ react_1.default.createElement(material_1.Box, { className: classes.inviteSection },
288
+ react_1.default.createElement(GroupInviteButton_1.default, { handleInvitations: handleInviteSection })))))));
238
289
  }
239
290
  exports.default = GroupForm;
@@ -35,10 +35,10 @@ export interface GroupHeaderProps {
35
35
  */
36
36
  ChangeCoverProps?: ChangeGroupCoverProps;
37
37
  /**
38
- * Props to spread category button followed
38
+ * Props to spread group button followed
39
39
  * @default {}
40
40
  */
41
- GroupSubscribeButtonProps?: Pick<GroupSubscribeButtonProps, Exclude<keyof GroupSubscribeButtonProps, 'group' | 'onSubscribe'>>;
41
+ GroupSubscribeButtonProps?: GroupSubscribeButtonProps;
42
42
  /**
43
43
  * Props to spread to the group memebers button
44
44
  * @default {}
@@ -54,7 +54,6 @@ export interface GroupHeaderProps {
54
54
  *
55
55
  *
56
56
  * This component renders the groups top section.
57
- * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UserProfileHeader)
58
57
 
59
58
  #### Import
60
59
 
@@ -18,6 +18,8 @@ const GroupMembersButton_1 = tslib_1.__importDefault(require("../GroupMembersBut
18
18
  const EditGroupButton_1 = tslib_1.__importDefault(require("../EditGroupButton"));
19
19
  const GroupSubscribeButton_1 = tslib_1.__importDefault(require("../GroupSubscribeButton"));
20
20
  const GroupInviteButton_1 = tslib_1.__importDefault(require("../GroupInviteButton"));
21
+ const PubSub_1 = require("../../constants/PubSub");
22
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
21
23
  const classes = {
22
24
  root: `${constants_1.PREFIX}-root`,
23
25
  cover: `${constants_1.PREFIX}-cover`,
@@ -40,7 +42,6 @@ const Root = (0, styles_1.styled)(material_1.Box, {
40
42
  *
41
43
  *
42
44
  * This component renders the groups top section.
43
- * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UserProfileHeader)
44
45
 
45
46
  #### Import
46
47
 
@@ -81,6 +82,8 @@ function GroupHeader(inProps) {
81
82
  const scUserContext = (0, react_core_1.useSCUser)();
82
83
  // HOOKS
83
84
  const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
85
+ // REFS
86
+ const updatesSubscription = (0, react_1.useRef)(null);
84
87
  // CONST
85
88
  const isGroupAdmin = (0, react_1.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]);
86
89
  /**
@@ -89,7 +92,7 @@ function GroupHeader(inProps) {
89
92
  */
90
93
  function handleChangeAvatar(avatar) {
91
94
  if (isGroupAdmin) {
92
- setSCGroup(Object.assign({}, scGroup, { image_bigger: avatar }));
95
+ setSCGroup(Object.assign({}, scGroup, { image_big: avatar }));
93
96
  }
94
97
  }
95
98
  /**
@@ -107,6 +110,34 @@ function GroupHeader(inProps) {
107
110
  const handleSubscribe = (group, status) => {
108
111
  setSCGroup(Object.assign(Object.assign({}, group), { subscribers_counter: group.subscribers_counter + (status ? 1 : -1) }));
109
112
  };
113
+ /**
114
+ * Subscriber for pubsub callback
115
+ */
116
+ const onChangeGroupMembersHandler = (0, react_1.useCallback)((msg, data) => {
117
+ var _a;
118
+ if (data && ((_a = data === null || data === void 0 ? void 0 : data.group) === null || _a === void 0 ? void 0 : _a.id) === (scGroup === null || scGroup === void 0 ? void 0 : scGroup.id)) {
119
+ let _group = Object.assign({}, scGroup);
120
+ if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.ADD_MEMBER}`) {
121
+ _group.subscribers_counter = _group.subscribers_counter + 1;
122
+ }
123
+ else if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.REMOVE_MEMBER}`) {
124
+ _group.subscribers_counter = Math.max(_group.subscribers_counter - 1, 0);
125
+ }
126
+ console.log(_group);
127
+ setSCGroup(_group);
128
+ }
129
+ }, [scGroup, setSCGroup]);
130
+ /**
131
+ * On mount, subscribe to receive groups updates (only edit)
132
+ */
133
+ (0, react_1.useEffect)(() => {
134
+ if (scGroup) {
135
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.MEMBERS}`, onChangeGroupMembersHandler);
136
+ }
137
+ return () => {
138
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
139
+ };
140
+ }, [scGroup]);
110
141
  // RENDER
111
142
  if (!scGroup) {
112
143
  return react_1.default.createElement(Skeleton_1.default, null);
@@ -118,7 +149,7 @@ function GroupHeader(inProps) {
118
149
  react_1.default.createElement(material_1.Paper, { style: _backgroundCover, classes: { root: classes.cover } },
119
150
  react_1.default.createElement(material_1.Box, { className: classes.avatar },
120
151
  react_1.default.createElement(material_1.Avatar, null,
121
- react_1.default.createElement("img", { alt: "group", src: scGroup.image_bigger ? scGroup.image_bigger : '' }))),
152
+ react_1.default.createElement("img", { alt: "group", src: scGroup.image_big ? scGroup.image_big : '' }))),
122
153
  isGroupAdmin && (react_1.default.createElement(react_1.default.Fragment, null,
123
154
  react_1.default.createElement(ChangeGroupPicture_1.default, Object.assign({ groupId: scGroup.id, onChange: handleChangeAvatar, className: classes.changePicture }, ChangePictureProps)),
124
155
  react_1.default.createElement("div", { className: classes.changeCover },
@@ -138,10 +169,12 @@ function GroupHeader(inProps) {
138
169
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" }))) : (react_1.default.createElement(material_1.Typography, { className: classes.visibilityItem },
139
170
  react_1.default.createElement(material_1.Icon, null, "visibility_off"),
140
171
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })))),
141
- react_1.default.createElement(react_1.default.Fragment, null, ((scGroup && scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC) || isGroupAdmin) && (react_1.default.createElement(material_1.Box, { className: classes.members },
172
+ react_1.default.createElement(react_1.default.Fragment, null, ((scGroup && scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC) ||
173
+ scGroup.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED ||
174
+ isGroupAdmin) && (react_1.default.createElement(material_1.Box, { className: classes.members },
142
175
  react_1.default.createElement(material_1.Typography, { className: classes.membersCounter, component: "div" },
143
176
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } })),
144
- react_1.default.createElement(GroupMembersButton_1.default, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps))))),
177
+ react_1.default.createElement(GroupMembersButton_1.default, Object.assign({ key: scGroup.subscribers_counter, groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps))))),
145
178
  isGroupAdmin ? (react_1.default.createElement(GroupInviteButton_1.default, { group: scGroup, groupId: scGroup.id })) : (react_1.default.createElement(GroupSubscribeButton_1.default, Object.assign({ group: scGroup, onSubscribe: handleSubscribe }, GroupSubscribeButtonProps))))));
146
179
  }
147
180
  exports.default = GroupHeader;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const react_1 = tslib_1.__importDefault(require("react"));
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const material_1 = require("@mui/material");
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
@@ -10,7 +10,11 @@ const system_1 = require("@mui/system");
10
10
  const constants_1 = require("./constants");
11
11
  const react_intl_1 = require("react-intl");
12
12
  const types_1 = require("@selfcommunity/types");
13
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
13
14
  const react_core_1 = require("@selfcommunity/react-core");
15
+ const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
16
+ const PubSub_1 = require("../../constants/PubSub");
17
+ const User_1 = tslib_1.__importDefault(require("../User"));
14
18
  const classes = {
15
19
  root: `${constants_1.PREFIX}-root`,
16
20
  title: `${constants_1.PREFIX}-title`,
@@ -19,6 +23,7 @@ const classes = {
19
23
  privacyTitle: `${constants_1.PREFIX}-privacy-title`,
20
24
  visibility: `${constants_1.PREFIX}-visibility`,
21
25
  visibilityTitle: `${constants_1.PREFIX}-visibility-title`,
26
+ admin: `${constants_1.PREFIX}-admin`,
22
27
  date: `${constants_1.PREFIX}-date`
23
28
  };
24
29
  const Root = (0, styles_1.styled)(Widget_1.default, {
@@ -54,6 +59,7 @@ const Root = (0, styles_1.styled)(Widget_1.default, {
54
59
  * @param inProps
55
60
  */
56
61
  function GroupInfoWidget(inProps) {
62
+ var _a;
57
63
  // PROPS
58
64
  const props = (0, system_1.useThemeProps)({
59
65
  props: inProps,
@@ -61,9 +67,36 @@ function GroupInfoWidget(inProps) {
61
67
  });
62
68
  const { className, group, groupId, onHeightChange, onStateChange } = props, rest = tslib_1.__rest(props, ["className", "group", "groupId", "onHeightChange", "onStateChange"]);
63
69
  // HOOKS
64
- const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
70
+ const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
65
71
  // INTL
66
72
  const intl = (0, react_intl_1.useIntl)();
73
+ // REFS
74
+ const updatesSubscription = (0, react_1.useRef)(null);
75
+ /**
76
+ * Subscriber for pubsub callback
77
+ */
78
+ const onChangeGroupHandler = (0, react_1.useCallback)((_msg, data) => {
79
+ if (data && scGroup.id === data.id) {
80
+ setSCGroup(data);
81
+ }
82
+ }, [scGroup, setSCGroup]);
83
+ /**
84
+ * On mount, subscribe to receive groups updates (only edit)
85
+ */
86
+ (0, react_1.useEffect)(() => {
87
+ if (scGroup) {
88
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.EDIT}`, onChangeGroupHandler);
89
+ }
90
+ return () => {
91
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
92
+ };
93
+ }, [scGroup]);
94
+ /**
95
+ * Loading group
96
+ */
97
+ if (!scGroup) {
98
+ return react_1.default.createElement(Skeleton_1.default, null);
99
+ }
67
100
  /**
68
101
  * Renders root object
69
102
  */
@@ -75,26 +108,49 @@ function GroupInfoWidget(inProps) {
75
108
  react_1.default.createElement(material_1.Typography, { component: "div", className: classes.privacy }, scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC ? (react_1.default.createElement(react_1.default.Fragment, null,
76
109
  react_1.default.createElement(material_1.Typography, { className: classes.privacyTitle },
77
110
  react_1.default.createElement(material_1.Icon, null, "public"),
78
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" })),
111
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.public", defaultMessage: "ui.groupInfoWidget.privacy.public" })),
79
112
  react_1.default.createElement(material_1.Typography, { variant: "body2" },
80
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))) : (react_1.default.createElement(react_1.default.Fragment, null,
113
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.public.info", defaultMessage: "ui.groupInfoWidget.privacy.public.info", values: {
114
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
115
+ // @ts-ignore
116
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
117
+ } })))) : (react_1.default.createElement(react_1.default.Fragment, null,
81
118
  react_1.default.createElement(material_1.Typography, { className: classes.privacyTitle },
82
119
  react_1.default.createElement(material_1.Icon, null, "private"),
83
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
120
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.private", defaultMessage: "ui.groupInfoWidget.privacy.private" })),
84
121
  react_1.default.createElement(material_1.Typography, { variant: "body2" },
85
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } }))))),
122
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.private.info", defaultMessage: "ui.groupInfoWidget.private.public.info", values: {
123
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
124
+ // @ts-ignore
125
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
126
+ } }))))),
86
127
  scGroup.privacy === types_1.SCGroupPrivacyType.PRIVATE && (react_1.default.createElement(material_1.Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (react_1.default.createElement(react_1.default.Fragment, null,
87
128
  react_1.default.createElement(material_1.Typography, { className: classes.visibilityTitle },
88
129
  react_1.default.createElement(material_1.Icon, null, "visibility"),
89
130
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" })),
90
131
  react_1.default.createElement(material_1.Typography, { variant: "body2" },
91
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))) : (react_1.default.createElement(react_1.default.Fragment, null,
132
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: {
133
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
134
+ // @ts-ignore
135
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
136
+ } })))) : (react_1.default.createElement(react_1.default.Fragment, null,
92
137
  react_1.default.createElement(material_1.Typography, { className: classes.visibilityTitle },
93
138
  react_1.default.createElement(material_1.Icon, null, "visibility_off"),
94
139
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
95
140
  react_1.default.createElement(material_1.Typography, { variant: "body2" },
96
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))))),
141
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: {
142
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
143
+ // @ts-ignore
144
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
145
+ } })))))),
97
146
  react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.date },
98
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })))));
147
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })),
148
+ react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.admin },
149
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.admin", defaultMessage: "ui.groupInfoWidget.admin", values: {
150
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
151
+ // @ts-ignore
152
+ b: (chunks) => react_1.default.createElement("strong", null, chunks)
153
+ } }),
154
+ react_1.default.createElement(User_1.default, { userId: (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id, elevation: 0, actions: react_1.default.createElement(react_1.default.Fragment, null) })))));
99
155
  }
100
156
  exports.default = GroupInfoWidget;