@selfcommunity/react-core 0.7.0-alpha.0 → 0.7.0-alpha.10

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 (85) hide show
  1. package/lib/cjs/components/provider/SCThemeProvider/index.js +3 -3
  2. package/lib/cjs/constants/Cache.d.ts +12 -0
  3. package/lib/cjs/constants/Cache.js +17 -1
  4. package/lib/cjs/constants/Preferences.d.ts +16 -0
  5. package/lib/cjs/constants/Preferences.js +31 -2
  6. package/lib/cjs/constants/Routes.d.ts +6 -0
  7. package/lib/cjs/constants/Routes.js +14 -1
  8. package/lib/cjs/hooks/useSCFetchCategory.d.ts +1 -0
  9. package/lib/cjs/hooks/useSCFetchCategory.js +18 -1
  10. package/lib/cjs/hooks/useSCFetchCourse.js +15 -15
  11. package/lib/cjs/hooks/useSCFetchEvent.d.ts +1 -0
  12. package/lib/cjs/hooks/useSCFetchEvent.js +16 -1
  13. package/lib/cjs/hooks/useSCFetchGroup.d.ts +1 -0
  14. package/lib/cjs/hooks/useSCFetchGroup.js +16 -1
  15. package/lib/cjs/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  16. package/lib/cjs/hooks/useSCFetchPaymentOrder.js +70 -0
  17. package/lib/cjs/hooks/useSCFetchPaymentProduct.d.ts +20 -0
  18. package/lib/cjs/hooks/useSCFetchPaymentProduct.js +70 -0
  19. package/lib/cjs/hooks/useSCFetchUsers.d.ts +23 -0
  20. package/lib/cjs/hooks/useSCFetchUsers.js +74 -0
  21. package/lib/cjs/hooks/useSCJoinedCoursesManager.d.ts +1 -1
  22. package/lib/cjs/hooks/useSCJoinedCoursesManager.js +36 -68
  23. package/lib/cjs/hooks/useSCPaymentsEnabled.d.ts +18 -0
  24. package/lib/cjs/hooks/useSCPaymentsEnabled.js +35 -0
  25. package/lib/cjs/hooks/useSCPreferenceEnabled.d.ts +6 -0
  26. package/lib/cjs/hooks/useSCPreferenceEnabled.js +16 -0
  27. package/lib/cjs/hooks/useSCSubscribedEventsManager.js +4 -14
  28. package/lib/cjs/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
  29. package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +29 -54
  30. package/lib/cjs/hooks/useSCWebPushMessaging.js +2 -2
  31. package/lib/cjs/index.d.ts +7 -2
  32. package/lib/cjs/index.js +13 -2
  33. package/lib/cjs/themes/theme.js +14 -2
  34. package/lib/cjs/types/theme.d.ts +53 -1
  35. package/lib/cjs/utils/hooks/index.d.ts +2 -1
  36. package/lib/cjs/utils/hooks/index.js +3 -1
  37. package/lib/cjs/utils/hooks/useResizeObserver.d.ts +1 -0
  38. package/lib/cjs/utils/hooks/useResizeObserver.js +16 -0
  39. package/lib/cjs/utils/user.d.ts +8 -1
  40. package/lib/cjs/utils/user.js +15 -2
  41. package/lib/esm/components/provider/SCThemeProvider/index.js +1 -1
  42. package/lib/esm/constants/Cache.d.ts +12 -0
  43. package/lib/esm/constants/Cache.js +12 -0
  44. package/lib/esm/constants/Preferences.d.ts +16 -0
  45. package/lib/esm/constants/Preferences.js +28 -0
  46. package/lib/esm/constants/Routes.d.ts +6 -0
  47. package/lib/esm/constants/Routes.js +12 -0
  48. package/lib/esm/hooks/useSCFetchCategory.d.ts +1 -0
  49. package/lib/esm/hooks/useSCFetchCategory.js +18 -1
  50. package/lib/esm/hooks/useSCFetchCourse.js +15 -15
  51. package/lib/esm/hooks/useSCFetchEvent.d.ts +1 -0
  52. package/lib/esm/hooks/useSCFetchEvent.js +16 -1
  53. package/lib/esm/hooks/useSCFetchGroup.d.ts +1 -0
  54. package/lib/esm/hooks/useSCFetchGroup.js +16 -1
  55. package/lib/esm/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  56. package/lib/esm/hooks/useSCFetchPaymentOrder.js +67 -0
  57. package/lib/esm/hooks/useSCFetchPaymentProduct.d.ts +20 -0
  58. package/lib/esm/hooks/useSCFetchPaymentProduct.js +67 -0
  59. package/lib/esm/hooks/useSCFetchUsers.d.ts +23 -0
  60. package/lib/esm/hooks/useSCFetchUsers.js +72 -0
  61. package/lib/esm/hooks/useSCJoinedCoursesManager.d.ts +1 -1
  62. package/lib/esm/hooks/useSCJoinedCoursesManager.js +37 -68
  63. package/lib/esm/hooks/useSCPaymentsEnabled.d.ts +18 -0
  64. package/lib/esm/hooks/useSCPaymentsEnabled.js +31 -0
  65. package/lib/esm/hooks/useSCPreferenceEnabled.d.ts +6 -0
  66. package/lib/esm/hooks/useSCPreferenceEnabled.js +13 -0
  67. package/lib/esm/hooks/useSCSubscribedEventsManager.js +4 -14
  68. package/lib/esm/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
  69. package/lib/esm/hooks/useSCSubscribedGroupsManager.js +29 -54
  70. package/lib/esm/hooks/useSCWebPushMessaging.js +1 -1
  71. package/lib/esm/index.d.ts +7 -2
  72. package/lib/esm/index.js +7 -2
  73. package/lib/esm/themes/theme.js +13 -1
  74. package/lib/esm/types/theme.d.ts +53 -1
  75. package/lib/esm/utils/hooks/index.d.ts +2 -1
  76. package/lib/esm/utils/hooks/index.js +2 -1
  77. package/lib/esm/utils/hooks/useResizeObserver.d.ts +1 -0
  78. package/lib/esm/utils/hooks/useResizeObserver.js +13 -0
  79. package/lib/esm/utils/user.d.ts +8 -1
  80. package/lib/esm/utils/user.js +13 -1
  81. package/lib/umd/440.js +2 -0
  82. package/lib/umd/react-core.js +1 -1
  83. package/package.json +6 -6
  84. package/lib/umd/258.js +0 -2
  85. /package/lib/umd/{258.js.LICENSE.txt → 440.js.LICENSE.txt} +0 -0
@@ -34,21 +34,17 @@ export default function useSCSubscribedEventsManager(user) {
34
34
  CONFIGURATIONS_EVENTS_ENABLED in preferences &&
35
35
  preferences[CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
36
36
  const notificationInvitedToJoinEvent = useRef(null);
37
- const notificationRequestedToJoinEvent = useRef(null);
38
- const notificationAcceptedToJoinEvent = useRef(null);
37
+ // const notificationRequestedToJoinEvent = useRef(null);
38
+ // const notificationAcceptedToJoinEvent = useRef(null);
39
39
  const notificationAddedToEvent = useRef(null);
40
40
  /**
41
41
  * Subscribe to notification types user_follow, user_unfollow
42
42
  */
43
43
  useDeepCompareEffectNoCheck(() => {
44
44
  notificationInvitedToJoinEvent.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT}`, notificationSubscriber);
45
- notificationRequestedToJoinEvent.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT}`, notificationSubscriber);
46
- notificationAcceptedToJoinEvent.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT}`, notificationSubscriber);
47
45
  notificationAddedToEvent.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_ADDED_TO_EVENT}`, notificationSubscriber);
48
46
  return () => {
49
47
  PubSub.unsubscribe(notificationInvitedToJoinEvent.current);
50
- PubSub.unsubscribe(notificationRequestedToJoinEvent.current);
51
- PubSub.unsubscribe(notificationAcceptedToJoinEvent.current);
52
48
  PubSub.unsubscribe(notificationAddedToEvent.current);
53
49
  };
54
50
  }, [data]);
@@ -64,12 +60,6 @@ export default function useSCSubscribedEventsManager(user) {
64
60
  case SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT:
65
61
  _status = SCEventSubscriptionStatusType.INVITED;
66
62
  break;
67
- case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT:
68
- _status = SCEventSubscriptionStatusType.REQUESTED;
69
- break;
70
- case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT:
71
- _status = SCEventSubscriptionStatusType.SUBSCRIBED;
72
- break;
73
63
  case SCNotificationTypologyType.USER_ADDED_TO_EVENT:
74
64
  _status = SCEventSubscriptionStatusType.SUBSCRIBED;
75
65
  break;
@@ -90,8 +80,8 @@ export default function useSCSubscribedEventsManager(user) {
90
80
  // Only if user is authenticated
91
81
  http
92
82
  .request({
93
- url: Endpoints.GetUserEvents.url(),
94
- method: Endpoints.GetUserEvents.method,
83
+ url: Endpoints.GetUserSubscribedEvents.url({ id: user.id }),
84
+ method: Endpoints.GetUserSubscribedEvents.method,
95
85
  })
96
86
  .then((res) => {
97
87
  if (res.status >= 300) {
@@ -30,7 +30,7 @@ export default function useSCSubscribedGroupsManager(user?: SCUserType): {
30
30
  isLoading: (v: number | {
31
31
  id: number;
32
32
  }) => boolean;
33
- subscribe: (group: SCGroupType, userId?: number) => Promise<any>;
33
+ subscribe: (group: SCGroupType) => Promise<any>;
34
34
  unsubscribe: (group: SCGroupType) => Promise<any>;
35
35
  subscriptionStatus: (group: SCGroupType) => string;
36
36
  refresh: () => void;
@@ -34,21 +34,15 @@ export default function useSCSubscribedGroupsManager(user) {
34
34
  CONFIGURATIONS_GROUPS_ENABLED in preferences &&
35
35
  preferences[CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
36
36
  const notificationInvitedToJoinGroup = useRef(null);
37
- const notificationRequestedToJoinGroup = useRef(null);
38
- const notificationAcceptedToJoinGroup = useRef(null);
39
37
  const notificationAddedToGroup = useRef(null);
40
38
  /**
41
39
  * Subscribe to notification types user_follow, user_unfollow
42
40
  */
43
41
  useDeepCompareEffectNoCheck(() => {
44
42
  notificationInvitedToJoinGroup.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP}`, notificationSubscriber);
45
- notificationRequestedToJoinGroup.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP}`, notificationSubscriber);
46
- notificationAcceptedToJoinGroup.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP}`, notificationSubscriber);
47
43
  notificationAddedToGroup.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_ADDED_TO_GROUP}`, notificationSubscriber);
48
44
  return () => {
49
45
  PubSub.unsubscribe(notificationInvitedToJoinGroup.current);
50
- PubSub.unsubscribe(notificationRequestedToJoinGroup.current);
51
- PubSub.unsubscribe(notificationAcceptedToJoinGroup.current);
52
46
  PubSub.unsubscribe(notificationAddedToGroup.current);
53
47
  };
54
48
  }, [data]);
@@ -58,20 +52,20 @@ export default function useSCSubscribedGroupsManager(user) {
58
52
  * @param dataMsg
59
53
  */
60
54
  const notificationSubscriber = (msg, dataMsg) => {
55
+ var _a;
61
56
  if (dataMsg.data.group !== undefined) {
62
57
  let _status;
63
58
  switch (SCNotificationMapping[dataMsg.data.activity_type]) {
64
59
  case SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP:
65
60
  _status = SCGroupSubscriptionStatusType.INVITED;
66
61
  break;
67
- case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP:
68
- _status = SCGroupSubscriptionStatusType.REQUESTED;
69
- break;
70
- case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP:
71
- _status = SCGroupSubscriptionStatusType.SUBSCRIBED;
72
- break;
73
62
  case SCNotificationTypologyType.USER_ADDED_TO_GROUP:
74
- _status = SCGroupSubscriptionStatusType.SUBSCRIBED;
63
+ if (dataMsg.data.notification_obj.group && ((_a = dataMsg.data.notification_obj.group.paywalls) === null || _a === void 0 ? void 0 : _a.length)) {
64
+ _status = SCGroupSubscriptionStatusType.PAYMENT_WAITING;
65
+ }
66
+ else {
67
+ _status = SCGroupSubscriptionStatusType.SUBSCRIBED;
68
+ }
75
69
  break;
76
70
  }
77
71
  updateCache([dataMsg.data.group]);
@@ -90,8 +84,8 @@ export default function useSCSubscribedGroupsManager(user) {
90
84
  // Only if user is authenticated
91
85
  http
92
86
  .request({
93
- url: Endpoints.GetUserGroups.url(),
94
- method: Endpoints.GetUserGroups.method,
87
+ url: Endpoints.GetUserSubscribedGroups.url({ id: user.id }),
88
+ method: Endpoints.GetUserSubscribedGroups.method,
95
89
  })
96
90
  .then((res) => {
97
91
  if (res.status >= 300) {
@@ -112,50 +106,31 @@ export default function useSCSubscribedGroupsManager(user) {
112
106
  * Memoized subscribe Group
113
107
  * Toggle action
114
108
  */
115
- const subscribe = useMemo(() => (group, userId) => {
109
+ const subscribe = useMemo(() => (group) => {
116
110
  setLoading(group.id);
117
- if (userId) {
118
- return http
119
- .request({
120
- url: Endpoints.InviteOrAcceptGroupRequest.url({ id: group.id }),
121
- method: Endpoints.InviteOrAcceptGroupRequest.method,
122
- data: { users: [userId] },
123
- })
124
- .then((res) => {
125
- if (res.status >= 300) {
126
- return Promise.reject(res);
127
- }
128
- updateCache([group.id]);
129
- setData((prev) => getDataUpdated(prev, group.id, SCGroupSubscriptionStatusType.SUBSCRIBED));
130
- setUnLoading(group.id);
131
- return Promise.resolve(res.data);
132
- });
133
- }
134
- else {
135
- return http
136
- .request({
137
- url: Endpoints.SubscribeToGroup.url({ id: group.id }),
138
- method: Endpoints.SubscribeToGroup.method,
139
- })
140
- .then((res) => {
141
- if (res.status >= 300) {
142
- return Promise.reject(res);
143
- }
144
- updateCache([group.id]);
145
- setData((prev) => getDataUpdated(prev, group.id, group.privacy === SCGroupPrivacyType.PRIVATE && group.subscription_status !== SCGroupSubscriptionStatusType.INVITED
146
- ? SCGroupSubscriptionStatusType.REQUESTED
147
- : SCGroupSubscriptionStatusType.SUBSCRIBED));
148
- setUnLoading(group.id);
149
- return Promise.resolve(res.data);
150
- });
151
- }
111
+ return http
112
+ .request({
113
+ url: Endpoints.SubscribeToGroup.url({ id: group.id }),
114
+ method: Endpoints.SubscribeToGroup.method,
115
+ })
116
+ .then((res) => {
117
+ if (res.status >= 300) {
118
+ return Promise.reject(res);
119
+ }
120
+ updateCache([group.id]);
121
+ setData((prev) => getDataUpdated(prev, group.id, group.privacy === SCGroupPrivacyType.PRIVATE && group.subscription_status !== SCGroupSubscriptionStatusType.INVITED
122
+ ? SCGroupSubscriptionStatusType.REQUESTED
123
+ : SCGroupSubscriptionStatusType.SUBSCRIBED));
124
+ setUnLoading(group.id);
125
+ return Promise.resolve(res.data);
126
+ });
152
127
  }, [data, loading, cache]);
153
128
  /**
154
129
  * Memoized subscribe Group
155
130
  * Toggle action
156
131
  */
157
132
  const unsubscribe = useMemo(() => (group) => {
158
- if (group.subscription_status !== SCGroupSubscriptionStatusType.REQUESTED) {
133
+ if (data[group.id] !== SCGroupSubscriptionStatusType.REQUESTED) {
159
134
  setLoading(group.id);
160
135
  return http
161
136
  .request({
@@ -248,7 +223,7 @@ export default function useSCSubscribedGroupsManager(user) {
248
223
  if (cache.includes(group.id)) {
249
224
  return getCurrentGroupCacheStatus(group);
250
225
  }
251
- if (authUserId) {
226
+ if (authUserId && group) {
252
227
  if ('subscription_status' in group) {
253
228
  return getSubscriptionStatus(group);
254
229
  }
@@ -257,7 +232,7 @@ export default function useSCSubscribedGroupsManager(user) {
257
232
  }
258
233
  }
259
234
  return null;
260
- }, [loading, cache, authUserId]);
235
+ }, [loading, cache, authUserId, getSubscriptionStatus, getCurrentGroupCacheStatus]);
261
236
  /**
262
237
  * Empty cache on logout
263
238
  */
@@ -3,7 +3,7 @@ import { useContext, useEffect, useRef, useState } from 'react';
3
3
  import { useSCContext } from '../components/provider/SCContextProvider';
4
4
  import { useSCUser } from '../components/provider/SCUserProvider';
5
5
  import { Logger } from '@selfcommunity/utils';
6
- import Button from '@mui/material/Button';
6
+ import { Button } from '@mui/material';
7
7
  import { loadVersionBrowser, urlB64ToUint8Array } from '@selfcommunity/utils';
8
8
  import { SCOPE_SC_CORE } from '../constants/Errors';
9
9
  import { http, Endpoints } from '@selfcommunity/api-services';
@@ -42,6 +42,7 @@ import * as SCCache from './constants/Cache';
42
42
  * Custom Hooks
43
43
  */
44
44
  import useSCFetchUser from './hooks/useSCFetchUser';
45
+ import useSCFetchUsers from './hooks/useSCFetchUsers';
45
46
  import useSCFetchUserProviders from './hooks/useSCFetchUserProviders';
46
47
  import useSCFetchVote from './hooks/useSCFetchVote';
47
48
  import useSCFetchFeedObject from './hooks/useSCFetchFeedObject';
@@ -71,6 +72,10 @@ import useSCGoogleApiLoader from './hooks/useSCGoogleApiLoader';
71
72
  import useSCFetchCourse from './hooks/useSCFetchCourse';
72
73
  import useSCFetchCourses from './hooks/useSCFetchCourses';
73
74
  import useSCFetchLesson from './hooks/useSCFetchLesson';
75
+ import useSCPaymentsEnabled from './hooks/useSCPaymentsEnabled';
76
+ import useSCFetchPaymentProduct from './hooks/useSCFetchPaymentProduct';
77
+ import useSCFetchPaymentOrder from './hooks/useSCFetchPaymentOrder';
78
+ import useSCPreferenceEnabled from './hooks/useSCPreferenceEnabled';
74
79
  /**
75
80
  * Routing component
76
81
  */
@@ -82,7 +87,7 @@ import * as SCRoutes from './constants/Routes';
82
87
  */
83
88
  import * as UserUtils from './utils/user';
84
89
  import getTheme from './themes/theme';
85
- import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility } from './utils/hooks';
90
+ import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver } from './utils/hooks';
86
91
  import { getEventStatus } from './utils/event';
87
92
  /**
88
93
  * Constants:
@@ -93,4 +98,4 @@ import * as Preferences from './constants/Preferences';
93
98
  /**
94
99
  * List all exports
95
100
  */
96
- export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType, SCJoinedCoursesManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, };
101
+ export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType, SCJoinedCoursesManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUsers, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, useSCFetchPaymentOrder, useSCPreferenceEnabled, };
package/lib/esm/index.js CHANGED
@@ -38,6 +38,7 @@ import * as SCCache from './constants/Cache';
38
38
  * Custom Hooks
39
39
  */
40
40
  import useSCFetchUser from './hooks/useSCFetchUser';
41
+ import useSCFetchUsers from './hooks/useSCFetchUsers';
41
42
  import useSCFetchUserProviders from './hooks/useSCFetchUserProviders';
42
43
  import useSCFetchVote from './hooks/useSCFetchVote';
43
44
  import useSCFetchFeedObject from './hooks/useSCFetchFeedObject';
@@ -67,6 +68,10 @@ import useSCGoogleApiLoader from './hooks/useSCGoogleApiLoader';
67
68
  import useSCFetchCourse from './hooks/useSCFetchCourse';
68
69
  import useSCFetchCourses from './hooks/useSCFetchCourses';
69
70
  import useSCFetchLesson from './hooks/useSCFetchLesson';
71
+ import useSCPaymentsEnabled from './hooks/useSCPaymentsEnabled';
72
+ import useSCFetchPaymentProduct from './hooks/useSCFetchPaymentProduct';
73
+ import useSCFetchPaymentOrder from './hooks/useSCFetchPaymentOrder';
74
+ import useSCPreferenceEnabled from './hooks/useSCPreferenceEnabled';
70
75
  /**
71
76
  * Routing component
72
77
  */
@@ -78,7 +83,7 @@ import * as SCRoutes from './constants/Routes';
78
83
  */
79
84
  import * as UserUtils from './utils/user';
80
85
  import getTheme from './themes/theme';
81
- import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, } from './utils/hooks';
86
+ import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, } from './utils/hooks';
82
87
  import { getEventStatus } from './utils/event';
83
88
  /**
84
89
  * Constants:
@@ -89,4 +94,4 @@ import * as Preferences from './constants/Preferences';
89
94
  /**
90
95
  * List all exports
91
96
  */
92
- export { SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, };
97
+ export { SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUsers, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, useSCFetchPaymentOrder, useSCPreferenceEnabled, };
@@ -1,4 +1,4 @@
1
- import createTheme from '@mui/material/styles/createTheme';
1
+ import { createTheme } from '@mui/material';
2
2
  import { mergeDeep } from '@selfcommunity/utils';
3
3
  import validateColor from 'validate-color';
4
4
  import { COLORS_COLORBACK, COLORS_COLORPRIMARY, COLORS_COLORSECONDARY, COLORS_COLORFONT, COLORS_COLORFONTSECONDARY, COLORS_NAVBARBACK, STYLE_FONT_FAMILY, } from '../constants/Preferences';
@@ -48,6 +48,18 @@ const getTheme = (options, preferences) => {
48
48
  sizeXLarge: 120,
49
49
  },
50
50
  },
51
+ contentProduct: {
52
+ icon: {
53
+ sizeSmall: 24,
54
+ sizeMedium: 40,
55
+ },
56
+ },
57
+ contentProductPrice: {
58
+ icon: {
59
+ sizeSmall: 24,
60
+ sizeMedium: 40,
61
+ },
62
+ },
51
63
  };
52
64
  const defaultOptions = preferences
53
65
  ? {
@@ -1,4 +1,4 @@
1
- import { Theme as MuiTheme } from '@mui/material/styles/createTheme';
1
+ import { Theme as MuiTheme } from '@mui/material';
2
2
  /**
3
3
  * Interface SCThemeAvatarVariableType
4
4
  */
@@ -55,6 +55,32 @@ export interface SCThemeCategoryIconVariableType {
55
55
  */
56
56
  sizeLarge: number;
57
57
  }
58
+ /**
59
+ * Interface SCThemeContentProductIconVariableType
60
+ */
61
+ export interface SCThemeContentProductIconVariableType {
62
+ /**
63
+ * ContentProduct size small
64
+ */
65
+ sizeSmall: number;
66
+ /**
67
+ * ContentProduct size medium
68
+ */
69
+ sizeMedium: number;
70
+ }
71
+ /**
72
+ * Interface SCThemeContentProductPriceIconVariableType
73
+ */
74
+ export interface SCThemeContentProductPriceIconVariableType {
75
+ /**
76
+ * ContentProductPrice size small
77
+ */
78
+ sizeSmall: number;
79
+ /**
80
+ * ContentProductPrice size medium
81
+ */
82
+ sizeMedium: number;
83
+ }
58
84
  /**
59
85
  * Interface SCThemeCategoryVariableType
60
86
  */
@@ -64,6 +90,24 @@ export interface SCThemeCategoryVariableType {
64
90
  */
65
91
  icon: SCThemeCategoryIconVariableType;
66
92
  }
93
+ /**
94
+ * Interface SCThemeContentProductVariableType
95
+ */
96
+ export interface SCThemeContentProductVariableType {
97
+ /**
98
+ * ContentProduct icon size
99
+ */
100
+ icon: SCThemeContentProductIconVariableType;
101
+ }
102
+ /**
103
+ * Interface SCThemeContentProductPriceVariableType
104
+ */
105
+ export interface SCThemeContentProductPriceVariableType {
106
+ /**
107
+ * ContentProductPrice icon size
108
+ */
109
+ icon: SCThemeContentProductPriceIconVariableType;
110
+ }
67
111
  /**
68
112
  * Interface SCThemeVariablesType
69
113
  */
@@ -80,6 +124,14 @@ export interface SCThemeVariablesType {
80
124
  * Group
81
125
  */
82
126
  group: SCThemeGroupVariableType;
127
+ /**
128
+ * ContentProduct
129
+ */
130
+ contentProduct: SCThemeContentProductVariableType;
131
+ /**
132
+ * ContentProductPrice
133
+ */
134
+ contentProductPrice: SCThemeContentProductPriceVariableType;
83
135
  }
84
136
  export interface SCThemeType extends MuiTheme {
85
137
  /**
@@ -4,4 +4,5 @@ import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';
4
4
  import useEffectOnce from './useEffectOnce';
5
5
  import useNoInitialEffect from './useNoInitialEffect';
6
6
  import usePageVisibility from './usePageVisibility';
7
- export { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility };
7
+ import useResizeObserver from './useResizeObserver';
8
+ export { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, };
@@ -4,4 +4,5 @@ import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';
4
4
  import useEffectOnce from './useEffectOnce';
5
5
  import useNoInitialEffect from './useNoInitialEffect';
6
6
  import usePageVisibility from './usePageVisibility';
7
- export { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility };
7
+ import useResizeObserver from './useResizeObserver';
8
+ export { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, };
@@ -0,0 +1 @@
1
+ export default function useResizeObserver(element: Element | null, options: ResizeObserverOptions | undefined, observerCallback: ResizeObserverCallback): void;
@@ -0,0 +1,13 @@
1
+ import { useEffect } from 'react';
2
+ export default function useResizeObserver(element, options, observerCallback) {
3
+ useEffect(() => {
4
+ if (!element || !('ResizeObserver' in window)) {
5
+ return undefined;
6
+ }
7
+ const observer = new ResizeObserver(observerCallback);
8
+ observer.observe(element, options);
9
+ return () => {
10
+ observer.disconnect();
11
+ };
12
+ }, [element, options, observerCallback]);
13
+ }
@@ -6,6 +6,7 @@ import { SCUserType } from '@selfcommunity/types';
6
6
  export declare const ADMIN_ROLE = "admin";
7
7
  export declare const MODERATOR_ROLE = "moderator";
8
8
  export declare const EDITOR_ROLE = "editor";
9
+ export declare const PUBLISHER_ROLE = "publisher";
9
10
  export declare const COMMUNITY_CREATOR = 1;
10
11
  /**
11
12
  * Get user role from roles(set)
@@ -38,7 +39,13 @@ export declare function isModerator(user: SCUserType): boolean;
38
39
  */
39
40
  export declare function isEditor(user: SCUserType): boolean;
40
41
  /**
41
- * Check if user is admin or moderator
42
+ * Check if user is publisher
43
+ * @param user
44
+ * @returns boolean
45
+ */
46
+ export declare function isPublisher(user: SCUserType): boolean;
47
+ /**
48
+ * Check if user is admin, moderator, editor or publisher
42
49
  * @param user
43
50
  * @returns boolean
44
51
  */
@@ -6,6 +6,7 @@ import { SCUserStatus } from '@selfcommunity/types';
6
6
  export const ADMIN_ROLE = 'admin';
7
7
  export const MODERATOR_ROLE = 'moderator';
8
8
  export const EDITOR_ROLE = 'editor';
9
+ export const PUBLISHER_ROLE = 'publisher';
9
10
  export const COMMUNITY_CREATOR = 1;
10
11
  /**
11
12
  * Get user role from roles(set)
@@ -24,6 +25,9 @@ export function getUserRole(user) {
24
25
  else if (role === EDITOR_ROLE) {
25
26
  return EDITOR_ROLE;
26
27
  }
28
+ else if (role === PUBLISHER_ROLE) {
29
+ return PUBLISHER_ROLE;
30
+ }
27
31
  }
28
32
  return null;
29
33
  }
@@ -60,7 +64,15 @@ export function isEditor(user) {
60
64
  return getUserRole(user) === EDITOR_ROLE;
61
65
  }
62
66
  /**
63
- * Check if user is admin or moderator
67
+ * Check if user is publisher
68
+ * @param user
69
+ * @returns boolean
70
+ */
71
+ export function isPublisher(user) {
72
+ return getUserRole(user) === PUBLISHER_ROLE;
73
+ }
74
+ /**
75
+ * Check if user is admin, moderator, editor or publisher
64
76
  * @param user
65
77
  * @returns boolean
66
78
  */