@selfcommunity/react-core 0.6.7-payments.181 → 0.6.7-payments.183

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 (32) hide show
  1. package/lib/cjs/constants/Cache.d.ts +4 -1
  2. package/lib/cjs/constants/Cache.js +6 -2
  3. package/lib/cjs/constants/Routes.d.ts +1 -0
  4. package/lib/cjs/constants/Routes.js +4 -2
  5. package/lib/cjs/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  6. package/lib/cjs/hooks/useSCFetchPaymentOrder.js +70 -0
  7. package/lib/cjs/hooks/useSCJoinedCoursesManager.js +8 -8
  8. package/lib/cjs/hooks/useSCSubscribedEventsManager.js +13 -6
  9. package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +8 -8
  10. package/lib/cjs/index.d.ts +3 -2
  11. package/lib/cjs/index.js +4 -1
  12. package/lib/cjs/utils/hooks/index.d.ts +2 -1
  13. package/lib/cjs/utils/hooks/index.js +3 -1
  14. package/lib/cjs/utils/hooks/useResizeObserver.d.ts +1 -0
  15. package/lib/cjs/utils/hooks/useResizeObserver.js +16 -0
  16. package/lib/esm/constants/Cache.d.ts +4 -1
  17. package/lib/esm/constants/Cache.js +4 -1
  18. package/lib/esm/constants/Routes.d.ts +1 -0
  19. package/lib/esm/constants/Routes.js +2 -0
  20. package/lib/esm/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  21. package/lib/esm/hooks/useSCFetchPaymentOrder.js +67 -0
  22. package/lib/esm/hooks/useSCJoinedCoursesManager.js +7 -7
  23. package/lib/esm/hooks/useSCSubscribedEventsManager.js +14 -7
  24. package/lib/esm/hooks/useSCSubscribedGroupsManager.js +7 -7
  25. package/lib/esm/index.d.ts +3 -2
  26. package/lib/esm/index.js +3 -2
  27. package/lib/esm/utils/hooks/index.d.ts +2 -1
  28. package/lib/esm/utils/hooks/index.js +2 -1
  29. package/lib/esm/utils/hooks/useResizeObserver.d.ts +1 -0
  30. package/lib/esm/utils/hooks/useResizeObserver.js +13 -0
  31. package/lib/umd/react-core.js +1 -1
  32. package/package.json +5 -5
@@ -1,8 +1,8 @@
1
1
  import { Endpoints, http } from '@selfcommunity/api-services';
2
2
  import { SCEventSubscriptionStatusType, SCFeatureName, SCNotificationTopicType, SCNotificationTypologyType, } from '@selfcommunity/types';
3
- import { Logger } from '@selfcommunity/utils';
3
+ import { isClientSideRendering, Logger } from '@selfcommunity/utils';
4
4
  import PubSub from 'pubsub-js';
5
- import { useEffect, useMemo, useRef } from 'react';
5
+ import { useContext, useEffect, useMemo, useRef } from 'react';
6
6
  import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
7
7
  import { useSCPreferences } from '../components/provider/SCPreferencesProvider';
8
8
  import { SCOPE_SC_CORE } from '../constants/Errors';
@@ -10,6 +10,8 @@ import { SCNotificationMapping } from '../constants/Notification';
10
10
  import { CONFIGURATIONS_EVENTS_ENABLED } from '../constants/Preferences';
11
11
  import { getEventStatus } from '../utils/event';
12
12
  import useSCCachingManager from './useSCCachingManager';
13
+ import { SCRoutingContext } from '../components/provider/SCRoutingProvider';
14
+ import * as SCRoutes from '../constants/Routes';
13
15
  /**
14
16
  :::info
15
17
  This custom hook is used to manage the events followed.
@@ -27,6 +29,7 @@ import useSCCachingManager from './useSCCachingManager';
27
29
  export default function useSCSubscribedEventsManager(user) {
28
30
  const { cache, updateCache, emptyCache, data, setData, loading, setLoading, setUnLoading, isLoading } = useSCCachingManager();
29
31
  const { preferences, features } = useSCPreferences();
32
+ const scRoutingContext = useContext(SCRoutingContext);
30
33
  const authUserId = user ? user.id : null;
31
34
  const eventsEnabled = useMemo(() => preferences &&
32
35
  features &&
@@ -63,13 +66,17 @@ export default function useSCSubscribedEventsManager(user) {
63
66
  switch (SCNotificationMapping[dataMsg.data.activity_type]) {
64
67
  case SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT:
65
68
  _status = SCEventSubscriptionStatusType.INVITED;
69
+ if (isClientSideRendering() &&
70
+ window.document.location.href.indexOf(scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, dataMsg.data.notification_obj.event)) > -1) {
71
+ checkEventSubscriptionStatus(dataMsg.data.notification_obj.event);
72
+ }
66
73
  break;
67
- case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT:
68
- _status = SCEventSubscriptionStatusType.REQUESTED;
69
- break;
74
+ /* case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT:
75
+ _status = SCEventSubscriptionStatusType.REQUESTED;
76
+ break;
70
77
  case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT:
71
- _status = SCEventSubscriptionStatusType.SUBSCRIBED;
72
- break;
78
+ _status = SCEventSubscriptionStatusType.SUBSCRIBED;
79
+ break; */
73
80
  case SCNotificationTypologyType.USER_ADDED_TO_EVENT:
74
81
  _status = SCEventSubscriptionStatusType.SUBSCRIBED;
75
82
  break;
@@ -64,12 +64,12 @@ export default function useSCSubscribedGroupsManager(user) {
64
64
  case SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP:
65
65
  _status = SCGroupSubscriptionStatusType.INVITED;
66
66
  break;
67
- case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP:
68
- _status = SCGroupSubscriptionStatusType.REQUESTED;
69
- break;
67
+ /* case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP:
68
+ _status = SCGroupSubscriptionStatusType.REQUESTED;
69
+ break;
70
70
  case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP:
71
- _status = SCGroupSubscriptionStatusType.SUBSCRIBED;
72
- break;
71
+ _status = SCGroupSubscriptionStatusType.SUBSCRIBED;
72
+ break; */
73
73
  case SCNotificationTypologyType.USER_ADDED_TO_GROUP:
74
74
  _status = SCGroupSubscriptionStatusType.SUBSCRIBED;
75
75
  break;
@@ -248,7 +248,7 @@ export default function useSCSubscribedGroupsManager(user) {
248
248
  if (cache.includes(group.id)) {
249
249
  return getCurrentGroupCacheStatus(group);
250
250
  }
251
- if (authUserId) {
251
+ if (authUserId && group) {
252
252
  if ('subscription_status' in group) {
253
253
  return getSubscriptionStatus(group);
254
254
  }
@@ -257,7 +257,7 @@ export default function useSCSubscribedGroupsManager(user) {
257
257
  }
258
258
  }
259
259
  return null;
260
- }, [loading, cache, authUserId]);
260
+ }, [loading, cache, authUserId, getSubscriptionStatus, getCurrentGroupCacheStatus]);
261
261
  /**
262
262
  * Empty cache on logout
263
263
  */
@@ -73,6 +73,7 @@ import useSCFetchCourses from './hooks/useSCFetchCourses';
73
73
  import useSCFetchLesson from './hooks/useSCFetchLesson';
74
74
  import useSCPaymentsEnabled from './hooks/useSCPaymentsEnabled';
75
75
  import useSCFetchPaymentProduct from './hooks/useSCFetchPaymentProduct';
76
+ import useSCFetchPaymentOrder from './hooks/useSCFetchPaymentOrder';
76
77
  /**
77
78
  * Routing component
78
79
  */
@@ -84,7 +85,7 @@ import * as SCRoutes from './constants/Routes';
84
85
  */
85
86
  import * as UserUtils from './utils/user';
86
87
  import getTheme from './themes/theme';
87
- import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility } from './utils/hooks';
88
+ import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver } from './utils/hooks';
88
89
  import { getEventStatus } from './utils/event';
89
90
  /**
90
91
  * Constants:
@@ -95,4 +96,4 @@ import * as Preferences from './constants/Preferences';
95
96
  /**
96
97
  * List all exports
97
98
  */
98
- 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, useSCPaymentsEnabled, useSCFetchPaymentProduct, };
99
+ 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, useResizeObserver, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, useSCFetchPaymentOrder, };
package/lib/esm/index.js CHANGED
@@ -69,6 +69,7 @@ import useSCFetchCourses from './hooks/useSCFetchCourses';
69
69
  import useSCFetchLesson from './hooks/useSCFetchLesson';
70
70
  import useSCPaymentsEnabled from './hooks/useSCPaymentsEnabled';
71
71
  import useSCFetchPaymentProduct from './hooks/useSCFetchPaymentProduct';
72
+ import useSCFetchPaymentOrder from './hooks/useSCFetchPaymentOrder';
72
73
  /**
73
74
  * Routing component
74
75
  */
@@ -80,7 +81,7 @@ import * as SCRoutes from './constants/Routes';
80
81
  */
81
82
  import * as UserUtils from './utils/user';
82
83
  import getTheme from './themes/theme';
83
- import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, } from './utils/hooks';
84
+ import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver } from './utils/hooks';
84
85
  import { getEventStatus } from './utils/event';
85
86
  /**
86
87
  * Constants:
@@ -91,4 +92,4 @@ import * as Preferences from './constants/Preferences';
91
92
  /**
92
93
  * List all exports
93
94
  */
94
- 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, useSCPaymentsEnabled, useSCFetchPaymentProduct, };
95
+ 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, useResizeObserver, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, useSCFetchPaymentOrder, };
@@ -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
+ }