@selfcommunity/react-ui 0.7.9-alpha.11 → 0.7.9-alpha.12

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.
@@ -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 {}
@@ -22,6 +22,10 @@ export interface GroupsProps {
22
22
  * @default null
23
23
  */
24
24
  prefetchedGroups?: SCGroupType[];
25
+ /** If true, it means that the endpoint fetches all groups available
26
+ * @default null
27
+ */
28
+ general?: boolean;
25
29
  /**
26
30
  * Other props
27
31
  */
@@ -64,7 +64,7 @@ function Groups(inProps) {
64
64
  props: inProps,
65
65
  name: constants_1.PREFIX
66
66
  });
67
- const { endpoint, className, GroupComponentProps = { variant: 'outlined', ButtonBaseProps: { disableRipple: true, component: material_1.Box } }, prefetchedGroups = [] } = props, rest = tslib_1.__rest(props, ["endpoint", "className", "GroupComponentProps", "prefetchedGroups"]);
67
+ const { endpoint, className, GroupComponentProps = { variant: 'outlined', ButtonBaseProps: { disableRipple: true, component: material_1.Box } }, prefetchedGroups = [], general } = props, rest = tslib_1.__rest(props, ["endpoint", "className", "GroupComponentProps", "prefetchedGroups", "general"]);
68
68
  // STATE
69
69
  const [groups, setGroups] = (0, react_1.useState)([]);
70
70
  const [loading, setLoading] = (0, react_1.useState)(true);
@@ -114,9 +114,11 @@ function Groups(inProps) {
114
114
  }
115
115
  }, [contentAvailability, authUserId, prefetchedGroups.length]);
116
116
  const handleSubscribe = (group) => {
117
- const newGroups = [...groups];
118
- const _updated = newGroups.filter((g) => g.id !== group.id);
119
- setGroups(_updated);
117
+ if (general) {
118
+ const newGroups = [...groups];
119
+ const _updated = newGroups.filter((g) => g.id !== group.id);
120
+ setGroups(_updated);
121
+ }
120
122
  };
121
123
  // RENDER
122
124
  if (!contentAvailability && !scUserContext.user) {
@@ -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 {}
@@ -22,6 +22,10 @@ export interface GroupsProps {
22
22
  * @default null
23
23
  */
24
24
  prefetchedGroups?: SCGroupType[];
25
+ /** If true, it means that the endpoint fetches all groups available
26
+ * @default null
27
+ */
28
+ general?: boolean;
25
29
  /**
26
30
  * Other props
27
31
  */
@@ -62,7 +62,7 @@ export default function Groups(inProps) {
62
62
  props: inProps,
63
63
  name: PREFIX
64
64
  });
65
- const { endpoint, className, GroupComponentProps = { variant: 'outlined', ButtonBaseProps: { disableRipple: true, component: Box } }, prefetchedGroups = [] } = props, rest = __rest(props, ["endpoint", "className", "GroupComponentProps", "prefetchedGroups"]);
65
+ const { endpoint, className, GroupComponentProps = { variant: 'outlined', ButtonBaseProps: { disableRipple: true, component: Box } }, prefetchedGroups = [], general } = props, rest = __rest(props, ["endpoint", "className", "GroupComponentProps", "prefetchedGroups", "general"]);
66
66
  // STATE
67
67
  const [groups, setGroups] = useState([]);
68
68
  const [loading, setLoading] = useState(true);
@@ -112,9 +112,11 @@ export default function Groups(inProps) {
112
112
  }
113
113
  }, [contentAvailability, authUserId, prefetchedGroups.length]);
114
114
  const handleSubscribe = (group) => {
115
- const newGroups = [...groups];
116
- const _updated = newGroups.filter((g) => g.id !== group.id);
117
- setGroups(_updated);
115
+ if (general) {
116
+ const newGroups = [...groups];
117
+ const _updated = newGroups.filter((g) => g.id !== group.id);
118
+ setGroups(_updated);
119
+ }
118
120
  };
119
121
  // RENDER
120
122
  if (!contentAvailability && !scUserContext.user) {