@selfcommunity/react-core 0.7.0-alpha.2 → 0.7.0-alpha.3

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 (73) hide show
  1. package/lib/cjs/constants/Cache.d.ts +6 -0
  2. package/lib/cjs/constants/Cache.js +9 -1
  3. package/lib/cjs/constants/Preferences.d.ts +14 -0
  4. package/lib/cjs/constants/Preferences.js +25 -2
  5. package/lib/cjs/constants/Routes.d.ts +6 -0
  6. package/lib/cjs/constants/Routes.js +14 -1
  7. package/lib/cjs/hooks/useSCFetchCategory.d.ts +1 -0
  8. package/lib/cjs/hooks/useSCFetchCategory.js +18 -1
  9. package/lib/cjs/hooks/useSCFetchCourse.js +15 -15
  10. package/lib/cjs/hooks/useSCFetchEvent.d.ts +1 -0
  11. package/lib/cjs/hooks/useSCFetchEvent.js +16 -1
  12. package/lib/cjs/hooks/useSCFetchGroup.d.ts +1 -0
  13. package/lib/cjs/hooks/useSCFetchGroup.js +16 -1
  14. package/lib/cjs/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  15. package/lib/cjs/hooks/useSCFetchPaymentOrder.js +70 -0
  16. package/lib/cjs/hooks/useSCFetchPaymentProduct.d.ts +20 -0
  17. package/lib/cjs/hooks/useSCFetchPaymentProduct.js +70 -0
  18. package/lib/cjs/hooks/useSCJoinedCoursesManager.d.ts +1 -1
  19. package/lib/cjs/hooks/useSCJoinedCoursesManager.js +36 -67
  20. package/lib/cjs/hooks/useSCPaymentsEnabled.d.ts +18 -0
  21. package/lib/cjs/hooks/useSCPaymentsEnabled.js +35 -0
  22. package/lib/cjs/hooks/useSCSubscribedEventsManager.js +4 -14
  23. package/lib/cjs/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
  24. package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +29 -54
  25. package/lib/cjs/index.d.ts +5 -2
  26. package/lib/cjs/index.js +8 -1
  27. package/lib/cjs/themes/theme.js +12 -0
  28. package/lib/cjs/types/theme.d.ts +52 -0
  29. package/lib/cjs/utils/hooks/index.d.ts +2 -1
  30. package/lib/cjs/utils/hooks/index.js +3 -1
  31. package/lib/cjs/utils/hooks/useResizeObserver.d.ts +1 -0
  32. package/lib/cjs/utils/hooks/useResizeObserver.js +16 -0
  33. package/lib/cjs/utils/user.d.ts +8 -1
  34. package/lib/cjs/utils/user.js +15 -2
  35. package/lib/esm/constants/Cache.d.ts +6 -0
  36. package/lib/esm/constants/Cache.js +6 -0
  37. package/lib/esm/constants/Preferences.d.ts +14 -0
  38. package/lib/esm/constants/Preferences.js +22 -0
  39. package/lib/esm/constants/Routes.d.ts +6 -0
  40. package/lib/esm/constants/Routes.js +12 -0
  41. package/lib/esm/hooks/useSCFetchCategory.d.ts +1 -0
  42. package/lib/esm/hooks/useSCFetchCategory.js +18 -1
  43. package/lib/esm/hooks/useSCFetchCourse.js +15 -15
  44. package/lib/esm/hooks/useSCFetchEvent.d.ts +1 -0
  45. package/lib/esm/hooks/useSCFetchEvent.js +16 -1
  46. package/lib/esm/hooks/useSCFetchGroup.d.ts +1 -0
  47. package/lib/esm/hooks/useSCFetchGroup.js +16 -1
  48. package/lib/esm/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  49. package/lib/esm/hooks/useSCFetchPaymentOrder.js +67 -0
  50. package/lib/esm/hooks/useSCFetchPaymentProduct.d.ts +20 -0
  51. package/lib/esm/hooks/useSCFetchPaymentProduct.js +67 -0
  52. package/lib/esm/hooks/useSCJoinedCoursesManager.d.ts +1 -1
  53. package/lib/esm/hooks/useSCJoinedCoursesManager.js +37 -67
  54. package/lib/esm/hooks/useSCPaymentsEnabled.d.ts +18 -0
  55. package/lib/esm/hooks/useSCPaymentsEnabled.js +31 -0
  56. package/lib/esm/hooks/useSCSubscribedEventsManager.js +4 -14
  57. package/lib/esm/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
  58. package/lib/esm/hooks/useSCSubscribedGroupsManager.js +29 -54
  59. package/lib/esm/index.d.ts +5 -2
  60. package/lib/esm/index.js +5 -2
  61. package/lib/esm/themes/theme.js +12 -0
  62. package/lib/esm/types/theme.d.ts +52 -0
  63. package/lib/esm/utils/hooks/index.d.ts +2 -1
  64. package/lib/esm/utils/hooks/index.js +2 -1
  65. package/lib/esm/utils/hooks/useResizeObserver.d.ts +1 -0
  66. package/lib/esm/utils/hooks/useResizeObserver.js +13 -0
  67. package/lib/esm/utils/user.d.ts +8 -1
  68. package/lib/esm/utils/user.js +13 -1
  69. package/lib/umd/440.js +2 -0
  70. package/lib/umd/react-core.js +1 -1
  71. package/package.json +6 -6
  72. package/lib/umd/258.js +0 -2
  73. /package/lib/umd/{258.js.LICENSE.txt → 440.js.LICENSE.txt} +0 -0
@@ -36,21 +36,15 @@ function useSCJoinedCoursesManager(user) {
36
36
  Preferences_1.CONFIGURATIONS_COURSES_ENABLED in preferences &&
37
37
  preferences[Preferences_1.CONFIGURATIONS_COURSES_ENABLED].value, [preferences, features]);
38
38
  const notificationInvitedToJoinCourse = (0, react_1.useRef)(null);
39
- const notificationRequestedToJoinCourse = (0, react_1.useRef)(null);
40
- const notificationAcceptedToJoinCourse = (0, react_1.useRef)(null);
41
39
  const notificationAddedToCourse = (0, react_1.useRef)(null);
42
40
  /**
43
41
  * Subscribe to notification types user_follow, user_unfollow
44
42
  */
45
43
  (0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
46
44
  notificationInvitedToJoinCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_COURSE}`, notificationSubscriber);
47
- notificationRequestedToJoinCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE}`, notificationSubscriber);
48
- notificationAcceptedToJoinCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_COURSE}`, notificationSubscriber);
49
45
  notificationAddedToCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ADDED_TO_COURSE}`, notificationSubscriber);
50
46
  return () => {
51
47
  pubsub_js_1.default.unsubscribe(notificationInvitedToJoinCourse.current);
52
- pubsub_js_1.default.unsubscribe(notificationRequestedToJoinCourse.current);
53
- pubsub_js_1.default.unsubscribe(notificationAcceptedToJoinCourse.current);
54
48
  pubsub_js_1.default.unsubscribe(notificationAddedToCourse.current);
55
49
  };
56
50
  }, [data]);
@@ -60,20 +54,20 @@ function useSCJoinedCoursesManager(user) {
60
54
  * @param dataMsg
61
55
  */
62
56
  const notificationSubscriber = (msg, dataMsg) => {
57
+ var _a;
63
58
  if (dataMsg.data.course !== undefined) {
64
59
  let _status;
65
60
  switch (Notification_1.SCNotificationMapping[dataMsg.data.activity_type]) {
66
61
  case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_COURSE:
67
62
  _status = types_1.SCCourseJoinStatusType.INVITED;
68
63
  break;
69
- case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
70
- _status = types_1.SCCourseJoinStatusType.REQUESTED;
71
- break;
72
- case types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_COURSE:
73
- _status = types_1.SCCourseJoinStatusType.JOINED;
74
- break;
75
64
  case types_1.SCNotificationTypologyType.USER_ADDED_TO_COURSE:
76
- _status = types_1.SCCourseJoinStatusType.JOINED;
65
+ if (dataMsg.data.notification_obj.course && ((_a = dataMsg.data.notification_obj.course.paywalls) === null || _a === void 0 ? void 0 : _a.length)) {
66
+ _status = types_1.SCCourseJoinStatusType.PAYMENT_WAITING;
67
+ }
68
+ else {
69
+ _status = types_1.SCCourseJoinStatusType.JOINED;
70
+ }
77
71
  break;
78
72
  }
79
73
  updateCache([dataMsg.data.course]);
@@ -92,8 +86,8 @@ function useSCJoinedCoursesManager(user) {
92
86
  // Only if user is authenticated
93
87
  api_services_1.http
94
88
  .request({
95
- url: api_services_1.Endpoints.GetJoinedCourses.url(),
96
- method: api_services_1.Endpoints.GetJoinedCourses.method,
89
+ url: api_services_1.Endpoints.GetUserJoinedCourses.url({ id: user.id }),
90
+ method: api_services_1.Endpoints.GetUserJoinedCourses.method,
97
91
  })
98
92
  .then((res) => {
99
93
  if (res.status >= 300) {
@@ -114,67 +108,42 @@ function useSCJoinedCoursesManager(user) {
114
108
  * Memoized join Course
115
109
  * Toggle action
116
110
  */
117
- const join = (0, react_1.useMemo)(() => (course, userId) => {
111
+ const join = (0, react_1.useMemo)(() => (course) => tslib_1.__awaiter(this, void 0, void 0, function* () {
118
112
  setLoading(course.id);
119
- if (userId) {
120
- return api_services_1.http
121
- .request({
122
- url: api_services_1.Endpoints.InviteOrAcceptUsersToCourse.url({ id: course.id }),
123
- method: api_services_1.Endpoints.InviteOrAcceptUsersToCourse.method,
124
- data: { users: [userId] },
125
- })
126
- .then((res) => {
127
- if (res.status >= 300) {
128
- return Promise.reject(res);
129
- }
130
- updateCache([course.id]);
131
- setData((prev) => getDataUpdated(prev, course.id, types_1.SCCourseJoinStatusType.JOINED));
132
- setUnLoading(course.id);
133
- return Promise.resolve(res.data);
134
- });
135
- }
136
- else {
137
- return api_services_1.http
138
- .request({
139
- url: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.url({ id: course.id }),
140
- method: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.method,
141
- })
142
- .then((res) => {
143
- if (res.status >= 300) {
144
- return Promise.reject(res);
145
- }
146
- updateCache([course.id]);
147
- setData((prev) => getDataUpdated(prev, course.id, course.privacy === types_1.SCCoursePrivacyType.PRIVATE && course.join_status !== types_1.SCCourseJoinStatusType.INVITED
148
- ? types_1.SCCourseJoinStatusType.REQUESTED
149
- : types_1.SCCourseJoinStatusType.JOINED));
150
- setUnLoading(course.id);
151
- return Promise.resolve(res.data);
152
- });
113
+ const res = yield api_services_1.http.request({
114
+ url: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.url({ id: course.id }),
115
+ method: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.method,
116
+ });
117
+ if (res.status >= 300) {
118
+ return Promise.reject(res);
153
119
  }
154
- }, [data, loading, cache]);
120
+ updateCache([course.id]);
121
+ setData((prev) => getDataUpdated(prev, course.id, course.privacy === types_1.SCCoursePrivacyType.PRIVATE && course.join_status !== types_1.SCCourseJoinStatusType.INVITED
122
+ ? types_1.SCCourseJoinStatusType.REQUESTED
123
+ : types_1.SCCourseJoinStatusType.JOINED));
124
+ setUnLoading(course.id);
125
+ return yield Promise.resolve(res.data);
126
+ }), [data, loading, cache]);
155
127
  /**
156
128
  * Memoized leave Course
157
129
  * Toggle action
158
130
  */
159
- const leave = (0, react_1.useMemo)(() => (course) => {
160
- if (course.join_status !== types_1.SCCourseJoinStatusType.REQUESTED) {
131
+ const leave = (0, react_1.useMemo)(() => (course) => tslib_1.__awaiter(this, void 0, void 0, function* () {
132
+ if (data[course.id] !== types_1.SCCourseJoinStatusType.REQUESTED) {
161
133
  setLoading(course.id);
162
- return api_services_1.http
163
- .request({
134
+ const res = yield api_services_1.http.request({
164
135
  url: api_services_1.Endpoints.LeaveOrRemoveCourseRequest.url({ id: course.id }),
165
136
  method: api_services_1.Endpoints.LeaveOrRemoveCourseRequest.method,
166
- })
167
- .then((res) => {
168
- if (res.status >= 300) {
169
- return Promise.reject(res);
170
- }
171
- updateCache([course.id]);
172
- setData((prev) => getDataUpdated(prev, course.id, null));
173
- setUnLoading(course.id);
174
- return Promise.resolve(res.data);
175
137
  });
138
+ if (res.status >= 300) {
139
+ return Promise.reject(res);
140
+ }
141
+ updateCache([course.id]);
142
+ setData((prev) => getDataUpdated(prev, course.id, null));
143
+ setUnLoading(course.id);
144
+ return yield Promise.resolve(res.data);
176
145
  }
177
- }, [data, loading, cache]);
146
+ }), [data, loading, cache]);
178
147
  /**
179
148
  * Check the authenticated user subscription status to the course
180
149
  * Update the courses cached
@@ -250,7 +219,7 @@ function useSCJoinedCoursesManager(user) {
250
219
  if (cache.includes(course.id)) {
251
220
  return getCurrentCourseCacheStatus(course);
252
221
  }
253
- if (authUserId) {
222
+ if (authUserId && course) {
254
223
  if ('join_status' in course) {
255
224
  return getJoinStatus(course);
256
225
  }
@@ -259,7 +228,7 @@ function useSCJoinedCoursesManager(user) {
259
228
  }
260
229
  }
261
230
  return null;
262
- }, [loading, cache, authUserId]);
231
+ }, [loading, cache, authUserId, getJoinStatus, getCurrentCourseCacheStatus]);
263
232
  /**
264
233
  * Empty cache on logout
265
234
  */
@@ -0,0 +1,18 @@
1
+ /**
2
+ :::info
3
+ This custom hook is used to check if the payments are enabled
4
+ :::
5
+ :::tip How to use it:
6
+
7
+ Follow these steps:
8
+ ```jsx
9
+ 1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
10
+ 2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
11
+ ```
12
+ :::
13
+ */
14
+ export default function useSCPaymentsEnabled(): {
15
+ isPaymentsEnabled: any;
16
+ stripePublicKey: any;
17
+ stripeConnectedAccountId: any;
18
+ };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = require("react");
5
+ const types_1 = require("@selfcommunity/types");
6
+ const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
7
+ const SCPreferences = tslib_1.__importStar(require("../constants/Preferences"));
8
+ /**
9
+ :::info
10
+ This custom hook is used to check if the payments are enabled
11
+ :::
12
+ :::tip How to use it:
13
+
14
+ Follow these steps:
15
+ ```jsx
16
+ 1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
17
+ 2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
18
+ ```
19
+ :::
20
+ */
21
+ function useSCPaymentsEnabled() {
22
+ // CONTEXT
23
+ const { preferences, features } = (0, SCPreferencesProvider_1.useSCPreferences)();
24
+ const isPaymentsEnabled = (0, react_1.useMemo)(() => preferences &&
25
+ features &&
26
+ features.includes(types_1.SCFeatureName.PAYMENTS) &&
27
+ SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED in preferences &&
28
+ preferences[SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED].value, [preferences]);
29
+ const stripePublicKey = (0, react_1.useMemo)(() => preferences && SCPreferences.STATIC_STRIPE_PUBLIC_KEY in preferences && preferences[SCPreferences.STATIC_STRIPE_PUBLIC_KEY].value, [preferences]);
30
+ const stripeConnectedAccountId = (0, react_1.useMemo)(() => preferences &&
31
+ SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID in preferences &&
32
+ preferences[SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID].value, [preferences]);
33
+ return { isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId };
34
+ }
35
+ exports.default = useSCPaymentsEnabled;
@@ -37,21 +37,17 @@ function useSCSubscribedEventsManager(user) {
37
37
  Preferences_1.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
38
38
  preferences[Preferences_1.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
39
39
  const notificationInvitedToJoinEvent = (0, react_1.useRef)(null);
40
- const notificationRequestedToJoinEvent = (0, react_1.useRef)(null);
41
- const notificationAcceptedToJoinEvent = (0, react_1.useRef)(null);
40
+ // const notificationRequestedToJoinEvent = useRef(null);
41
+ // const notificationAcceptedToJoinEvent = useRef(null);
42
42
  const notificationAddedToEvent = (0, react_1.useRef)(null);
43
43
  /**
44
44
  * Subscribe to notification types user_follow, user_unfollow
45
45
  */
46
46
  (0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
47
47
  notificationInvitedToJoinEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT}`, notificationSubscriber);
48
- notificationRequestedToJoinEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT}`, notificationSubscriber);
49
- notificationAcceptedToJoinEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT}`, notificationSubscriber);
50
48
  notificationAddedToEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ADDED_TO_EVENT}`, notificationSubscriber);
51
49
  return () => {
52
50
  pubsub_js_1.default.unsubscribe(notificationInvitedToJoinEvent.current);
53
- pubsub_js_1.default.unsubscribe(notificationRequestedToJoinEvent.current);
54
- pubsub_js_1.default.unsubscribe(notificationAcceptedToJoinEvent.current);
55
51
  pubsub_js_1.default.unsubscribe(notificationAddedToEvent.current);
56
52
  };
57
53
  }, [data]);
@@ -67,12 +63,6 @@ function useSCSubscribedEventsManager(user) {
67
63
  case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT:
68
64
  _status = types_1.SCEventSubscriptionStatusType.INVITED;
69
65
  break;
70
- case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT:
71
- _status = types_1.SCEventSubscriptionStatusType.REQUESTED;
72
- break;
73
- case types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT:
74
- _status = types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
75
- break;
76
66
  case types_1.SCNotificationTypologyType.USER_ADDED_TO_EVENT:
77
67
  _status = types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
78
68
  break;
@@ -93,8 +83,8 @@ function useSCSubscribedEventsManager(user) {
93
83
  // Only if user is authenticated
94
84
  api_services_1.http
95
85
  .request({
96
- url: api_services_1.Endpoints.GetUserEvents.url(),
97
- method: api_services_1.Endpoints.GetUserEvents.method,
86
+ url: api_services_1.Endpoints.GetUserSubscribedEvents.url({ id: user.id }),
87
+ method: api_services_1.Endpoints.GetUserSubscribedEvents.method,
98
88
  })
99
89
  .then((res) => {
100
90
  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;
@@ -37,21 +37,15 @@ function useSCSubscribedGroupsManager(user) {
37
37
  Preferences_1.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
38
38
  preferences[Preferences_1.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
39
39
  const notificationInvitedToJoinGroup = (0, react_1.useRef)(null);
40
- const notificationRequestedToJoinGroup = (0, react_1.useRef)(null);
41
- const notificationAcceptedToJoinGroup = (0, react_1.useRef)(null);
42
40
  const notificationAddedToGroup = (0, react_1.useRef)(null);
43
41
  /**
44
42
  * Subscribe to notification types user_follow, user_unfollow
45
43
  */
46
44
  (0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
47
45
  notificationInvitedToJoinGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP}`, notificationSubscriber);
48
- notificationRequestedToJoinGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP}`, notificationSubscriber);
49
- notificationAcceptedToJoinGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP}`, notificationSubscriber);
50
46
  notificationAddedToGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP}`, notificationSubscriber);
51
47
  return () => {
52
48
  pubsub_js_1.default.unsubscribe(notificationInvitedToJoinGroup.current);
53
- pubsub_js_1.default.unsubscribe(notificationRequestedToJoinGroup.current);
54
- pubsub_js_1.default.unsubscribe(notificationAcceptedToJoinGroup.current);
55
49
  pubsub_js_1.default.unsubscribe(notificationAddedToGroup.current);
56
50
  };
57
51
  }, [data]);
@@ -61,20 +55,20 @@ function useSCSubscribedGroupsManager(user) {
61
55
  * @param dataMsg
62
56
  */
63
57
  const notificationSubscriber = (msg, dataMsg) => {
58
+ var _a;
64
59
  if (dataMsg.data.group !== undefined) {
65
60
  let _status;
66
61
  switch (Notification_1.SCNotificationMapping[dataMsg.data.activity_type]) {
67
62
  case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP:
68
63
  _status = types_1.SCGroupSubscriptionStatusType.INVITED;
69
64
  break;
70
- case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP:
71
- _status = types_1.SCGroupSubscriptionStatusType.REQUESTED;
72
- break;
73
- case types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP:
74
- _status = types_1.SCGroupSubscriptionStatusType.SUBSCRIBED;
75
- break;
76
65
  case types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP:
77
- _status = types_1.SCGroupSubscriptionStatusType.SUBSCRIBED;
66
+ if (dataMsg.data.notification_obj.group && ((_a = dataMsg.data.notification_obj.group.paywalls) === null || _a === void 0 ? void 0 : _a.length)) {
67
+ _status = types_1.SCGroupSubscriptionStatusType.PAYMENT_WAITING;
68
+ }
69
+ else {
70
+ _status = types_1.SCGroupSubscriptionStatusType.SUBSCRIBED;
71
+ }
78
72
  break;
79
73
  }
80
74
  updateCache([dataMsg.data.group]);
@@ -93,8 +87,8 @@ function useSCSubscribedGroupsManager(user) {
93
87
  // Only if user is authenticated
94
88
  api_services_1.http
95
89
  .request({
96
- url: api_services_1.Endpoints.GetUserGroups.url(),
97
- method: api_services_1.Endpoints.GetUserGroups.method,
90
+ url: api_services_1.Endpoints.GetUserSubscribedGroups.url({ id: user.id }),
91
+ method: api_services_1.Endpoints.GetUserSubscribedGroups.method,
98
92
  })
99
93
  .then((res) => {
100
94
  if (res.status >= 300) {
@@ -115,50 +109,31 @@ function useSCSubscribedGroupsManager(user) {
115
109
  * Memoized subscribe Group
116
110
  * Toggle action
117
111
  */
118
- const subscribe = (0, react_1.useMemo)(() => (group, userId) => {
112
+ const subscribe = (0, react_1.useMemo)(() => (group) => {
119
113
  setLoading(group.id);
120
- if (userId) {
121
- return api_services_1.http
122
- .request({
123
- url: api_services_1.Endpoints.InviteOrAcceptGroupRequest.url({ id: group.id }),
124
- method: api_services_1.Endpoints.InviteOrAcceptGroupRequest.method,
125
- data: { users: [userId] },
126
- })
127
- .then((res) => {
128
- if (res.status >= 300) {
129
- return Promise.reject(res);
130
- }
131
- updateCache([group.id]);
132
- setData((prev) => getDataUpdated(prev, group.id, types_1.SCGroupSubscriptionStatusType.SUBSCRIBED));
133
- setUnLoading(group.id);
134
- return Promise.resolve(res.data);
135
- });
136
- }
137
- else {
138
- return api_services_1.http
139
- .request({
140
- url: api_services_1.Endpoints.SubscribeToGroup.url({ id: group.id }),
141
- method: api_services_1.Endpoints.SubscribeToGroup.method,
142
- })
143
- .then((res) => {
144
- if (res.status >= 300) {
145
- return Promise.reject(res);
146
- }
147
- updateCache([group.id]);
148
- setData((prev) => getDataUpdated(prev, group.id, group.privacy === types_1.SCGroupPrivacyType.PRIVATE && group.subscription_status !== types_1.SCGroupSubscriptionStatusType.INVITED
149
- ? types_1.SCGroupSubscriptionStatusType.REQUESTED
150
- : types_1.SCGroupSubscriptionStatusType.SUBSCRIBED));
151
- setUnLoading(group.id);
152
- return Promise.resolve(res.data);
153
- });
154
- }
114
+ return api_services_1.http
115
+ .request({
116
+ url: api_services_1.Endpoints.SubscribeToGroup.url({ id: group.id }),
117
+ method: api_services_1.Endpoints.SubscribeToGroup.method,
118
+ })
119
+ .then((res) => {
120
+ if (res.status >= 300) {
121
+ return Promise.reject(res);
122
+ }
123
+ updateCache([group.id]);
124
+ setData((prev) => getDataUpdated(prev, group.id, group.privacy === types_1.SCGroupPrivacyType.PRIVATE && group.subscription_status !== types_1.SCGroupSubscriptionStatusType.INVITED
125
+ ? types_1.SCGroupSubscriptionStatusType.REQUESTED
126
+ : types_1.SCGroupSubscriptionStatusType.SUBSCRIBED));
127
+ setUnLoading(group.id);
128
+ return Promise.resolve(res.data);
129
+ });
155
130
  }, [data, loading, cache]);
156
131
  /**
157
132
  * Memoized subscribe Group
158
133
  * Toggle action
159
134
  */
160
135
  const unsubscribe = (0, react_1.useMemo)(() => (group) => {
161
- if (group.subscription_status !== types_1.SCGroupSubscriptionStatusType.REQUESTED) {
136
+ if (data[group.id] !== types_1.SCGroupSubscriptionStatusType.REQUESTED) {
162
137
  setLoading(group.id);
163
138
  return api_services_1.http
164
139
  .request({
@@ -251,7 +226,7 @@ function useSCSubscribedGroupsManager(user) {
251
226
  if (cache.includes(group.id)) {
252
227
  return getCurrentGroupCacheStatus(group);
253
228
  }
254
- if (authUserId) {
229
+ if (authUserId && group) {
255
230
  if ('subscription_status' in group) {
256
231
  return getSubscriptionStatus(group);
257
232
  }
@@ -260,7 +235,7 @@ function useSCSubscribedGroupsManager(user) {
260
235
  }
261
236
  }
262
237
  return null;
263
- }, [loading, cache, authUserId]);
238
+ }, [loading, cache, authUserId, getSubscriptionStatus, getCurrentGroupCacheStatus]);
264
239
  /**
265
240
  * Empty cache on logout
266
241
  */
@@ -71,6 +71,9 @@ import useSCGoogleApiLoader from './hooks/useSCGoogleApiLoader';
71
71
  import useSCFetchCourse from './hooks/useSCFetchCourse';
72
72
  import useSCFetchCourses from './hooks/useSCFetchCourses';
73
73
  import useSCFetchLesson from './hooks/useSCFetchLesson';
74
+ import useSCPaymentsEnabled from './hooks/useSCPaymentsEnabled';
75
+ import useSCFetchPaymentProduct from './hooks/useSCFetchPaymentProduct';
76
+ import useSCFetchPaymentOrder from './hooks/useSCFetchPaymentOrder';
74
77
  /**
75
78
  * Routing component
76
79
  */
@@ -82,7 +85,7 @@ import * as SCRoutes from './constants/Routes';
82
85
  */
83
86
  import * as UserUtils from './utils/user';
84
87
  import getTheme from './themes/theme';
85
- import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility } from './utils/hooks';
88
+ import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver } from './utils/hooks';
86
89
  import { getEventStatus } from './utils/event';
87
90
  /**
88
91
  * Constants:
@@ -93,4 +96,4 @@ import * as Preferences from './constants/Preferences';
93
96
  /**
94
97
  * List all exports
95
98
  */
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, };
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/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSCFetchCategories = exports.useSCFetchCategory = exports.useSCFetchAddressingTagList = exports.useSCFetchTag = exports.useSCFetchCustomAdv = exports.useSCFetchLessonCommentObjects = exports.useSCFetchLessonCommentObject = exports.useSCFetchCommentObjects = exports.useSCFetchCommentObject = exports.useSCFetchFeedObject = exports.useSCFetchVote = exports.useSCFetchUserProviders = exports.useSCFetchUser = exports.Preferences = exports.Locale = exports.getEventStatus = exports.UserUtils = exports.SCCache = exports.SCRoutes = exports.Link = exports.useSCAlertMessages = exports.SCAlertMessagesContext = exports.SCAlertMessagesProvider = exports.useSCNotification = exports.SCNotificationContext = exports.SCNotificationProvider = exports.SCNotification = exports.SCFeatures = exports.SCPreferences = exports.SCPreferencesProvider = exports.withSCLocale = exports.useSCLocale = exports.SCLocaleProvider = exports.useSCRouting = exports.SCRoutingProvider = exports.getTheme = exports.withSCTheme = exports.useSCTheme = exports.SCThemeProvider = exports.useSCPreferences = exports.useSCUser = exports.SCUserProvider = exports.SCContextProvider = exports.useSCContext = exports.SCPreferencesContext = exports.SCLocaleContext = exports.SCRoutingContext = exports.SCThemeContext = exports.SCUserContext = exports.SCContext = void 0;
4
- exports.useSCFetchLesson = exports.useSCFetchCourses = exports.useSCFetchCourse = exports.useSCGoogleApiLoader = exports.useSCFetchLiveStream = exports.useSCFetchEvents = exports.useSCFetchEvent = exports.useSCFetchGroups = exports.useSCFetchGroup = exports.useSCUserIsBlocked = exports.useSCFetchUserBlockedBy = exports.useSCFetchBroadcastMessages = exports.useSCFetchPrivateMessageSnippets = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = exports.useSCFetchFeed = exports.useSCFetchContributors = exports.useSCMediaClick = exports.useSCFetchIncubator = void 0;
4
+ exports.useSCFetchPaymentOrder = exports.useSCFetchPaymentProduct = exports.useSCPaymentsEnabled = exports.useSCFetchLesson = exports.useSCFetchCourses = exports.useSCFetchCourse = exports.useSCGoogleApiLoader = exports.useSCFetchLiveStream = exports.useSCFetchEvents = exports.useSCFetchEvent = exports.useSCFetchGroups = exports.useSCFetchGroup = exports.useSCUserIsBlocked = exports.useSCFetchUserBlockedBy = exports.useSCFetchBroadcastMessages = exports.useSCFetchPrivateMessageSnippets = exports.useResizeObserver = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = exports.useSCFetchFeed = exports.useSCFetchContributors = exports.useSCMediaClick = exports.useSCFetchIncubator = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  /**
7
7
  * ContextProvider component
@@ -132,6 +132,12 @@ const useSCFetchCourses_1 = tslib_1.__importDefault(require("./hooks/useSCFetchC
132
132
  exports.useSCFetchCourses = useSCFetchCourses_1.default;
133
133
  const useSCFetchLesson_1 = tslib_1.__importDefault(require("./hooks/useSCFetchLesson"));
134
134
  exports.useSCFetchLesson = useSCFetchLesson_1.default;
135
+ const useSCPaymentsEnabled_1 = tslib_1.__importDefault(require("./hooks/useSCPaymentsEnabled"));
136
+ exports.useSCPaymentsEnabled = useSCPaymentsEnabled_1.default;
137
+ const useSCFetchPaymentProduct_1 = tslib_1.__importDefault(require("./hooks/useSCFetchPaymentProduct"));
138
+ exports.useSCFetchPaymentProduct = useSCFetchPaymentProduct_1.default;
139
+ const useSCFetchPaymentOrder_1 = tslib_1.__importDefault(require("./hooks/useSCFetchPaymentOrder"));
140
+ exports.useSCFetchPaymentOrder = useSCFetchPaymentOrder_1.default;
135
141
  /**
136
142
  * Routing component
137
143
  */
@@ -154,6 +160,7 @@ Object.defineProperty(exports, "useIsomorphicLayoutEffect", { enumerable: true,
154
160
  Object.defineProperty(exports, "useEffectOnce", { enumerable: true, get: function () { return hooks_1.useEffectOnce; } });
155
161
  Object.defineProperty(exports, "useNoInitialEffect", { enumerable: true, get: function () { return hooks_1.useNoInitialEffect; } });
156
162
  Object.defineProperty(exports, "usePageVisibility", { enumerable: true, get: function () { return hooks_1.usePageVisibility; } });
163
+ Object.defineProperty(exports, "useResizeObserver", { enumerable: true, get: function () { return hooks_1.useResizeObserver; } });
157
164
  const event_1 = require("./utils/event");
158
165
  Object.defineProperty(exports, "getEventStatus", { enumerable: true, get: function () { return event_1.getEventStatus; } });
159
166
  /**
@@ -51,6 +51,18 @@ const getTheme = (options, preferences) => {
51
51
  sizeXLarge: 120,
52
52
  },
53
53
  },
54
+ contentProduct: {
55
+ icon: {
56
+ sizeSmall: 24,
57
+ sizeMedium: 40,
58
+ },
59
+ },
60
+ contentProductPrice: {
61
+ icon: {
62
+ sizeSmall: 24,
63
+ sizeMedium: 40,
64
+ },
65
+ },
54
66
  };
55
67
  const defaultOptions = preferences
56
68
  ? {
@@ -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, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = void 0;
3
+ exports.useResizeObserver = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const useIsComponentMountedRef_1 = tslib_1.__importDefault(require("./useIsComponentMountedRef"));
6
6
  exports.useIsComponentMountedRef = useIsComponentMountedRef_1.default;
@@ -14,3 +14,5 @@ const useNoInitialEffect_1 = tslib_1.__importDefault(require("./useNoInitialEffe
14
14
  exports.useNoInitialEffect = useNoInitialEffect_1.default;
15
15
  const usePageVisibility_1 = tslib_1.__importDefault(require("./usePageVisibility"));
16
16
  exports.usePageVisibility = usePageVisibility_1.default;
17
+ const useResizeObserver_1 = tslib_1.__importDefault(require("./useResizeObserver"));
18
+ exports.useResizeObserver = useResizeObserver_1.default;
@@ -0,0 +1 @@
1
+ export default function useResizeObserver(element: Element | null, options: ResizeObserverOptions | undefined, observerCallback: ResizeObserverCallback): void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ function useResizeObserver(element, options, observerCallback) {
5
+ (0, react_1.useEffect)(() => {
6
+ if (!element || !('ResizeObserver' in window)) {
7
+ return undefined;
8
+ }
9
+ const observer = new ResizeObserver(observerCallback);
10
+ observer.observe(element, options);
11
+ return () => {
12
+ observer.disconnect();
13
+ };
14
+ }, [element, options, observerCallback]);
15
+ }
16
+ exports.default = useResizeObserver;