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

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 (90) hide show
  1. package/lib/cjs/constants/Cache.d.ts +12 -0
  2. package/lib/cjs/constants/Cache.js +17 -1
  3. package/lib/cjs/constants/Preferences.d.ts +18 -0
  4. package/lib/cjs/constants/Preferences.js +36 -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/useFetchMenuFooter.d.ts +5 -0
  8. package/lib/cjs/hooks/useFetchMenuFooter.js +36 -0
  9. package/lib/cjs/hooks/useSCFeature.d.ts +22 -0
  10. package/lib/cjs/hooks/useSCFeature.js +38 -0
  11. package/lib/cjs/hooks/useSCFetchCategory.d.ts +1 -0
  12. package/lib/cjs/hooks/useSCFetchCategory.js +18 -1
  13. package/lib/cjs/hooks/useSCFetchCourse.js +15 -15
  14. package/lib/cjs/hooks/useSCFetchEvent.d.ts +1 -0
  15. package/lib/cjs/hooks/useSCFetchEvent.js +16 -1
  16. package/lib/cjs/hooks/useSCFetchGroup.d.ts +1 -0
  17. package/lib/cjs/hooks/useSCFetchGroup.js +16 -1
  18. package/lib/cjs/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  19. package/lib/cjs/hooks/useSCFetchPaymentOrder.js +70 -0
  20. package/lib/cjs/hooks/useSCFetchPaymentProduct.d.ts +20 -0
  21. package/lib/cjs/hooks/useSCFetchPaymentProduct.js +70 -0
  22. package/lib/cjs/hooks/useSCFetchUsers.d.ts +21 -0
  23. package/lib/cjs/hooks/useSCFetchUsers.js +50 -0
  24. package/lib/cjs/hooks/useSCJoinedCoursesManager.d.ts +1 -1
  25. package/lib/cjs/hooks/useSCJoinedCoursesManager.js +36 -67
  26. package/lib/cjs/hooks/useSCPaymentsEnabled.d.ts +18 -0
  27. package/lib/cjs/hooks/useSCPaymentsEnabled.js +35 -0
  28. package/lib/cjs/hooks/useSCPreference.d.ts +36 -0
  29. package/lib/cjs/hooks/useSCPreference.js +69 -0
  30. package/lib/cjs/hooks/useSCPreferencesAndFeaturesEnabled.d.ts +17 -0
  31. package/lib/cjs/hooks/useSCPreferencesAndFeaturesEnabled.js +35 -0
  32. package/lib/cjs/hooks/useSCSubscribedEventsManager.js +4 -14
  33. package/lib/cjs/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
  34. package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +29 -54
  35. package/lib/cjs/index.d.ts +10 -2
  36. package/lib/cjs/index.js +22 -2
  37. package/lib/cjs/themes/theme.js +12 -0
  38. package/lib/cjs/types/theme.d.ts +52 -0
  39. package/lib/cjs/utils/hooks/index.d.ts +2 -1
  40. package/lib/cjs/utils/hooks/index.js +3 -1
  41. package/lib/cjs/utils/hooks/useResizeObserver.d.ts +1 -0
  42. package/lib/cjs/utils/hooks/useResizeObserver.js +16 -0
  43. package/lib/cjs/utils/user.d.ts +8 -1
  44. package/lib/cjs/utils/user.js +15 -2
  45. package/lib/esm/constants/Cache.d.ts +12 -0
  46. package/lib/esm/constants/Cache.js +12 -0
  47. package/lib/esm/constants/Preferences.d.ts +18 -0
  48. package/lib/esm/constants/Preferences.js +33 -0
  49. package/lib/esm/constants/Routes.d.ts +6 -0
  50. package/lib/esm/constants/Routes.js +12 -0
  51. package/lib/esm/hooks/useFetchMenuFooter.d.ts +5 -0
  52. package/lib/esm/hooks/useFetchMenuFooter.js +33 -0
  53. package/lib/esm/hooks/useSCFeature.d.ts +22 -0
  54. package/lib/esm/hooks/useSCFeature.js +33 -0
  55. package/lib/esm/hooks/useSCFetchCategory.d.ts +1 -0
  56. package/lib/esm/hooks/useSCFetchCategory.js +18 -1
  57. package/lib/esm/hooks/useSCFetchCourse.js +15 -15
  58. package/lib/esm/hooks/useSCFetchEvent.d.ts +1 -0
  59. package/lib/esm/hooks/useSCFetchEvent.js +16 -1
  60. package/lib/esm/hooks/useSCFetchGroup.d.ts +1 -0
  61. package/lib/esm/hooks/useSCFetchGroup.js +16 -1
  62. package/lib/esm/hooks/useSCFetchPaymentOrder.d.ts +20 -0
  63. package/lib/esm/hooks/useSCFetchPaymentOrder.js +67 -0
  64. package/lib/esm/hooks/useSCFetchPaymentProduct.d.ts +20 -0
  65. package/lib/esm/hooks/useSCFetchPaymentProduct.js +67 -0
  66. package/lib/esm/hooks/useSCFetchUsers.d.ts +21 -0
  67. package/lib/esm/hooks/useSCFetchUsers.js +48 -0
  68. package/lib/esm/hooks/useSCJoinedCoursesManager.d.ts +1 -1
  69. package/lib/esm/hooks/useSCJoinedCoursesManager.js +37 -67
  70. package/lib/esm/hooks/useSCPaymentsEnabled.d.ts +18 -0
  71. package/lib/esm/hooks/useSCPaymentsEnabled.js +31 -0
  72. package/lib/esm/hooks/useSCPreference.d.ts +36 -0
  73. package/lib/esm/hooks/useSCPreference.js +65 -0
  74. package/lib/esm/hooks/useSCPreferencesAndFeaturesEnabled.d.ts +17 -0
  75. package/lib/esm/hooks/useSCPreferencesAndFeaturesEnabled.js +32 -0
  76. package/lib/esm/hooks/useSCSubscribedEventsManager.js +4 -14
  77. package/lib/esm/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
  78. package/lib/esm/hooks/useSCSubscribedGroupsManager.js +29 -54
  79. package/lib/esm/index.d.ts +10 -2
  80. package/lib/esm/index.js +10 -2
  81. package/lib/esm/themes/theme.js +12 -0
  82. package/lib/esm/types/theme.d.ts +52 -0
  83. package/lib/esm/utils/hooks/index.d.ts +2 -1
  84. package/lib/esm/utils/hooks/index.js +2 -1
  85. package/lib/esm/utils/hooks/useResizeObserver.d.ts +1 -0
  86. package/lib/esm/utils/hooks/useResizeObserver.js +13 -0
  87. package/lib/esm/utils/user.d.ts +8 -1
  88. package/lib/esm/utils/user.js +13 -1
  89. package/lib/umd/react-core.js +1 -1
  90. package/package.json +6 -6
@@ -82,6 +82,8 @@ export const ADDONS_POST_GEOLOCATION_ENABLED = `${SCPreferenceSection.ADDONS}.${
82
82
  export const ADDONS_SHARE_POST_ON_FACEBOOK_ENABLED = `${SCPreferenceSection.ADDONS}.${SCPreferenceName.SHARE_POST_ON_FACEBOOK_ENABLED}`;
83
83
  export const ADDONS_SHARE_POST_ON_TWITTER_ENABLED = `${SCPreferenceSection.ADDONS}.${SCPreferenceName.SHARE_POST_ON_TWITTER_ENABLED}`;
84
84
  export const ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED = `${SCPreferenceSection.ADDONS}.${SCPreferenceName.SHARE_POST_ON_LINKEDIN_ENABLED}`;
85
+ export const ADDONS_PRIVATE_MESSAGES_ENABLED = `${SCPreferenceSection.ADDONS}.${SCPreferenceName.PRIVATE_MESSAGES_ENABLED}`;
86
+ export const ADDONS_SHARE_POST_ENABLED = `${SCPreferenceSection.ADDONS}.${SCPreferenceName.SHARE_POST_ENABLED}`;
85
87
  /**
86
88
  * ADVERTISING
87
89
  */
@@ -90,6 +92,7 @@ export const ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED = `${SCPref
90
92
  /**
91
93
  * CONFIGURATIONS
92
94
  */
95
+ export const CONFIGURATIONS_CONNECTION_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.CONNECTION_ENABLED}`;
93
96
  export const CONFIGURATIONS_FOLLOW_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.FOLLOW_ENABLED}`;
94
97
  export const CONFIGURATIONS_EXPLORE_STREAM_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EXPLORE_STREAM_ENABLED}`;
95
98
  export const CONFIGURATIONS_EXPLORE_STREAM_ORDER_BY = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EXPLORE_STREAM_ORDER_BY}`;
@@ -147,6 +150,20 @@ export const CONFIGURATIONS_LIVE_STREAM_ENABLED = `${SCPreferenceSection.CONFIGU
147
150
  export const CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.LIVE_STREAM_ONLY_STAFF_ENABLED}`;
148
151
  export const CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.LIVE_STREAM_VIDEO_CONFERENCE_ENABLED}`;
149
152
  export const CONFIGURATIONS_SUBSCRIPTION_TIER = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.SUBSCRIPTION_TIER}`;
153
+ export const CONFIGURATIONS_PAYMENTS_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.PAYMENTS_ENABLED}`;
154
+ export const CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.STRIPE_CONNECTED_ACCOUNT_ID}`;
155
+ export const CONFIGURATIONS_CONTEXT_MENU_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.CONTEXT_MENU_ENABLED}`;
156
+ export const CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.CATEGORY_FOLLOW_ENABLED}`;
157
+ export const CONFIGURATIONS_COMMENTS_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.COMMENTS_ENABLED}`;
158
+ export const CONFIGURATIONS_SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED}`;
159
+ export const CONFIGURATIONS_VIDEO_AUTOPLAY_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.VIDEO_AUTOPLAY_ENABLED}`;
160
+ export const CONFIGURATIONS_VIDEO_PLAY_TRACKING_DELAY_SECONDS = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.VIDEO_PLAY_TRACKING_DELAY_SECONDS}`;
161
+ export const CONFIGURATIONS_SCHEDULED_POSTS_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.SCHEDULED_POSTS_ENABLED}`;
162
+ export const CONFIGURATIONS_POST_CATEGORY_REQUIRED_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.POST_CATEGORY_REQUIRED_ENABLED}`;
163
+ export const CONFIGURATIONS_POST_ADDRESSING_REQUIRED_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.POST_ADDRESSING_REQUIRED_ENABLED}`;
164
+ export const CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.POST_USER_ADDRESSING_ENABLED}`;
165
+ export const CONFIGURATIONS_CONTACT_API_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.CONTACT_API_ENABLED}`;
166
+ export const CONFIGURATIONS_ACCEPTED_MEDIA_MIMETYPES = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.ACCEPTED_MEDIA_MIMETYPES}`;
150
167
  /**
151
168
  * PROVIDERS
152
169
  */
@@ -178,6 +195,7 @@ export const WEBMASTER_META_DESCRIPTION = `${SCPreferenceSection.WEBMASTER}.${SC
178
195
  */
179
196
  export const STATIC_ENVIRONMENT = `${SCPreferenceSection.STATIC}.${SCPreferenceName.ENVIRONMENT}`;
180
197
  export const STATIC_STACKID = `${SCPreferenceSection.STATIC}.${SCPreferenceName.STACK_ID}`;
198
+ export const STATIC_STRIPE_PUBLIC_KEY = `${SCPreferenceSection.STATIC}.${SCPreferenceName.STRIPE_PUBLIC_KEY}`;
181
199
  const booleanType = (value) => {
182
200
  if (value === 'True') {
183
201
  return true;
@@ -252,6 +270,7 @@ export const DATA_TYPES = {
252
270
  [ADDONS_SHARE_POST_ON_FACEBOOK_ENABLED]: booleanType,
253
271
  [ADDONS_SHARE_POST_ON_TWITTER_ENABLED]: booleanType,
254
272
  [ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED]: booleanType,
273
+ [ADDONS_SHARE_POST_ENABLED]: booleanType,
255
274
  [CONFIGURATIONS_FOLLOW_ENABLED]: booleanType,
256
275
  [CONFIGURATIONS_EXPLORE_STREAM_ENABLED]: booleanType,
257
276
  [CONFIGURATIONS_EXPLORE_STREAM_ORDER_BY]: stringType,
@@ -308,6 +327,17 @@ export const DATA_TYPES = {
308
327
  [CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED]: booleanType,
309
328
  [CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED]: booleanType,
310
329
  [CONFIGURATIONS_SUBSCRIPTION_TIER]: stringType,
330
+ [CONFIGURATIONS_PAYMENTS_ENABLED]: booleanType,
331
+ [CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID]: stringType,
332
+ [CONFIGURATIONS_CONTEXT_MENU_ENABLED]: booleanType,
333
+ [CONFIGURATIONS_COMMENTS_ENABLED]: booleanType,
334
+ [CONFIGURATIONS_SIDEBAR_SHOW_ALL_CATEGORIES_ENABLED]: booleanType,
335
+ [CONFIGURATIONS_VIDEO_AUTOPLAY_ENABLED]: booleanType,
336
+ [CONFIGURATIONS_VIDEO_PLAY_TRACKING_DELAY_SECONDS]: integerType,
337
+ [CONFIGURATIONS_SCHEDULED_POSTS_ENABLED]: booleanType,
338
+ [CONFIGURATIONS_POST_CATEGORY_REQUIRED_ENABLED]: booleanType,
339
+ [CONFIGURATIONS_POST_ADDRESSING_REQUIRED_ENABLED]: booleanType,
340
+ [CONFIGURATIONS_ACCEPTED_MEDIA_MIMETYPES]: stringType,
311
341
  [PROVIDERS_APP_URL_ON_APP_STORE]: stringType,
312
342
  [PROVIDERS_APP_URL_ON_GOOGLE_PLAY]: stringType,
313
343
  [PROVIDERS_FACEBOOK_SIGNIN_ENABLED]: stringType,
@@ -330,4 +360,7 @@ export const DATA_TYPES = {
330
360
  [WEBMASTER_META_DESCRIPTION]: stringType,
331
361
  [STATIC_ENVIRONMENT]: stringType,
332
362
  [STATIC_STACKID]: stringType,
363
+ [STATIC_STRIPE_PUBLIC_KEY]: stringType,
364
+ [CONFIGURATIONS_POST_USER_ADDRESSING_ENABLED]: booleanType,
365
+ [CONFIGURATIONS_CONTACT_API_ENABLED]: booleanType,
333
366
  };
@@ -23,7 +23,12 @@ export declare const USER_PROFILE_CONNECTIONS_REQUESTS_ROUTE_NAME = "user_connec
23
23
  export declare const USER_PROFILE_CONNECTIONS_REQUESTS_SENT_ROUTE_NAME = "user_connections_requests_sent";
24
24
  export declare const USER_PROFILE_CATEGORIES_ROUTE_NAME = "user_categories";
25
25
  export declare const USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME = "user_followed_posts";
26
+ export declare const USER_PROFILE_SCHEDULED_POSTS_ROUTE_NAME = "user_scheduled_posts";
27
+ export declare const USER_PROFILE_SCHEDULED_DISCUSSIONS_ROUTE_NAME = "user_scheduled_discussions";
26
28
  export declare const USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = "user_followed_discussions";
29
+ export declare const USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME = "user_payments_history_orders";
30
+ export declare const USER_PAYMENTS_ORDER_PDF_ROUTE_NAME = "user_payments_order_pdf";
31
+ export declare const USER_PAYMENT_METHODS_ROUTE_NAME = "user_payment_methods";
27
32
  export declare const LOYALTY_ROUTE_NAME = "loyalty";
28
33
  export declare const INCUBATOR_ROUTE_NAME = "incubator";
29
34
  export declare const SIGNIN_ROUTE_NAME = "signin";
@@ -50,6 +55,7 @@ export declare const EVENTS_SUGGESTED_ROUTE_NAME = "events_suggested";
50
55
  export declare const EVENTS_SUBSCRIBED_ROUTE_NAME = "events_subscribed";
51
56
  export declare const EVENTS_HIGHLIGHT_ROUTE_NAME = "events_highlight";
52
57
  export declare const LIVESTREAM_ROUTE_NAME = "live";
58
+ export declare const CHECKOUT_PAYMENT = "checkout_payment";
53
59
  /**
54
60
  * Default Routes
55
61
  * @type {{[p: string]: string, '[POST_ROUTE_NAME]': string, '[INCUBATOR_ROUTE_NAME]': string, '[LOYALTY_ROUTE_NAME]': string, '[USER_NOTIFICATION_ROUTE_NAME]': string, '[USER_PRIVATE_MESSAGES_ROUTE_NAME]': string, '[COMMENT_ROUTE_NAME]': string, '[DISCUSSION_ROUTE_NAME]': string, '[CATEGORIES_ROUTE_NAME]': string, '[USER_PROFILE_ROUTE_NAME]': string, '[CATEGORY_ROUTE_NAME]': string, '[USER_PROFILE_SETTINGS_ROUTE_NAME]': string, '[STATUS_ROUTE_NAME]': string}}
@@ -23,7 +23,12 @@ export const USER_PROFILE_CONNECTIONS_REQUESTS_ROUTE_NAME = 'user_connections_re
23
23
  export const USER_PROFILE_CONNECTIONS_REQUESTS_SENT_ROUTE_NAME = 'user_connections_requests_sent';
24
24
  export const USER_PROFILE_CATEGORIES_ROUTE_NAME = 'user_categories';
25
25
  export const USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME = 'user_followed_posts';
26
+ export const USER_PROFILE_SCHEDULED_POSTS_ROUTE_NAME = 'user_scheduled_posts';
27
+ export const USER_PROFILE_SCHEDULED_DISCUSSIONS_ROUTE_NAME = 'user_scheduled_discussions';
26
28
  export const USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = 'user_followed_discussions';
29
+ export const USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME = 'user_payments_history_orders';
30
+ export const USER_PAYMENTS_ORDER_PDF_ROUTE_NAME = 'user_payments_order_pdf';
31
+ export const USER_PAYMENT_METHODS_ROUTE_NAME = 'user_payment_methods';
27
32
  export const LOYALTY_ROUTE_NAME = 'loyalty';
28
33
  export const INCUBATOR_ROUTE_NAME = 'incubator';
29
34
  export const SIGNIN_ROUTE_NAME = 'signin';
@@ -50,6 +55,7 @@ export const EVENTS_SUGGESTED_ROUTE_NAME = 'events_suggested';
50
55
  export const EVENTS_SUBSCRIBED_ROUTE_NAME = 'events_subscribed';
51
56
  export const EVENTS_HIGHLIGHT_ROUTE_NAME = 'events_highlight';
52
57
  export const LIVESTREAM_ROUTE_NAME = 'live';
58
+ export const CHECKOUT_PAYMENT = 'checkout_payment';
53
59
  /**
54
60
  * Default Routes
55
61
  * @type {{[p: string]: string, '[POST_ROUTE_NAME]': string, '[INCUBATOR_ROUTE_NAME]': string, '[LOYALTY_ROUTE_NAME]': string, '[USER_NOTIFICATION_ROUTE_NAME]': string, '[USER_PRIVATE_MESSAGES_ROUTE_NAME]': string, '[COMMENT_ROUTE_NAME]': string, '[DISCUSSION_ROUTE_NAME]': string, '[CATEGORIES_ROUTE_NAME]': string, '[USER_PROFILE_ROUTE_NAME]': string, '[CATEGORY_ROUTE_NAME]': string, '[USER_PROFILE_SETTINGS_ROUTE_NAME]': string, '[STATUS_ROUTE_NAME]': string}}
@@ -75,7 +81,12 @@ export const defaultRoutes = {
75
81
  [USER_PROFILE_CONNECTIONS_REQUESTS_SENT_ROUTE_NAME]: '/user/:id/connections/requests/sent/',
76
82
  [USER_PROFILE_CATEGORIES_ROUTE_NAME]: '/user/:id/categories/',
77
83
  [USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME]: '/user/:id/posts/followed/',
84
+ [USER_PROFILE_SCHEDULED_POSTS_ROUTE_NAME]: '/user/:id/posts/scheduled/',
78
85
  [USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME]: '/user/:id/discussions/followed/',
86
+ [USER_PROFILE_SCHEDULED_DISCUSSIONS_ROUTE_NAME]: '/user/:id/discussions/scheduled/',
87
+ [USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME]: '/user/:id/:username/history_orders/',
88
+ [USER_PAYMENTS_ORDER_PDF_ROUTE_NAME]: '/user/:id/:username/order/:pid/pdf/',
89
+ [USER_PAYMENT_METHODS_ROUTE_NAME]: '/user/:id/:username/payment_methods/',
79
90
  [LOYALTY_ROUTE_NAME]: '/loyalty/',
80
91
  [INCUBATOR_ROUTE_NAME]: '/incubator/:id/',
81
92
  [SIGNIN_ROUTE_NAME]: '/signin/',
@@ -102,4 +113,5 @@ export const defaultRoutes = {
102
113
  [COURSE_LESSON_COMMENTS_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/comments',
103
114
  [COURSE_LESSON_EDIT_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/edit',
104
115
  [LIVESTREAM_ROUTE_NAME]: '/live/:slug/',
116
+ [CHECKOUT_PAYMENT]: '/checkout/:content_type/:content_id/price/:price_id',
105
117
  };
@@ -0,0 +1,5 @@
1
+ import { SCCustomMenu, SCCustomMenuType } from '@selfcommunity/types';
2
+ export default function useFetchMenuFooter(id: SCCustomMenu, menu?: SCCustomMenuType | null): {
3
+ _menu: SCCustomMenuType;
4
+ loading: boolean;
5
+ };
@@ -0,0 +1,33 @@
1
+ import { CustomMenuService } from '@selfcommunity/api-services';
2
+ import { Logger } from '@selfcommunity/utils';
3
+ import { useCallback, useEffect, useState } from 'react';
4
+ import { SCOPE_SC_CORE } from '../constants/Errors';
5
+ export default function useFetchMenuFooter(id, menu = null) {
6
+ // STATES
7
+ const [_menu, setMenu] = useState(menu);
8
+ const [loading, setLoading] = useState(!menu);
9
+ /**
10
+ * Fetches custom pages
11
+ */
12
+ const fetchMenu = useCallback(() => {
13
+ setLoading(true);
14
+ CustomMenuService.getASpecificCustomMenu(id)
15
+ .then((menu) => {
16
+ setMenu(menu);
17
+ })
18
+ .catch((error) => {
19
+ Logger.error(SCOPE_SC_CORE, error);
20
+ })
21
+ .then(() => setLoading(false));
22
+ }, []);
23
+ /**
24
+ * On mount, fetches legal and custom pages
25
+ */
26
+ useEffect(() => {
27
+ if (menu) {
28
+ return;
29
+ }
30
+ fetchMenu();
31
+ }, [id]);
32
+ return { _menu, loading };
33
+ }
@@ -0,0 +1,22 @@
1
+ import { SCFeatureName } from '@selfcommunity/types';
2
+ /**
3
+ * Custom hook to check if the feature is enabled
4
+ * @param featureName - feature name
5
+ * @returns boolean - true if the feature is in the list of features
6
+ *
7
+ * Ex.
8
+ * const isTaggingEnabled = useSCFeatureEnabled(SCFeatureName.TAGGING);
9
+ */
10
+ export declare function useSCFeatureEnabled(featureName: SCFeatureName): boolean;
11
+ /**
12
+ * Custom hook to check if a list of features are enabled
13
+ * @param featureNames - feature names
14
+ * @returns boolean - true if all features are in the features list
15
+ *
16
+ * Ex.
17
+ * const hasRequiredFeatures = useSCFeaturesEnabled([
18
+ * SCFeatureName.TAGGING,
19
+ * SCFeatureName.GROUPING
20
+ * ]);
21
+ */
22
+ export declare function useSCFeaturesEnabled(featureNames: SCFeatureName[]): boolean;
@@ -0,0 +1,33 @@
1
+ import { useMemo } from 'react';
2
+ import { useSCPreferences } from '../components/provider/SCPreferencesProvider';
3
+ /**
4
+ * Custom hook to check if the feature is enabled
5
+ * @param featureName - feature name
6
+ * @returns boolean - true if the feature is in the list of features
7
+ *
8
+ * Ex.
9
+ * const isTaggingEnabled = useSCFeatureEnabled(SCFeatureName.TAGGING);
10
+ */
11
+ export function useSCFeatureEnabled(featureName) {
12
+ const { features } = useSCPreferences();
13
+ return useMemo(() => {
14
+ return Boolean(features && features.includes(featureName));
15
+ }, [features, featureName]);
16
+ }
17
+ /**
18
+ * Custom hook to check if a list of features are enabled
19
+ * @param featureNames - feature names
20
+ * @returns boolean - true if all features are in the features list
21
+ *
22
+ * Ex.
23
+ * const hasRequiredFeatures = useSCFeaturesEnabled([
24
+ * SCFeatureName.TAGGING,
25
+ * SCFeatureName.GROUPING
26
+ * ]);
27
+ */
28
+ export function useSCFeaturesEnabled(featureNames) {
29
+ const { features } = useSCPreferences();
30
+ return useMemo(() => {
31
+ return Boolean(features && featureNames.every((name) => features.includes(name)));
32
+ }, [features, featureNames]);
33
+ }
@@ -18,4 +18,5 @@ export default function useSCFetchCategory({ id, category, cacheStrategy, }: {
18
18
  scCategory: SCCategoryType;
19
19
  setSCCategory: import("react").Dispatch<import("react").SetStateAction<SCCategoryType>>;
20
20
  error: string;
21
+ refreshCategory: () => void;
21
22
  };
@@ -40,6 +40,23 @@ export default function useSCFetchCategory({ id = null, category = null, cacheSt
40
40
  return Promise.resolve(res.data);
41
41
  });
42
42
  }, [__categoryId]);
43
+ /**
44
+ * Refresh category
45
+ */
46
+ const refreshCategory = useMemo(() => () => {
47
+ fetchCategory()
48
+ .then((obj) => {
49
+ const _c = authUserId ? obj : objectWithoutProperties(obj, ['followed']);
50
+ setSCCategory(_c);
51
+ LRUCache.set(__categoryCacheKey, _c);
52
+ })
53
+ .catch((err) => {
54
+ LRUCache.delete(__categoryCacheKey);
55
+ setError(`Error on refresh category with id ${id}`);
56
+ Logger.error(SCOPE_SC_CORE, `Error on refresh category with id ${id}`);
57
+ Logger.error(SCOPE_SC_CORE, err.message);
58
+ });
59
+ }, [__categoryId, setSCCategory, __categoryCacheKey]);
43
60
  /**
44
61
  * If id attempt to get the category by id
45
62
  */
@@ -66,5 +83,5 @@ export default function useSCFetchCategory({ id = null, category = null, cacheSt
66
83
  LRUCache.set(__categoryCacheKey, _c);
67
84
  }
68
85
  }, [category]);
69
- return { scCategory, setSCCategory, error };
86
+ return { scCategory, setSCCategory, error, refreshCategory };
70
87
  }
@@ -46,6 +46,21 @@ export default function useSCFetchCourse({ id = null, course = null, cacheStrate
46
46
  return Promise.resolve(res.data);
47
47
  });
48
48
  }, []);
49
+ /**
50
+ * Refresh course
51
+ */
52
+ const refreshCourse = useMemo(() => () => {
53
+ fetchCourse(id)
54
+ .then((e) => {
55
+ setSCCourse(e);
56
+ })
57
+ .catch((err) => {
58
+ LRUCache.delete(__courseCacheKey);
59
+ setError(`Error on refresh course with id ${id}`);
60
+ Logger.error(SCOPE_SC_CORE, `Error on refresh course with id ${id}`);
61
+ Logger.error(SCOPE_SC_CORE, err.message);
62
+ });
63
+ }, [id, __courseCacheKey, setSCCourse]);
49
64
  /**
50
65
  * If id attempt to get the course by id
51
66
  */
@@ -74,20 +89,5 @@ export default function useSCFetchCourse({ id = null, course = null, cacheStrate
74
89
  setSCCourse(course);
75
90
  }
76
91
  }, [course, authUserId]);
77
- /**
78
- * Refreshes course data from the network
79
- */
80
- const refreshCourse = useCallback(() => {
81
- if (id) {
82
- fetchCourse(id)
83
- .then((e) => {
84
- setSCCourse(e);
85
- })
86
- .catch((err) => {
87
- setError(`Failed to refresh course data: ${err.message}`);
88
- Logger.error(SCOPE_SC_CORE, err.message);
89
- });
90
- }
91
- }, [id, fetchCourse]);
92
92
  return { scCourse, setSCCourse, error, refreshCourse };
93
93
  }
@@ -19,4 +19,5 @@ export default function useSCFetchEvent({ id, event, autoSubscribe, cacheStrateg
19
19
  scEvent: SCEventType;
20
20
  setSCEvent: (e: SCEventType) => void;
21
21
  error: string;
22
+ refreshEvent: () => () => void;
22
23
  };
@@ -66,6 +66,21 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
66
66
  return Promise.resolve(res.data);
67
67
  });
68
68
  }, []);
69
+ /**
70
+ * Refresh event
71
+ */
72
+ const refreshEvent = useMemo(() => () => () => {
73
+ fetchEvent(id)
74
+ .then((e) => {
75
+ setSCEvent(e);
76
+ })
77
+ .catch((err) => {
78
+ LRUCache.delete(__eventCacheKey);
79
+ setError(`Error on refresh event with id ${id}`);
80
+ Logger.error(SCOPE_SC_CORE, `Error on refresh event with id ${id}`);
81
+ Logger.error(SCOPE_SC_CORE, err.message);
82
+ });
83
+ }, [id, setSCEvent, __eventCacheKey]);
69
84
  /**
70
85
  * If id attempt to get the event by id
71
86
  */
@@ -88,5 +103,5 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
88
103
  setSCEvent(event);
89
104
  }
90
105
  }, [event, authUserId]);
91
- return { scEvent, setSCEvent, error };
106
+ return { scEvent, setSCEvent, error, refreshEvent };
92
107
  }
@@ -17,4 +17,5 @@ export default function useSCFetchGroup({ id, group, cacheStrategy, }: {
17
17
  scGroup: SCGroupType;
18
18
  setSCGroup: (group: SCGroupType) => void;
19
19
  error: string;
20
+ refreshGroup: () => void;
20
21
  };
@@ -45,6 +45,21 @@ export default function useSCFetchGroup({ id = null, group = null, cacheStrategy
45
45
  return Promise.resolve(res.data);
46
46
  });
47
47
  }, [__groupId]);
48
+ /**
49
+ * Refresh group
50
+ */
51
+ const refreshGroup = useMemo(() => () => {
52
+ fetchGroup()
53
+ .then((obj) => {
54
+ setSCGroup(obj);
55
+ })
56
+ .catch((err) => {
57
+ LRUCache.delete(__groupCacheKey);
58
+ setError(`Error on refresh group with id ${id}`);
59
+ Logger.error(SCOPE_SC_CORE, `Error on refresh group with id ${id}`);
60
+ Logger.error(SCOPE_SC_CORE, err.message);
61
+ });
62
+ }, [__groupCacheKey, setSCGroup]);
48
63
  /**
49
64
  * If id attempt to get the group by id
50
65
  */
@@ -67,5 +82,5 @@ export default function useSCFetchGroup({ id = null, group = null, cacheStrategy
67
82
  setSCGroup(group);
68
83
  }
69
84
  }, [group, authUserId]);
70
- return { scGroup, setSCGroup, error };
85
+ return { scGroup, setSCGroup, error, refreshGroup };
71
86
  }
@@ -0,0 +1,20 @@
1
+ import { SCPaymentOrder } from '@selfcommunity/types';
2
+ import { CacheStrategies } from '@selfcommunity/utils';
3
+ /**
4
+ :::info
5
+ This custom hook is used to fetch a payment order.
6
+ :::
7
+ * @param object
8
+ * @param object.id
9
+ * @param object.paymentOrder
10
+ * @param object.cacheStrategy
11
+ */
12
+ export default function useSCFetchPaymentOrder({ id, paymentOrder, cacheStrategy, }: {
13
+ id?: number | string;
14
+ paymentOrder?: SCPaymentOrder;
15
+ cacheStrategy?: CacheStrategies;
16
+ }): {
17
+ scPaymentOrder: SCPaymentOrder;
18
+ setSCPaymentOrder: (c: SCPaymentOrder) => void;
19
+ error: string;
20
+ };
@@ -0,0 +1,67 @@
1
+ import { Endpoints, http } from '@selfcommunity/api-services';
2
+ import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
3
+ import { useCallback, useEffect, useMemo, useState } from 'react';
4
+ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
5
+ import { useSCUser } from '../components/provider/SCUserProvider';
6
+ import { getPaymentOrderObjectCacheKey } from '../constants/Cache';
7
+ import { SCOPE_SC_CORE } from '../constants/Errors';
8
+ /**
9
+ :::info
10
+ This custom hook is used to fetch a payment order.
11
+ :::
12
+ * @param object
13
+ * @param object.id
14
+ * @param object.paymentOrder
15
+ * @param object.cacheStrategy
16
+ */
17
+ export default function useSCFetchPaymentOrder({ id = null, paymentOrder = null, cacheStrategy = CacheStrategies.NETWORK_ONLY, }) {
18
+ const __paymentOrderId = useMemo(() => (paymentOrder === null || paymentOrder === void 0 ? void 0 : paymentOrder.id) || id, [paymentOrder, id]);
19
+ // CONTEXT
20
+ const scUserContext = useSCUser();
21
+ const authUserId = useMemo(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) || null; }, [scUserContext.user]);
22
+ // CACHE
23
+ const __paymentOrderCacheKey = useMemo(() => getPaymentOrderObjectCacheKey(__paymentOrderId), [__paymentOrderId]);
24
+ const [scPaymentOrder, setScPaymentOrder] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__paymentOrderCacheKey, paymentOrder) : null);
25
+ const [error, setError] = useState(null);
26
+ const setSCPaymentOrder = useCallback((c) => {
27
+ setScPaymentOrder(c);
28
+ LRUCache.set(__paymentOrderCacheKey, c);
29
+ }, [setScPaymentOrder, __paymentOrderCacheKey]);
30
+ /**
31
+ * Memoized fetch order
32
+ */
33
+ const fetchPaymentOrder = useMemo(() => (id) => {
34
+ return http
35
+ .request({
36
+ url: Endpoints.GetPaymentOrder.url({ id }),
37
+ method: Endpoints.GetPaymentOrder.method,
38
+ })
39
+ .then((res) => {
40
+ if (res.status >= 300) {
41
+ return Promise.reject(res);
42
+ }
43
+ return Promise.resolve(res.data);
44
+ });
45
+ }, []);
46
+ /**
47
+ * If id attempt to get the course by id
48
+ */
49
+ useEffect(() => {
50
+ if (id !== null && id !== undefined && !paymentOrder) {
51
+ fetchPaymentOrder(id)
52
+ .then((e) => {
53
+ setSCPaymentOrder(e);
54
+ })
55
+ .catch((err) => {
56
+ LRUCache.delete(__paymentOrderCacheKey);
57
+ Logger.error(SCOPE_SC_CORE, err.message);
58
+ });
59
+ }
60
+ }, [id, paymentOrder, authUserId]);
61
+ useDeepCompareEffectNoCheck(() => {
62
+ if (paymentOrder) {
63
+ setSCPaymentOrder(paymentOrder);
64
+ }
65
+ }, [paymentOrder, authUserId]);
66
+ return { scPaymentOrder, setSCPaymentOrder, error };
67
+ }
@@ -0,0 +1,20 @@
1
+ import { SCPaymentProduct } from '@selfcommunity/types';
2
+ import { CacheStrategies } from '@selfcommunity/utils';
3
+ /**
4
+ :::info
5
+ This custom hook is used to fetch a payment product.
6
+ :::
7
+ * @param object
8
+ * @param object.id
9
+ * @param object.paymentProduct
10
+ * @param object.cacheStrategy
11
+ */
12
+ export default function useSCFetchPaymentProduct({ id, paymentProduct, cacheStrategy, }: {
13
+ id?: number | string;
14
+ paymentProduct?: SCPaymentProduct;
15
+ cacheStrategy?: CacheStrategies;
16
+ }): {
17
+ scPaymentProduct: SCPaymentProduct;
18
+ setSCPaymentProduct: (c: SCPaymentProduct) => void;
19
+ error: string;
20
+ };
@@ -0,0 +1,67 @@
1
+ import { Endpoints, http } from '@selfcommunity/api-services';
2
+ import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
3
+ import { useCallback, useEffect, useMemo, useState } from 'react';
4
+ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
5
+ import { useSCUser } from '../components/provider/SCUserProvider';
6
+ import { getPaymentProductObjectCacheKey } from '../constants/Cache';
7
+ import { SCOPE_SC_CORE } from '../constants/Errors';
8
+ /**
9
+ :::info
10
+ This custom hook is used to fetch a payment product.
11
+ :::
12
+ * @param object
13
+ * @param object.id
14
+ * @param object.paymentProduct
15
+ * @param object.cacheStrategy
16
+ */
17
+ export default function useSCFetchPaymentProduct({ id = null, paymentProduct = null, cacheStrategy = CacheStrategies.NETWORK_ONLY, }) {
18
+ const __paymentProductId = useMemo(() => (paymentProduct === null || paymentProduct === void 0 ? void 0 : paymentProduct.id) || id, [paymentProduct, id]);
19
+ // CONTEXT
20
+ const scUserContext = useSCUser();
21
+ const authUserId = useMemo(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) || null; }, [scUserContext.user]);
22
+ // CACHE
23
+ const __paymentProductCacheKey = useMemo(() => getPaymentProductObjectCacheKey(__paymentProductId), [__paymentProductId]);
24
+ const [scPaymentProduct, setScPaymentProduct] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__paymentProductCacheKey, paymentProduct) : null);
25
+ const [error, setError] = useState(null);
26
+ const setSCPaymentProduct = useCallback((c) => {
27
+ setScPaymentProduct(c);
28
+ LRUCache.set(__paymentProductCacheKey, c);
29
+ }, [setScPaymentProduct, __paymentProductCacheKey]);
30
+ /**
31
+ * Memoized fetch product
32
+ */
33
+ const fetchPaymentProduct = useMemo(() => (id) => {
34
+ return http
35
+ .request({
36
+ url: Endpoints.GetPaymentProduct.url({ id }),
37
+ method: Endpoints.GetPaymentProduct.method,
38
+ })
39
+ .then((res) => {
40
+ if (res.status >= 300) {
41
+ return Promise.reject(res);
42
+ }
43
+ return Promise.resolve(res.data);
44
+ });
45
+ }, []);
46
+ /**
47
+ * If id attempt to get the course by id
48
+ */
49
+ useEffect(() => {
50
+ if (id !== null && id !== undefined && !paymentProduct) {
51
+ fetchPaymentProduct(id)
52
+ .then((e) => {
53
+ setSCPaymentProduct(e);
54
+ })
55
+ .catch((err) => {
56
+ LRUCache.delete(__paymentProductCacheKey);
57
+ Logger.error(SCOPE_SC_CORE, err.message);
58
+ });
59
+ }
60
+ }, [id, paymentProduct, authUserId]);
61
+ useDeepCompareEffectNoCheck(() => {
62
+ if (paymentProduct) {
63
+ setSCPaymentProduct(paymentProduct);
64
+ }
65
+ }, [paymentProduct, authUserId]);
66
+ return { scPaymentProduct, setSCPaymentProduct, error };
67
+ }
@@ -0,0 +1,21 @@
1
+ import { SCUserAutocompleteType } from '@selfcommunity/types';
2
+ /**
3
+ :::info
4
+ This custom hook is used to fetch users.
5
+
6
+ :::tip Context can be consumed in this way:
7
+
8
+ ```jsx
9
+ const {users, isLoading} = useSCFetchUsers();
10
+ ```
11
+ :::
12
+ * @param props
13
+ */
14
+ declare const useSCFetchUsers: (props?: {
15
+ search: string;
16
+ exclude?: string;
17
+ }) => {
18
+ users: SCUserAutocompleteType[];
19
+ isLoading: boolean;
20
+ };
21
+ export default useSCFetchUsers;
@@ -0,0 +1,48 @@
1
+ import { __awaiter } from "tslib";
2
+ import { useEffect, useState } from 'react';
3
+ import { SCOPE_SC_CORE } from '../constants/Errors';
4
+ import { Endpoints, http } from '@selfcommunity/api-services';
5
+ import { Logger } from '@selfcommunity/utils';
6
+ /**
7
+ :::info
8
+ This custom hook is used to fetch users.
9
+
10
+ :::tip Context can be consumed in this way:
11
+
12
+ ```jsx
13
+ const {users, isLoading} = useSCFetchUsers();
14
+ ```
15
+ :::
16
+ * @param props
17
+ */
18
+ const useSCFetchUsers = (props) => {
19
+ const { search = '', exclude = '' } = props || {};
20
+ const [data, setData] = useState({ users: [], isLoading: false });
21
+ const fetchUsers = (next = Endpoints.UserAutocomplete.url(), searchParam, excludeParam) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const response = yield http.request({
23
+ url: next,
24
+ method: Endpoints.UserAutocomplete.method,
25
+ params: Object.assign({ search: searchParam }, (excludeParam && { exclude: excludeParam })),
26
+ });
27
+ const result = response.data;
28
+ if (result.next) {
29
+ return result.results.concat(yield fetchUsers(result.next, searchParam, excludeParam));
30
+ }
31
+ return result.results;
32
+ });
33
+ useEffect(() => {
34
+ if (!search)
35
+ return;
36
+ fetchUsers(undefined, search, exclude)
37
+ .then((users) => {
38
+ setData({ users, isLoading: false });
39
+ })
40
+ .catch((error) => {
41
+ console.error(error);
42
+ Logger.error(SCOPE_SC_CORE, 'Unable to retrieve users');
43
+ setData((prev) => (Object.assign(Object.assign({}, prev), { isLoading: false })));
44
+ });
45
+ }, [search, exclude]);
46
+ return data;
47
+ };
48
+ export default useSCFetchUsers;
@@ -30,7 +30,7 @@ export default function useSCJoinedCoursesManager(user?: SCUserType): {
30
30
  isLoading: (v: number | {
31
31
  id: number;
32
32
  }) => boolean;
33
- join: (course: SCCourseType, userId?: number) => Promise<any>;
33
+ join: (course: SCCourseType) => Promise<any>;
34
34
  leave: (course: SCCourseType) => Promise<any>;
35
35
  joinStatus: (course: SCCourseType) => string;
36
36
  refresh: () => void;