@selfcommunity/react-core 0.6.7-alpha.9 → 0.6.7-payments.143
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.
- package/lib/cjs/components/provider/SCUserProvider/index.js +6 -0
- package/lib/cjs/constants/Cache.d.ts +21 -2
- package/lib/cjs/constants/Cache.js +29 -4
- package/lib/cjs/constants/Preferences.d.ts +13 -0
- package/lib/cjs/constants/Preferences.js +24 -1
- package/lib/cjs/constants/Routes.d.ts +8 -0
- package/lib/cjs/constants/Routes.js +17 -1
- package/lib/cjs/hooks/useSCFetchCategories.d.ts +2 -0
- package/lib/cjs/hooks/useSCFetchCategories.js +7 -4
- package/lib/cjs/hooks/useSCFetchCourse.d.ts +23 -0
- package/lib/cjs/hooks/useSCFetchCourse.js +81 -0
- package/lib/cjs/hooks/useSCFetchCourses.d.ts +22 -0
- package/lib/cjs/hooks/useSCFetchCourses.js +83 -0
- package/lib/cjs/hooks/useSCFetchLesson.d.ts +22 -0
- package/lib/cjs/hooks/useSCFetchLesson.js +72 -0
- package/lib/cjs/hooks/useSCFetchLessonCommentObject.d.ts +23 -0
- package/lib/cjs/hooks/useSCFetchLessonCommentObject.js +72 -0
- package/lib/cjs/hooks/useSCFetchLessonCommentObjects.d.ts +48 -0
- package/lib/cjs/hooks/useSCFetchLessonCommentObjects.js +302 -0
- package/lib/cjs/hooks/useSCFetchUserBlockedBy.js +1 -1
- package/lib/cjs/hooks/useSCJoinedCoursesManager.d.ts +38 -0
- package/lib/cjs/hooks/useSCJoinedCoursesManager.js +277 -0
- package/lib/cjs/index.d.ts +7 -2
- package/lib/cjs/index.js +12 -2
- package/lib/cjs/themes/theme.js +12 -0
- package/lib/cjs/types/context.d.ts +36 -1
- package/lib/cjs/types/index.d.ts +2 -2
- package/lib/cjs/types/theme.d.ts +52 -0
- package/lib/esm/components/provider/SCUserProvider/index.js +6 -0
- package/lib/esm/constants/Cache.d.ts +21 -2
- package/lib/esm/constants/Cache.js +21 -2
- package/lib/esm/constants/Preferences.d.ts +13 -0
- package/lib/esm/constants/Preferences.js +23 -0
- package/lib/esm/constants/Routes.d.ts +8 -0
- package/lib/esm/constants/Routes.js +16 -0
- package/lib/esm/hooks/useSCFetchCategories.d.ts +2 -0
- package/lib/esm/hooks/useSCFetchCategories.js +7 -4
- package/lib/esm/hooks/useSCFetchCourse.d.ts +23 -0
- package/lib/esm/hooks/useSCFetchCourse.js +78 -0
- package/lib/esm/hooks/useSCFetchCourses.d.ts +22 -0
- package/lib/esm/hooks/useSCFetchCourses.js +81 -0
- package/lib/esm/hooks/useSCFetchLesson.d.ts +22 -0
- package/lib/esm/hooks/useSCFetchLesson.js +69 -0
- package/lib/esm/hooks/useSCFetchLessonCommentObject.d.ts +23 -0
- package/lib/esm/hooks/useSCFetchLessonCommentObject.js +69 -0
- package/lib/esm/hooks/useSCFetchLessonCommentObjects.d.ts +48 -0
- package/lib/esm/hooks/useSCFetchLessonCommentObjects.js +297 -0
- package/lib/esm/hooks/useSCFetchUserBlockedBy.js +1 -1
- package/lib/esm/hooks/useSCJoinedCoursesManager.d.ts +38 -0
- package/lib/esm/hooks/useSCJoinedCoursesManager.js +273 -0
- package/lib/esm/index.d.ts +7 -2
- package/lib/esm/index.js +6 -1
- package/lib/esm/themes/theme.js +12 -0
- package/lib/esm/types/context.d.ts +36 -1
- package/lib/esm/types/index.d.ts +2 -2
- package/lib/esm/types/theme.d.ts +52 -0
- package/lib/umd/react-core.js +1 -1
- package/package.json +6 -6
|
@@ -22,6 +22,7 @@ const useSCBlockedUsersManager_1 = tslib_1.__importDefault(require("../../../hoo
|
|
|
22
22
|
const Session = tslib_1.__importStar(require("../../../constants/Session"));
|
|
23
23
|
const useSCSubscribedGroupsManager_1 = tslib_1.__importDefault(require("../../../hooks/useSCSubscribedGroupsManager"));
|
|
24
24
|
const useSCSubscribedEventsManager_1 = tslib_1.__importDefault(require("../../../hooks/useSCSubscribedEventsManager"));
|
|
25
|
+
const useSCJoinedCoursesManager_1 = tslib_1.__importDefault(require("../../../hooks/useSCJoinedCoursesManager"));
|
|
25
26
|
/**
|
|
26
27
|
* SCUserContext (Authentication Context)
|
|
27
28
|
*
|
|
@@ -75,6 +76,7 @@ function SCUserProvider({ children }) {
|
|
|
75
76
|
const blockedUsersManager = (0, useSCBlockedUsersManager_1.default)(state.user);
|
|
76
77
|
const subscribedGroupsManager = (0, useSCSubscribedGroupsManager_1.default)(state.user);
|
|
77
78
|
const subscribedEventsManager = (0, useSCSubscribedEventsManager_1.default)(state.user);
|
|
79
|
+
const joinedCoursesManager = (0, useSCJoinedCoursesManager_1.default)(state.user);
|
|
78
80
|
/**
|
|
79
81
|
* Ref notifications subscribers: BLOCKED_USER, UNBLOCKED_USER
|
|
80
82
|
*/
|
|
@@ -127,6 +129,7 @@ function SCUserProvider({ children }) {
|
|
|
127
129
|
blockedUsersManager.refresh && blockedUsersManager.refresh();
|
|
128
130
|
subscribedGroupsManager.refresh && subscribedGroupsManager.refresh();
|
|
129
131
|
subscribedEventsManager.refresh && subscribedEventsManager.refresh();
|
|
132
|
+
joinedCoursesManager.refresh && joinedCoursesManager.refresh();
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
135
|
/**
|
|
@@ -224,6 +227,7 @@ function SCUserProvider({ children }) {
|
|
|
224
227
|
blockedUsers: blockedUsersManager,
|
|
225
228
|
groups: subscribedGroupsManager,
|
|
226
229
|
events: subscribedEventsManager,
|
|
230
|
+
courses: joinedCoursesManager,
|
|
227
231
|
},
|
|
228
232
|
}), [
|
|
229
233
|
state,
|
|
@@ -244,6 +248,8 @@ function SCUserProvider({ children }) {
|
|
|
244
248
|
subscribedGroupsManager.groups,
|
|
245
249
|
subscribedEventsManager.loading,
|
|
246
250
|
subscribedEventsManager.events,
|
|
251
|
+
joinedCoursesManager.loading,
|
|
252
|
+
joinedCoursesManager.emptyCache,
|
|
247
253
|
]);
|
|
248
254
|
/**
|
|
249
255
|
* We only want to render the underlying app after we
|
|
@@ -4,19 +4,35 @@
|
|
|
4
4
|
/** FEED OBJECT **/
|
|
5
5
|
export declare const FEED_OBJECT_CACHE_PREFIX_KEY = "_fo_";
|
|
6
6
|
export declare const getFeedObjectCacheKey: (id: any, type: any) => string;
|
|
7
|
-
/**
|
|
7
|
+
/** COMMENT OBJECT **/
|
|
8
8
|
export declare const COMMENT_OBJECT_CACHE_PREFIX_KEY = "_co_";
|
|
9
9
|
export declare const getCommentObjectCacheKey: (id: any) => string;
|
|
10
|
-
/**
|
|
10
|
+
/** COMMENT OBJECTS **/
|
|
11
11
|
export declare const COMMENT_OBJECTS_CACHE_PREFIX_KEY = "_cos_";
|
|
12
12
|
export declare const getCommentObjectsCacheKey: (id: any, type: any, next: any) => string;
|
|
13
13
|
export declare const getCommentObjectsCachePrefixKeys: (id: any, type: any) => string;
|
|
14
|
+
/** LESSON COMMENT OBJECT **/
|
|
15
|
+
export declare const LESSON_COMMENT_CACHE_PREFIX_KEY = "_lco_";
|
|
16
|
+
export declare const getLessonCommentCacheKey: (id: any) => string;
|
|
17
|
+
/** LESSON COMMENT OBJECTS **/
|
|
18
|
+
export declare const LESSON_COMMENTS_CACHE_PREFIX_KEY = "_lcos_";
|
|
19
|
+
export declare const getLessonCommentsCacheKey: (id: any, next: any) => string;
|
|
20
|
+
export declare const getLessonCommentsCachePrefixKeys: (id: any) => string;
|
|
14
21
|
/** CATEGORIES OBJECT **/
|
|
15
22
|
export declare const CATEGORIES_OBJECT_CACHE_PREFIX_KEY = "_cas_";
|
|
16
23
|
export declare const getCategoriesObjectCacheKey: () => string;
|
|
17
24
|
/** CATEGORY OBJECT **/
|
|
18
25
|
export declare const CATEGORY_OBJECT_CACHE_PREFIX_KEY = "_ca_";
|
|
19
26
|
export declare const getCategoryObjectCacheKey: (id: any) => string;
|
|
27
|
+
/** COURSE OBJECT **/
|
|
28
|
+
export declare const COURSE_OBJECT_CACHE_PREFIX_KEY = "_crs_";
|
|
29
|
+
export declare const getCourseObjectCacheKey: (id: any) => string;
|
|
30
|
+
/** COURSES OBJECT **/
|
|
31
|
+
export declare const COURSES_OBJECT_CACHE_PREFIX_KEY = "_crss_";
|
|
32
|
+
export declare const getCoursesObjectCacheKey: () => string;
|
|
33
|
+
/** LESSON OBJECT **/
|
|
34
|
+
export declare const LESSON_OBJECT_CACHE_PREFIX_KEY = "_lss_";
|
|
35
|
+
export declare const getLessonObjectCacheKey: (id: any) => string;
|
|
20
36
|
/** EVENT OBJECT **/
|
|
21
37
|
export declare const EVENT_OBJECT_CACHE_PREFIX_KEY = "_evt_";
|
|
22
38
|
export declare const getEventObjectCacheKey: (id: any) => string;
|
|
@@ -70,6 +86,9 @@ export declare const USER_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = "_uFoldWidget_
|
|
|
70
86
|
export declare const USER_EVENTS_STATE_CACHE_PREFIX_KEY = "_uEvents_";
|
|
71
87
|
export declare const USER_OTHER_EVENTS_STATE_CACHE_PREFIX_KEY = "_uOtherEvents_";
|
|
72
88
|
export declare const USER_PARTECIPANTS_EVENTS_STATE_CACHE_PREFIX_KEY = "_uPartecipantsEvents_";
|
|
89
|
+
export declare const USER_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = "_uPartecipantsCourses_";
|
|
90
|
+
export declare const USER_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY = "_uRequestsCourses_";
|
|
91
|
+
export declare const USER_COMMENTS_COURSES_STATE_CACHE_PREFIX_KEY = "_uCommentsCourses_";
|
|
73
92
|
export declare const USER_INVITED_EVENTS_STATE_CACHE_PREFIX_KEY = "_uInvitedEvents_";
|
|
74
93
|
export declare const USER_REQUESTS_EVENTS_STATE_CACHE_PREFIX_KEY = "_uRequestsEvents_";
|
|
75
94
|
export declare const USER_LIVE_STREAM_CACHE_PREFIX_KEY = "_uUserLives_";
|
|
@@ -3,22 +3,32 @@
|
|
|
3
3
|
* Cache prefixes
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.getWidgetStateCacheKey = exports.GROUPS_SUBSCRIBED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUPS_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_MEMBERS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.POLL_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.PEOPLE_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_PEOPLE_TOOLS_STATE_CACHE_PREFIX_KEY = exports.RELATED_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_SENT_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY = exports.USER_LIVE_STREAM_CACHE_PREFIX_KEY = exports.USER_REQUESTS_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_INVITED_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_PARTECIPANTS_EVENTS_STATE_CACHE_PREFIX_KEY = void 0;
|
|
6
|
+
exports.PM_SNIPPETS_OBJECT_CACHE_PREFIX_KEY = exports.getAdvObjectCacheKey = exports.ADV_OBJECT_CACHE_PREFIX_KEY = exports.getFeedSPCacheKey = exports.FEED_CACHE_SP_KEY = exports.getVirtualizedScrollStateCacheKey = exports.VIRTUALIZED_SCROLL_STATE_CACHE_PREFIX_KEY = exports.getStateFeedCacheKey = exports.FEED_STATE_CACHE_PREFIX_KEY = exports.getFeedCacheKey = exports.FEED_CACHE_PREFIX_KEY = exports.getBroadcastMessagesObjectCacheKey = exports.BROADCAST_MESSAGES_OBJECT_CACHE_PREFIX_KEY = exports.getContributorsCachePrefixKeys = exports.getContributorsCacheKey = exports.CONTRIBUTORS_CACHE_PREFIX_KEY = exports.getIncubatorObjectCacheKey = exports.INCUBATOR_OBJECT_CACHE_PREFIX_KEY = exports.getGroupsObjectCacheKey = exports.GROUPS_OBJECT_CACHE_PREFIX_KEY = exports.getGroupObjectCacheKey = exports.GROUP_OBJECT_CACHE_PREFIX_KEY = exports.getLiveStreamObjectCacheKey = exports.LIVESTREAM_OBJECT_CACHE_PREFIX_KEY = exports.getEventsObjectCacheKey = exports.EVENTS_OBJECT_CACHE_PREFIX_KEY = exports.getEventObjectCacheKey = exports.EVENT_OBJECT_CACHE_PREFIX_KEY = exports.getLessonObjectCacheKey = exports.LESSON_OBJECT_CACHE_PREFIX_KEY = exports.getCoursesObjectCacheKey = exports.COURSES_OBJECT_CACHE_PREFIX_KEY = exports.getCourseObjectCacheKey = exports.COURSE_OBJECT_CACHE_PREFIX_KEY = exports.getCategoryObjectCacheKey = exports.CATEGORY_OBJECT_CACHE_PREFIX_KEY = exports.getCategoriesObjectCacheKey = exports.CATEGORIES_OBJECT_CACHE_PREFIX_KEY = exports.getLessonCommentsCachePrefixKeys = exports.getLessonCommentsCacheKey = exports.LESSON_COMMENTS_CACHE_PREFIX_KEY = exports.getLessonCommentCacheKey = exports.LESSON_COMMENT_CACHE_PREFIX_KEY = exports.getCommentObjectsCachePrefixKeys = exports.getCommentObjectsCacheKey = exports.COMMENT_OBJECTS_CACHE_PREFIX_KEY = exports.getCommentObjectCacheKey = exports.COMMENT_OBJECT_CACHE_PREFIX_KEY = exports.getFeedObjectCacheKey = exports.FEED_OBJECT_CACHE_PREFIX_KEY = void 0;
|
|
7
|
+
exports.getWidgetStateCacheKey = exports.GROUPS_SUBSCRIBED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUPS_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.GROUP_MEMBERS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.POLL_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.INCUBATOR_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.PEOPLE_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_PEOPLE_TOOLS_STATE_CACHE_PREFIX_KEY = exports.RELATED_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.TRENDING_FEED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_SENT_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_CONNECTIONS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY = exports.USER_LIVE_STREAM_CACHE_PREFIX_KEY = exports.USER_REQUESTS_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_INVITED_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_COMMENTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USER_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USER_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USER_PARTECIPANTS_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_OTHER_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_EVENTS_STATE_CACHE_PREFIX_KEY = exports.USER_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.USER_FOLLOWERS_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_POPULAR_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_SUGGESTION_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = exports.CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = exports.getPmSnippetObjectCacheKey = exports.PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = exports.getPmSnippetsObjectCacheKey = void 0;
|
|
8
8
|
/** FEED OBJECT **/
|
|
9
9
|
exports.FEED_OBJECT_CACHE_PREFIX_KEY = '_fo_';
|
|
10
10
|
const getFeedObjectCacheKey = (id, type) => `${exports.FEED_OBJECT_CACHE_PREFIX_KEY}${type}_${id}`;
|
|
11
11
|
exports.getFeedObjectCacheKey = getFeedObjectCacheKey;
|
|
12
|
-
/**
|
|
12
|
+
/** COMMENT OBJECT **/
|
|
13
13
|
exports.COMMENT_OBJECT_CACHE_PREFIX_KEY = '_co_';
|
|
14
14
|
const getCommentObjectCacheKey = (id) => `${exports.COMMENT_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
15
15
|
exports.getCommentObjectCacheKey = getCommentObjectCacheKey;
|
|
16
|
-
/**
|
|
16
|
+
/** COMMENT OBJECTS **/
|
|
17
17
|
exports.COMMENT_OBJECTS_CACHE_PREFIX_KEY = '_cos_';
|
|
18
18
|
const getCommentObjectsCacheKey = (id, type, next) => `${exports.COMMENT_OBJECTS_CACHE_PREFIX_KEY}${type}_${id}_${next}`;
|
|
19
19
|
exports.getCommentObjectsCacheKey = getCommentObjectsCacheKey;
|
|
20
20
|
const getCommentObjectsCachePrefixKeys = (id, type) => `${exports.COMMENT_OBJECTS_CACHE_PREFIX_KEY}${type}_${id}`;
|
|
21
21
|
exports.getCommentObjectsCachePrefixKeys = getCommentObjectsCachePrefixKeys;
|
|
22
|
+
/** LESSON COMMENT OBJECT **/
|
|
23
|
+
exports.LESSON_COMMENT_CACHE_PREFIX_KEY = '_lco_';
|
|
24
|
+
const getLessonCommentCacheKey = (id) => `${exports.LESSON_COMMENT_CACHE_PREFIX_KEY}${id}`;
|
|
25
|
+
exports.getLessonCommentCacheKey = getLessonCommentCacheKey;
|
|
26
|
+
/** LESSON COMMENT OBJECTS **/
|
|
27
|
+
exports.LESSON_COMMENTS_CACHE_PREFIX_KEY = '_lcos_';
|
|
28
|
+
const getLessonCommentsCacheKey = (id, next) => `${exports.LESSON_COMMENTS_CACHE_PREFIX_KEY}${id}_${next}`;
|
|
29
|
+
exports.getLessonCommentsCacheKey = getLessonCommentsCacheKey;
|
|
30
|
+
const getLessonCommentsCachePrefixKeys = (id) => `${exports.LESSON_COMMENTS_CACHE_PREFIX_KEY}${id}`;
|
|
31
|
+
exports.getLessonCommentsCachePrefixKeys = getLessonCommentsCachePrefixKeys;
|
|
22
32
|
/** CATEGORIES OBJECT **/
|
|
23
33
|
exports.CATEGORIES_OBJECT_CACHE_PREFIX_KEY = '_cas_';
|
|
24
34
|
const getCategoriesObjectCacheKey = () => `${exports.CATEGORIES_OBJECT_CACHE_PREFIX_KEY}`;
|
|
@@ -27,6 +37,18 @@ exports.getCategoriesObjectCacheKey = getCategoriesObjectCacheKey;
|
|
|
27
37
|
exports.CATEGORY_OBJECT_CACHE_PREFIX_KEY = '_ca_';
|
|
28
38
|
const getCategoryObjectCacheKey = (id) => `${exports.CATEGORY_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
29
39
|
exports.getCategoryObjectCacheKey = getCategoryObjectCacheKey;
|
|
40
|
+
/** COURSE OBJECT **/
|
|
41
|
+
exports.COURSE_OBJECT_CACHE_PREFIX_KEY = '_crs_';
|
|
42
|
+
const getCourseObjectCacheKey = (id) => `${exports.COURSE_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
43
|
+
exports.getCourseObjectCacheKey = getCourseObjectCacheKey;
|
|
44
|
+
/** COURSES OBJECT **/
|
|
45
|
+
exports.COURSES_OBJECT_CACHE_PREFIX_KEY = '_crss_';
|
|
46
|
+
const getCoursesObjectCacheKey = () => `${exports.COURSES_OBJECT_CACHE_PREFIX_KEY}`;
|
|
47
|
+
exports.getCoursesObjectCacheKey = getCoursesObjectCacheKey;
|
|
48
|
+
/** LESSON OBJECT **/
|
|
49
|
+
exports.LESSON_OBJECT_CACHE_PREFIX_KEY = '_lss_';
|
|
50
|
+
const getLessonObjectCacheKey = (id) => `${exports.LESSON_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
51
|
+
exports.getLessonObjectCacheKey = getLessonObjectCacheKey;
|
|
30
52
|
/** EVENT OBJECT **/
|
|
31
53
|
exports.EVENT_OBJECT_CACHE_PREFIX_KEY = '_evt_';
|
|
32
54
|
const getEventObjectCacheKey = (id) => `${exports.EVENT_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
@@ -100,6 +122,9 @@ exports.USER_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = '_uFoldWidget_';
|
|
|
100
122
|
exports.USER_EVENTS_STATE_CACHE_PREFIX_KEY = '_uEvents_';
|
|
101
123
|
exports.USER_OTHER_EVENTS_STATE_CACHE_PREFIX_KEY = '_uOtherEvents_';
|
|
102
124
|
exports.USER_PARTECIPANTS_EVENTS_STATE_CACHE_PREFIX_KEY = '_uPartecipantsEvents_';
|
|
125
|
+
exports.USER_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = '_uPartecipantsCourses_';
|
|
126
|
+
exports.USER_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY = '_uRequestsCourses_';
|
|
127
|
+
exports.USER_COMMENTS_COURSES_STATE_CACHE_PREFIX_KEY = '_uCommentsCourses_';
|
|
103
128
|
exports.USER_INVITED_EVENTS_STATE_CACHE_PREFIX_KEY = '_uInvitedEvents_';
|
|
104
129
|
exports.USER_REQUESTS_EVENTS_STATE_CACHE_PREFIX_KEY = '_uRequestsEvents_';
|
|
105
130
|
exports.USER_LIVE_STREAM_CACHE_PREFIX_KEY = '_uUserLives_';
|
|
@@ -135,11 +135,18 @@ export declare const CONFIGURATIONS_EVENTS_ENABLED: string;
|
|
|
135
135
|
export declare const CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED: string;
|
|
136
136
|
export declare const CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED: string;
|
|
137
137
|
export declare const CONFIGURATIONS_EVENTS_PRIVATE_ENABLED: string;
|
|
138
|
+
export declare const CONFIGURATIONS_COURSES_ENABLED: string;
|
|
139
|
+
export declare const CONFIGURATIONS_COURSES_ONLY_STAFF_ENABLED: string;
|
|
140
|
+
export declare const CONFIGURATIONS_COURSES_VISIBILITY_ENABLED: string;
|
|
141
|
+
export declare const CONFIGURATIONS_COURSES_PRIVATE_ENABLED: string;
|
|
138
142
|
export declare const CONFIGURATIONS_ONBOARDING_ENABLED: string;
|
|
139
143
|
export declare const CONFIGURATIONS_ONBOARDING_HIDDEN: string;
|
|
140
144
|
export declare const CONFIGURATIONS_LIVE_STREAM_ENABLED: string;
|
|
141
145
|
export declare const CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED: string;
|
|
146
|
+
export declare const CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED: string;
|
|
142
147
|
export declare const CONFIGURATIONS_SUBSCRIPTION_TIER: string;
|
|
148
|
+
export declare const CONFIGURATIONS_PAYMENTS_ENABLED: string;
|
|
149
|
+
export declare const CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID: string;
|
|
143
150
|
/**
|
|
144
151
|
* PROVIDERS
|
|
145
152
|
*/
|
|
@@ -166,6 +173,12 @@ export declare const PROVIDERS_WEB_PUSH_ENABLED: string;
|
|
|
166
173
|
export declare const WEBMASTER_META_ROBOTS: string;
|
|
167
174
|
export declare const WEBMASTER_META_TITLE_HOME_NOT_LOGGED: string;
|
|
168
175
|
export declare const WEBMASTER_META_DESCRIPTION: string;
|
|
176
|
+
/**
|
|
177
|
+
* STATIC
|
|
178
|
+
*/
|
|
179
|
+
export declare const STATIC_ENVIRONMENT: string;
|
|
180
|
+
export declare const STATIC_STACKID: string;
|
|
181
|
+
export declare const STATIC_STRIPE_PUBLIC_KEY: string;
|
|
169
182
|
export declare const getPreferenceSection: (value: any) => any;
|
|
170
183
|
export declare const getPreferenceName: (value: any) => any;
|
|
171
184
|
export declare const getPreference: (value: any) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ADDONS_SHARE_POST_ON_FACEBOOK_ENABLED = exports.ADDONS_POST_GEOLOCATION_ENABLED = exports.ADDONS_REGISTRATION_WIZARD = exports.ADDONS_POLLS_ENABLED = exports.ADDONS_LOYALTY_POINTS_COLLECTION = exports.ADDONS_INCUBATOR_SUBSCRIBERS = exports.ADDONS_INCUBATOR_ENABLED = exports.ADDONS_CLOSED_COMMUNITY = exports.ADDONS_AFFINITY_ENABLED = exports.POINTS_DAILY_VISIT = exports.POINTS_APP_USED = exports.POINTS_SOCIAL_SHARE = exports.POINTS_CONNECTION_OR_FOLLOWER = exports.POINTS_RECEIVE_VOTE = exports.POINTS_MAKE_COMMENT = exports.POINTS_MAKE_POST = exports.POINTS_MAKE_DISCUSSION = exports.LOYALTY_PRIZE_C_IMAGE = exports.LOYALTY_PRIZE_B_IMAGE = exports.LOYALTY_PRIZE_A_IMAGE = exports.STAFF_STAFF_BADGE_LABEL = exports.STAFF_STAFF_BADGE_ICON = exports.IMAGES_ERRORPAGES_IMAGE = exports.IMAGES_ERROR_503 = exports.IMAGES_ERROR_404 = exports.IMAGES_USER_DEFAULT_COVER = exports.IMAGES_APP_ICON = exports.COVERS_VISIBILITY = exports.COVERS_COVER_4_HP_M1920 = exports.COVERS_COVER_3_HP_M1920 = exports.COVERS_COVER_2_HP_M1920 = exports.COVERS_COVER_1_HP_M1920 = exports.COLORS_COLORFONTSECONDARY = exports.COLORS_COLORFONT = exports.COLORS_NAVBARBACK = exports.COLORS_COLORSECONDARY = exports.COLORS_COLORPRIMARY = exports.COLORS_COLORBACK = exports.LOGO_NAVBAR_LOGO_MOBILE = exports.LOGO_NAVBAR_LOGO = exports.STYLE_FONT_FAMILY = exports.TEXT_ERROR_PAGES_SUBTITLE = exports.TEXT_ERROR_PAGES_TITLE = exports.TEXT_APPLICATION_COPYRIGHT = exports.TEXT_APPLICATION_SLOGAN2 = exports.TEXT_APPLICATION_SLOGAN1 = exports.TEXT_APPLICATION_NAME = exports.DEFAULT_GLOBAL_PREFERENCES_OPTION = exports.GLOBAL_PREFERENCES_OPTION = exports.PREFERENCES_OPTION = void 0;
|
|
4
4
|
exports.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = exports.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = exports.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_EVENTS_ENABLED = exports.CONFIGURATIONS_GROUPS_PRIVATE_ENABLED = exports.CONFIGURATIONS_GROUPS_VISIBILITY_ENABLED = exports.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_GROUPS_ENABLED = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT = exports.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED = exports.CONFIGURATIONS_GDPR_SIGNUP_ACCEPT_HTML = exports.CONFIGURATIONS_GDPR_COOKIE_CONSENT_EXTERNAL_HTML = exports.CONFIGURATIONS_TAG_MANAGER_CONTAINER_ID = exports.CONFIGURATIONS_USER_METADATA_DEFINITIONS = exports.CONFIGURATIONS_APP_URL = exports.CONFIGURATIONS_URL_TEMPLATE_LIVE_STREAM = exports.CONFIGURATIONS_URL_TEMPLATE_INCUBATOR = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PRIVATE_MESSAGES = exports.CONFIGURATIONS_URL_TEMPLATE_NOTIFICATIONS = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PROFILE_SETTINGS = exports.CONFIGURATIONS_URL_TEMPLATE_USER_PROFILE = exports.CONFIGURATIONS_URL_TEMPLATE_CATEGORIES_LIST = exports.CONFIGURATIONS_URL_TEMPLATE_CATEGORY = exports.CONFIGURATIONS_URL_TEMPLATE_COMMENT = exports.CONFIGURATIONS_URL_TEMPLATE_STATUS = exports.CONFIGURATIONS_URL_TEMPLATE_DISCUSSION = exports.CONFIGURATIONS_URL_TEMPLATE_POST = exports.CONFIGURATIONS_URL_TEMPLATE_VERIFY_EMAIL = exports.CONFIGURATIONS_URL_TEMPLATE_PASSWORD_RECOVER = exports.CONFIGURATIONS_URL_TEMPLATE_EMAIL_UNSUBSCRIBE = exports.CONFIGURATIONS_URL_TEMPLATE_EMAIL_SETTINGS = exports.CONFIGURATIONS_STATUS_TYPE_ENABLED = exports.CONFIGURATIONS_DISCUSSION_TYPE_ENABLED = exports.CONFIGURATIONS_POST_TYPE_ENABLED = exports.CONFIGURATIONS_USERS_APPROVAL_ENABLED = exports.CONFIGURATIONS_CONTENT_AVAILABILITY = exports.CONFIGURATIONS_STREAM_QUALITY = exports.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_PEOPLE_SEARCH_ENABLED = exports.CONFIGURATIONS_MANUAL_CATEGORIES_ORDER_ENABLED = exports.CONFIGURATIONS_HOME_STREAM_ORDER_BY = exports.CONFIGURATIONS_EXPLORE_STREAM_ORDER_BY = exports.CONFIGURATIONS_EXPLORE_STREAM_ENABLED = exports.CONFIGURATIONS_FOLLOW_ENABLED = exports.ADVERTISING_CUSTOM_ADV_ONLY_FOR_ANONYMOUS_USERS_ENABLED = exports.ADVERTISING_CUSTOM_ADV_ENABLED = exports.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED = exports.ADDONS_SHARE_POST_ON_TWITTER_ENABLED = void 0;
|
|
5
|
-
exports.DATA_TYPES = exports.getPreference = exports.getPreferenceName = exports.getPreferenceSection = exports.WEBMASTER_META_DESCRIPTION = exports.WEBMASTER_META_TITLE_HOME_NOT_LOGGED = exports.WEBMASTER_META_ROBOTS = exports.PROVIDERS_WEB_PUSH_ENABLED = exports.PROVIDERS_WEB_PUSH_PUBLIC_KEY = exports.PROVIDERS_GOOGLE_APP_SECRET = exports.PROVIDERS_GOOGLE_APP_KEY = exports.PROVIDERS_GOOGLE_SIGNIN_ENABLED = exports.PROVIDERS_GOOGLE_GEOCODING_API_KEY = exports.PROVIDERS_TWITTER_APP_SECRET = exports.PROVIDERS_TWITTER_APP_KEY = exports.PROVIDERS_TWITTER_SIGNIN_ENABLED = exports.PROVIDERS_LINKEDIN_APP_SECRET = exports.PROVIDERS_LINKEDIN_APP_KEY = exports.PROVIDERS_LINKEDIN_SIGNIN_ENABLED = exports.PROVIDERS_FACEBOOK_APP_SECRET = exports.PROVIDERS_FACEBOOK_APP_KEY = exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED = exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY = exports.PROVIDERS_APP_URL_ON_APP_STORE = exports.CONFIGURATIONS_SUBSCRIPTION_TIER = exports.CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_LIVE_STREAM_ENABLED = exports.CONFIGURATIONS_ONBOARDING_HIDDEN = exports.CONFIGURATIONS_ONBOARDING_ENABLED = void 0;
|
|
5
|
+
exports.DATA_TYPES = exports.getPreference = exports.getPreferenceName = exports.getPreferenceSection = exports.STATIC_STRIPE_PUBLIC_KEY = exports.STATIC_STACKID = exports.STATIC_ENVIRONMENT = exports.WEBMASTER_META_DESCRIPTION = exports.WEBMASTER_META_TITLE_HOME_NOT_LOGGED = exports.WEBMASTER_META_ROBOTS = exports.PROVIDERS_WEB_PUSH_ENABLED = exports.PROVIDERS_WEB_PUSH_PUBLIC_KEY = exports.PROVIDERS_GOOGLE_APP_SECRET = exports.PROVIDERS_GOOGLE_APP_KEY = exports.PROVIDERS_GOOGLE_SIGNIN_ENABLED = exports.PROVIDERS_GOOGLE_GEOCODING_API_KEY = exports.PROVIDERS_TWITTER_APP_SECRET = exports.PROVIDERS_TWITTER_APP_KEY = exports.PROVIDERS_TWITTER_SIGNIN_ENABLED = exports.PROVIDERS_LINKEDIN_APP_SECRET = exports.PROVIDERS_LINKEDIN_APP_KEY = exports.PROVIDERS_LINKEDIN_SIGNIN_ENABLED = exports.PROVIDERS_FACEBOOK_APP_SECRET = exports.PROVIDERS_FACEBOOK_APP_KEY = exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED = exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY = exports.PROVIDERS_APP_URL_ON_APP_STORE = exports.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID = exports.CONFIGURATIONS_PAYMENTS_ENABLED = exports.CONFIGURATIONS_SUBSCRIPTION_TIER = exports.CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED = exports.CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_LIVE_STREAM_ENABLED = exports.CONFIGURATIONS_ONBOARDING_HIDDEN = exports.CONFIGURATIONS_ONBOARDING_ENABLED = exports.CONFIGURATIONS_COURSES_PRIVATE_ENABLED = exports.CONFIGURATIONS_COURSES_VISIBILITY_ENABLED = exports.CONFIGURATIONS_COURSES_ONLY_STAFF_ENABLED = exports.CONFIGURATIONS_COURSES_ENABLED = void 0;
|
|
6
6
|
const types_1 = require("@selfcommunity/types");
|
|
7
7
|
/**
|
|
8
8
|
* DEFAULT CONF VALIDATION OPTION
|
|
@@ -141,11 +141,18 @@ exports.CONFIGURATIONS_EVENTS_ENABLED = `${types_1.SCPreferenceSection.CONFIGURA
|
|
|
141
141
|
exports.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.EVENTS_ONLY_STAFF_ENABLED}`;
|
|
142
142
|
exports.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.EVENTS_VISIBILITY_ENABLED}`;
|
|
143
143
|
exports.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.EVENTS_PRIVATE_ENABLED}`;
|
|
144
|
+
exports.CONFIGURATIONS_COURSES_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.COURSES_ENABLED}`;
|
|
145
|
+
exports.CONFIGURATIONS_COURSES_ONLY_STAFF_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.COURSES_ONLY_STAFF_ENABLED}`;
|
|
146
|
+
exports.CONFIGURATIONS_COURSES_VISIBILITY_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.COURSES_VISIBILITY_ENABLED}`;
|
|
147
|
+
exports.CONFIGURATIONS_COURSES_PRIVATE_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.COURSES_PRIVATE_ENABLED}`;
|
|
144
148
|
exports.CONFIGURATIONS_ONBOARDING_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.ONBOARDING_ENABLED}`;
|
|
145
149
|
exports.CONFIGURATIONS_ONBOARDING_HIDDEN = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.ONBOARDING_HIDDEN}`;
|
|
146
150
|
exports.CONFIGURATIONS_LIVE_STREAM_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.LIVE_STREAM_ENABLED}`;
|
|
147
151
|
exports.CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.LIVE_STREAM_ONLY_STAFF_ENABLED}`;
|
|
152
|
+
exports.CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.LIVE_STREAM_VIDEO_CONFERENCE_ENABLED}`;
|
|
148
153
|
exports.CONFIGURATIONS_SUBSCRIPTION_TIER = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.SUBSCRIPTION_TIER}`;
|
|
154
|
+
exports.CONFIGURATIONS_PAYMENTS_ENABLED = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.PAYMENTS_ENABLED}`;
|
|
155
|
+
exports.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID = `${types_1.SCPreferenceSection.CONFIGURATIONS}.${types_1.SCPreferenceName.STRIPE_CONNECTED_ACCOUNT_ID}`;
|
|
149
156
|
/**
|
|
150
157
|
* PROVIDERS
|
|
151
158
|
*/
|
|
@@ -172,6 +179,12 @@ exports.PROVIDERS_WEB_PUSH_ENABLED = `${types_1.SCPreferenceSection.PROVIDERS}.$
|
|
|
172
179
|
exports.WEBMASTER_META_ROBOTS = `${types_1.SCPreferenceSection.WEBMASTER}.${types_1.SCPreferenceName.META_ROBOTS}`;
|
|
173
180
|
exports.WEBMASTER_META_TITLE_HOME_NOT_LOGGED = `${types_1.SCPreferenceSection.WEBMASTER}.${types_1.SCPreferenceName.META_TITLE_HOME_NOT_LOGGED}`;
|
|
174
181
|
exports.WEBMASTER_META_DESCRIPTION = `${types_1.SCPreferenceSection.WEBMASTER}.${types_1.SCPreferenceName.META_DESCRIPTION}`;
|
|
182
|
+
/**
|
|
183
|
+
* STATIC
|
|
184
|
+
*/
|
|
185
|
+
exports.STATIC_ENVIRONMENT = `${types_1.SCPreferenceSection.STATIC}.${types_1.SCPreferenceName.ENVIRONMENT}`;
|
|
186
|
+
exports.STATIC_STACKID = `${types_1.SCPreferenceSection.STATIC}.${types_1.SCPreferenceName.STACK_ID}`;
|
|
187
|
+
exports.STATIC_STRIPE_PUBLIC_KEY = `${types_1.SCPreferenceSection.STATIC}.${types_1.SCPreferenceName.STRIPE_PUBLIC_KEY}`;
|
|
175
188
|
const booleanType = (value) => {
|
|
176
189
|
if (value === 'True') {
|
|
177
190
|
return true;
|
|
@@ -294,11 +307,18 @@ exports.DATA_TYPES = {
|
|
|
294
307
|
[exports.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED]: booleanType,
|
|
295
308
|
[exports.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED]: booleanType,
|
|
296
309
|
[exports.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED]: booleanType,
|
|
310
|
+
[exports.CONFIGURATIONS_COURSES_ENABLED]: booleanType,
|
|
311
|
+
[exports.CONFIGURATIONS_COURSES_ONLY_STAFF_ENABLED]: booleanType,
|
|
312
|
+
[exports.CONFIGURATIONS_COURSES_VISIBILITY_ENABLED]: booleanType,
|
|
313
|
+
[exports.CONFIGURATIONS_COURSES_PRIVATE_ENABLED]: booleanType,
|
|
297
314
|
[exports.CONFIGURATIONS_ONBOARDING_ENABLED]: booleanType,
|
|
298
315
|
[exports.CONFIGURATIONS_ONBOARDING_HIDDEN]: booleanType,
|
|
299
316
|
[exports.CONFIGURATIONS_LIVE_STREAM_ENABLED]: booleanType,
|
|
300
317
|
[exports.CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED]: booleanType,
|
|
318
|
+
[exports.CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED]: booleanType,
|
|
301
319
|
[exports.CONFIGURATIONS_SUBSCRIPTION_TIER]: stringType,
|
|
320
|
+
[exports.CONFIGURATIONS_PAYMENTS_ENABLED]: booleanType,
|
|
321
|
+
[exports.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID]: stringType,
|
|
302
322
|
[exports.PROVIDERS_APP_URL_ON_APP_STORE]: stringType,
|
|
303
323
|
[exports.PROVIDERS_APP_URL_ON_GOOGLE_PLAY]: stringType,
|
|
304
324
|
[exports.PROVIDERS_FACEBOOK_SIGNIN_ENABLED]: stringType,
|
|
@@ -319,4 +339,7 @@ exports.DATA_TYPES = {
|
|
|
319
339
|
[exports.WEBMASTER_META_ROBOTS]: stringType,
|
|
320
340
|
[exports.WEBMASTER_META_TITLE_HOME_NOT_LOGGED]: stringType,
|
|
321
341
|
[exports.WEBMASTER_META_DESCRIPTION]: stringType,
|
|
342
|
+
[exports.STATIC_ENVIRONMENT]: stringType,
|
|
343
|
+
[exports.STATIC_STACKID]: stringType,
|
|
344
|
+
[exports.STATIC_STRIPE_PUBLIC_KEY]: stringType,
|
|
322
345
|
};
|
|
@@ -38,10 +38,18 @@ export declare const GROUPS_ROUTE_NAME = "groups";
|
|
|
38
38
|
export declare const GROUPS_SUBSCRIBED_ROUTE_NAME = "groups_subscribed";
|
|
39
39
|
export declare const EVENT_ROUTE_NAME = "event";
|
|
40
40
|
export declare const EVENTS_ROUTE_NAME = "events";
|
|
41
|
+
export declare const COURSE_ROUTE_NAME = "course";
|
|
42
|
+
export declare const COURSE_EDIT_ROUTE_NAME = "course_edit";
|
|
43
|
+
export declare const COURSE_DASHBOARD_ROUTE_NAME = "course_dashboard";
|
|
44
|
+
export declare const COURSE_LESSON_ROUTE_NAME = "course_lesson";
|
|
45
|
+
export declare const COURSE_LESSON_EDIT_ROUTE_NAME = "course_lesson_edit";
|
|
46
|
+
export declare const COURSE_LESSON_COMMENT_ROUTE_NAME = "course_lesson_comment";
|
|
47
|
+
export declare const COURSES_ROUTE_NAME = "courses";
|
|
41
48
|
export declare const EVENTS_SUGGESTED_ROUTE_NAME = "events_suggested";
|
|
42
49
|
export declare const EVENTS_SUBSCRIBED_ROUTE_NAME = "events_subscribed";
|
|
43
50
|
export declare const EVENTS_HIGHLIGHT_ROUTE_NAME = "events_highlight";
|
|
44
51
|
export declare const LIVESTREAM_ROUTE_NAME = "live";
|
|
52
|
+
export declare const CHECKOUT_PAYMENT = "checkout_payment";
|
|
45
53
|
/**
|
|
46
54
|
* Default Routes
|
|
47
55
|
* @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}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultRoutes = exports.LIVESTREAM_ROUTE_NAME = exports.EVENTS_HIGHLIGHT_ROUTE_NAME = exports.EVENTS_SUBSCRIBED_ROUTE_NAME = exports.EVENTS_SUGGESTED_ROUTE_NAME = exports.EVENTS_ROUTE_NAME = exports.EVENT_ROUTE_NAME = exports.GROUPS_SUBSCRIBED_ROUTE_NAME = exports.GROUPS_ROUTE_NAME = exports.GROUP_MESSAGES_ROUTE_NAME = exports.GROUP_MEMBERS_ROUTE_NAME = exports.GROUP_ROUTE_NAME = exports.LEGAL_PAGES_ROUTE_NAME = exports.CUSTOM_PAGES_ROUTE_NAME = exports.RECOVER_ROUTE_NAME = exports.SIGNUP_ROUTE_NAME = exports.SIGNIN_ROUTE_NAME = exports.INCUBATOR_ROUTE_NAME = exports.LOYALTY_ROUTE_NAME = exports.USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = exports.USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME = exports.USER_PROFILE_CATEGORIES_ROUTE_NAME = exports.USER_PROFILE_CONNECTIONS_REQUESTS_SENT_ROUTE_NAME = exports.USER_PROFILE_CONNECTIONS_REQUESTS_ROUTE_NAME = exports.USER_PROFILE_CONNECTIONS_ROUTE_NAME = exports.USER_PROFILE_FOLLOWERS_ROUTE_NAME = exports.USER_PROFILE_FOLLOWINGS_ROUTE_NAME = exports.USER_PRIVATE_MESSAGES_ROUTE_NAME = exports.USER_NOTIFICATIONS_ROUTE_NAME = exports.USER_PROFILE_SETTINGS_ROUTE_NAME = exports.USER_PROFILE_ROUTE_NAME = exports.CATEGORIES_LIST_ROUTE_NAME = exports.CATEGORY_TRENDING_FEED_ROUTE_NAME = exports.CATEGORY_ROUTE_NAME = exports.COMMENT_ROUTE_NAME = exports.STATUS_ROUTE_NAME = exports.DISCUSSION_ROUTE_NAME = exports.POST_ROUTE_NAME = exports.EXPLORE_ROUTE_NAME = exports.HOME_ROUTE_NAME = exports.ROUTER_OPTION = exports.PORTAL_OPTION = void 0;
|
|
3
|
+
exports.defaultRoutes = exports.CHECKOUT_PAYMENT = exports.LIVESTREAM_ROUTE_NAME = exports.EVENTS_HIGHLIGHT_ROUTE_NAME = exports.EVENTS_SUBSCRIBED_ROUTE_NAME = exports.EVENTS_SUGGESTED_ROUTE_NAME = exports.COURSES_ROUTE_NAME = exports.COURSE_LESSON_COMMENT_ROUTE_NAME = exports.COURSE_LESSON_EDIT_ROUTE_NAME = exports.COURSE_LESSON_ROUTE_NAME = exports.COURSE_DASHBOARD_ROUTE_NAME = exports.COURSE_EDIT_ROUTE_NAME = exports.COURSE_ROUTE_NAME = exports.EVENTS_ROUTE_NAME = exports.EVENT_ROUTE_NAME = exports.GROUPS_SUBSCRIBED_ROUTE_NAME = exports.GROUPS_ROUTE_NAME = exports.GROUP_MESSAGES_ROUTE_NAME = exports.GROUP_MEMBERS_ROUTE_NAME = exports.GROUP_ROUTE_NAME = exports.LEGAL_PAGES_ROUTE_NAME = exports.CUSTOM_PAGES_ROUTE_NAME = exports.RECOVER_ROUTE_NAME = exports.SIGNUP_ROUTE_NAME = exports.SIGNIN_ROUTE_NAME = exports.INCUBATOR_ROUTE_NAME = exports.LOYALTY_ROUTE_NAME = exports.USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = exports.USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME = exports.USER_PROFILE_CATEGORIES_ROUTE_NAME = exports.USER_PROFILE_CONNECTIONS_REQUESTS_SENT_ROUTE_NAME = exports.USER_PROFILE_CONNECTIONS_REQUESTS_ROUTE_NAME = exports.USER_PROFILE_CONNECTIONS_ROUTE_NAME = exports.USER_PROFILE_FOLLOWERS_ROUTE_NAME = exports.USER_PROFILE_FOLLOWINGS_ROUTE_NAME = exports.USER_PRIVATE_MESSAGES_ROUTE_NAME = exports.USER_NOTIFICATIONS_ROUTE_NAME = exports.USER_PROFILE_SETTINGS_ROUTE_NAME = exports.USER_PROFILE_ROUTE_NAME = exports.CATEGORIES_LIST_ROUTE_NAME = exports.CATEGORY_TRENDING_FEED_ROUTE_NAME = exports.CATEGORY_ROUTE_NAME = exports.COMMENT_ROUTE_NAME = exports.STATUS_ROUTE_NAME = exports.DISCUSSION_ROUTE_NAME = exports.POST_ROUTE_NAME = exports.EXPLORE_ROUTE_NAME = exports.HOME_ROUTE_NAME = exports.ROUTER_OPTION = exports.PORTAL_OPTION = void 0;
|
|
4
4
|
exports.PORTAL_OPTION = 'portal';
|
|
5
5
|
exports.ROUTER_OPTION = 'router';
|
|
6
6
|
/**
|
|
@@ -41,10 +41,18 @@ exports.GROUPS_ROUTE_NAME = 'groups';
|
|
|
41
41
|
exports.GROUPS_SUBSCRIBED_ROUTE_NAME = 'groups_subscribed';
|
|
42
42
|
exports.EVENT_ROUTE_NAME = 'event';
|
|
43
43
|
exports.EVENTS_ROUTE_NAME = 'events';
|
|
44
|
+
exports.COURSE_ROUTE_NAME = 'course';
|
|
45
|
+
exports.COURSE_EDIT_ROUTE_NAME = 'course_edit';
|
|
46
|
+
exports.COURSE_DASHBOARD_ROUTE_NAME = 'course_dashboard';
|
|
47
|
+
exports.COURSE_LESSON_ROUTE_NAME = 'course_lesson';
|
|
48
|
+
exports.COURSE_LESSON_EDIT_ROUTE_NAME = 'course_lesson_edit';
|
|
49
|
+
exports.COURSE_LESSON_COMMENT_ROUTE_NAME = 'course_lesson_comment';
|
|
50
|
+
exports.COURSES_ROUTE_NAME = 'courses';
|
|
44
51
|
exports.EVENTS_SUGGESTED_ROUTE_NAME = 'events_suggested';
|
|
45
52
|
exports.EVENTS_SUBSCRIBED_ROUTE_NAME = 'events_subscribed';
|
|
46
53
|
exports.EVENTS_HIGHLIGHT_ROUTE_NAME = 'events_highlight';
|
|
47
54
|
exports.LIVESTREAM_ROUTE_NAME = 'live';
|
|
55
|
+
exports.CHECKOUT_PAYMENT = 'checkout_payment';
|
|
48
56
|
/**
|
|
49
57
|
* Default Routes
|
|
50
58
|
* @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}}
|
|
@@ -88,5 +96,13 @@ exports.defaultRoutes = {
|
|
|
88
96
|
[exports.EVENT_ROUTE_NAME]: '/event/:id/:slug/',
|
|
89
97
|
[exports.EVENTS_SUBSCRIBED_ROUTE_NAME]: '/events/subscribed/',
|
|
90
98
|
[exports.EVENTS_HIGHLIGHT_ROUTE_NAME]: '/events/highlight/',
|
|
99
|
+
[exports.COURSE_ROUTE_NAME]: '/course/:id/:slug/',
|
|
100
|
+
[exports.COURSES_ROUTE_NAME]: '/courses/',
|
|
101
|
+
[exports.COURSE_EDIT_ROUTE_NAME]: '/course/:id/:slug/edit/:tab',
|
|
102
|
+
[exports.COURSE_DASHBOARD_ROUTE_NAME]: '/course/:id/:slug/dashboard',
|
|
103
|
+
[exports.COURSE_LESSON_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/',
|
|
104
|
+
[exports.COURSE_LESSON_EDIT_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/edit',
|
|
105
|
+
[exports.COURSE_LESSON_COMMENT_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/comment/:comment_id',
|
|
91
106
|
[exports.LIVESTREAM_ROUTE_NAME]: '/live/:slug/',
|
|
107
|
+
[exports.CHECKOUT_PAYMENT]: '/checkout/:content_type/:content_id/price/:price_id',
|
|
92
108
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SCCategoryType } from '@selfcommunity/types';
|
|
2
|
+
import { CategoryParams } from '@selfcommunity/api-services';
|
|
2
3
|
import { CacheStrategies } from '@selfcommunity/utils';
|
|
3
4
|
/**
|
|
4
5
|
:::info
|
|
@@ -14,6 +15,7 @@ import { CacheStrategies } from '@selfcommunity/utils';
|
|
|
14
15
|
*/
|
|
15
16
|
declare const useSCFetchCategories: (props?: {
|
|
16
17
|
cacheStrategy?: CacheStrategies;
|
|
18
|
+
endpointQueryParams?: CategoryParams;
|
|
17
19
|
}) => {
|
|
18
20
|
categories: SCCategoryType[];
|
|
19
21
|
isLoading: boolean;
|
|
@@ -8,7 +8,7 @@ const utils_1 = require("@selfcommunity/utils");
|
|
|
8
8
|
const Cache_1 = require("../constants/Cache");
|
|
9
9
|
const init = { categories: [], isLoading: true };
|
|
10
10
|
// HYDRATE the cache
|
|
11
|
-
const hydrate = (ids) => {
|
|
11
|
+
const hydrate = (ids, endpointQueryParams) => {
|
|
12
12
|
if (!ids) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
@@ -20,6 +20,9 @@ const hydrate = (ids) => {
|
|
|
20
20
|
// REVALIDATE CACHE
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
|
+
if (endpointQueryParams === null || endpointQueryParams === void 0 ? void 0 : endpointQueryParams.can_create_content) {
|
|
24
|
+
return categories.filter((c) => !c.content_only_staff);
|
|
25
|
+
}
|
|
23
26
|
return categories;
|
|
24
27
|
};
|
|
25
28
|
/**
|
|
@@ -36,17 +39,17 @@ const hydrate = (ids) => {
|
|
|
36
39
|
*/
|
|
37
40
|
const useSCFetchCategories = (props) => {
|
|
38
41
|
// PROPS
|
|
39
|
-
const { cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST } = props || {};
|
|
42
|
+
const { cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, endpointQueryParams = {} } = props || {};
|
|
40
43
|
// CACHE
|
|
41
44
|
const __categoriesCacheKey = (0, Cache_1.getCategoriesObjectCacheKey)();
|
|
42
45
|
// STATE
|
|
43
|
-
const categories = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? hydrate(utils_1.LRUCache.get(__categoriesCacheKey, null)) : null;
|
|
46
|
+
const categories = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? hydrate(utils_1.LRUCache.get(__categoriesCacheKey, null), endpointQueryParams) : null;
|
|
44
47
|
const [data, setData] = (0, react_1.useState)(categories !== null ? { categories, isLoading: false } : init);
|
|
45
48
|
/**
|
|
46
49
|
* Fetch categories
|
|
47
50
|
*/
|
|
48
51
|
const fetchCategories = (next = api_services_1.Endpoints.CategoryList.url()) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
const data = yield api_services_1.CategoryService.getAllCategories({ active: true }, { url: next });
|
|
52
|
+
const data = yield api_services_1.CategoryService.getAllCategories(Object.assign({ active: true }, endpointQueryParams), { url: next });
|
|
50
53
|
return data.next ? data.results.concat(yield fetchCategories(data.next)) : data.results;
|
|
51
54
|
});
|
|
52
55
|
/**
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CourseInfoParams } from '@selfcommunity/api-services';
|
|
2
|
+
import { SCCourseType } from '@selfcommunity/types';
|
|
3
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
4
|
+
/**
|
|
5
|
+
:::info
|
|
6
|
+
This custom hook is used to fetch an course object.
|
|
7
|
+
:::
|
|
8
|
+
* @param object
|
|
9
|
+
* @param object.id
|
|
10
|
+
* @param object.course
|
|
11
|
+
* @param object.cacheStrategy
|
|
12
|
+
* @param object.params
|
|
13
|
+
*/
|
|
14
|
+
export default function useSCFetchCourse({ id, course, cacheStrategy, params, }: {
|
|
15
|
+
id?: number | string;
|
|
16
|
+
course?: SCCourseType;
|
|
17
|
+
cacheStrategy?: CacheStrategies;
|
|
18
|
+
params?: CourseInfoParams;
|
|
19
|
+
}): {
|
|
20
|
+
scCourse: SCCourseType;
|
|
21
|
+
setSCCourse: (c: SCCourseType) => void;
|
|
22
|
+
error: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
4
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
7
|
+
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
8
|
+
const Cache_1 = require("../constants/Cache");
|
|
9
|
+
const Errors_1 = require("../constants/Errors");
|
|
10
|
+
/**
|
|
11
|
+
:::info
|
|
12
|
+
This custom hook is used to fetch an course object.
|
|
13
|
+
:::
|
|
14
|
+
* @param object
|
|
15
|
+
* @param object.id
|
|
16
|
+
* @param object.course
|
|
17
|
+
* @param object.cacheStrategy
|
|
18
|
+
* @param object.params
|
|
19
|
+
*/
|
|
20
|
+
function useSCFetchCourse({ id = null, course = null, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, params = null, }) {
|
|
21
|
+
const __courseId = (0, react_1.useMemo)(() => (course === null || course === void 0 ? void 0 : course.id) || id, [course, id]);
|
|
22
|
+
// CONTEXT
|
|
23
|
+
const scUserContext = (0, SCUserProvider_1.useSCUser)();
|
|
24
|
+
const authUserId = (0, react_1.useMemo)(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) || null; }, [scUserContext.user]);
|
|
25
|
+
// CACHE
|
|
26
|
+
const __courseCacheKey = (0, react_1.useMemo)(() => (0, Cache_1.getCourseObjectCacheKey)(__courseId), [__courseId]);
|
|
27
|
+
const __course = (0, react_1.useMemo)(() => (authUserId ? course : (0, utils_1.objectWithoutProperties)(course, ['join_status'])), [authUserId, course]);
|
|
28
|
+
const [scCourse, setScCourse] = (0, react_1.useState)(cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? utils_1.LRUCache.get(__courseCacheKey, __course) : null);
|
|
29
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
30
|
+
const setSCCourse = (0, react_1.useCallback)((c) => {
|
|
31
|
+
setScCourse(c);
|
|
32
|
+
utils_1.LRUCache.set(__courseCacheKey, c);
|
|
33
|
+
}, [setScCourse, __courseCacheKey]);
|
|
34
|
+
/**
|
|
35
|
+
* Memoized fetchTag
|
|
36
|
+
*/
|
|
37
|
+
const fetchCourse = (0, react_1.useMemo)(() => (id) => {
|
|
38
|
+
return api_services_1.http
|
|
39
|
+
.request({
|
|
40
|
+
url: api_services_1.Endpoints.GetCourseInfo.url({ id }),
|
|
41
|
+
method: api_services_1.Endpoints.GetCourseInfo.method,
|
|
42
|
+
params: params !== null && params !== void 0 ? params : {},
|
|
43
|
+
})
|
|
44
|
+
.then((res) => {
|
|
45
|
+
if (res.status >= 300) {
|
|
46
|
+
return Promise.reject(res);
|
|
47
|
+
}
|
|
48
|
+
return Promise.resolve(res.data);
|
|
49
|
+
});
|
|
50
|
+
}, []);
|
|
51
|
+
/**
|
|
52
|
+
* If id attempt to get the course by id
|
|
53
|
+
*/
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
if (id !== null && id !== undefined && !course) {
|
|
56
|
+
fetchCourse(id)
|
|
57
|
+
.then((e) => {
|
|
58
|
+
setSCCourse(e);
|
|
59
|
+
})
|
|
60
|
+
.catch((err) => {
|
|
61
|
+
utils_1.LRUCache.delete(__courseCacheKey);
|
|
62
|
+
if (err.status === 403) {
|
|
63
|
+
setError('You do not have permission to perform this action.');
|
|
64
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, 'You do not have permission to perform this action.');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
setError(`Course with id ${id} not found`);
|
|
68
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, `Course with id ${id} not found`);
|
|
69
|
+
}
|
|
70
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, err.message);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, [id, course, authUserId]);
|
|
74
|
+
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
75
|
+
if (course) {
|
|
76
|
+
setSCCourse(course);
|
|
77
|
+
}
|
|
78
|
+
}, [course, authUserId]);
|
|
79
|
+
return { scCourse, setSCCourse, error };
|
|
80
|
+
}
|
|
81
|
+
exports.default = useSCFetchCourse;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SCCourseType } from '@selfcommunity/types';
|
|
2
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
3
|
+
/**
|
|
4
|
+
:::info
|
|
5
|
+
This custom hook is used to fetch courses.
|
|
6
|
+
@param object.cacheStrategy
|
|
7
|
+
|
|
8
|
+
:::tip Context can be consumed in this way:
|
|
9
|
+
|
|
10
|
+
```jsx
|
|
11
|
+
const {courses, isLoading} = useSCFetchCourses();
|
|
12
|
+
```
|
|
13
|
+
:::
|
|
14
|
+
* @param props
|
|
15
|
+
*/
|
|
16
|
+
declare const useSCFetchCourses: (props?: {
|
|
17
|
+
cacheStrategy?: CacheStrategies;
|
|
18
|
+
}) => {
|
|
19
|
+
courses: SCCourseType[];
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
};
|
|
22
|
+
export default useSCFetchCourses;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const Errors_1 = require("../constants/Errors");
|
|
6
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
7
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
8
|
+
const Cache_1 = require("../constants/Cache");
|
|
9
|
+
const init = { courses: [], isLoading: true };
|
|
10
|
+
// HYDRATE the cache
|
|
11
|
+
const hydrate = (ids) => {
|
|
12
|
+
if (!ids) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const courses = ids.map((id) => {
|
|
16
|
+
const __courseCacheKey = (0, Cache_1.getCourseObjectCacheKey)(id);
|
|
17
|
+
return utils_1.LRUCache.get(__courseCacheKey);
|
|
18
|
+
});
|
|
19
|
+
if (courses.filter((c) => !c).length > 0) {
|
|
20
|
+
// REVALIDATE CACHE
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return courses;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
:::info
|
|
27
|
+
This custom hook is used to fetch courses.
|
|
28
|
+
@param object.cacheStrategy
|
|
29
|
+
|
|
30
|
+
:::tip Context can be consumed in this way:
|
|
31
|
+
|
|
32
|
+
```jsx
|
|
33
|
+
const {courses, isLoading} = useSCFetchCourses();
|
|
34
|
+
```
|
|
35
|
+
:::
|
|
36
|
+
* @param props
|
|
37
|
+
*/
|
|
38
|
+
const useSCFetchCourses = (props) => {
|
|
39
|
+
// PROPS
|
|
40
|
+
const { cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST } = props || {};
|
|
41
|
+
// CACHE
|
|
42
|
+
const __coursesCacheKey = (0, Cache_1.getCoursesObjectCacheKey)();
|
|
43
|
+
// STATE
|
|
44
|
+
const courses = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? hydrate(utils_1.LRUCache.get(__coursesCacheKey, null)) : null;
|
|
45
|
+
const [data, setData] = (0, react_1.useState)(courses !== null ? { courses, isLoading: false } : init);
|
|
46
|
+
/**
|
|
47
|
+
* Fetch courses
|
|
48
|
+
*/
|
|
49
|
+
const fetchCourses = (next = api_services_1.Endpoints.GetJoinedCourses.url()) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const response = yield api_services_1.http.request({
|
|
51
|
+
url: next,
|
|
52
|
+
method: api_services_1.Endpoints.GetJoinedCourses.method,
|
|
53
|
+
});
|
|
54
|
+
const data = response.data;
|
|
55
|
+
if (data.next) {
|
|
56
|
+
return data.results.concat(yield fetchCourses(data.next));
|
|
57
|
+
}
|
|
58
|
+
return data.results;
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Get courses
|
|
62
|
+
*/
|
|
63
|
+
(0, react_1.useEffect)(() => {
|
|
64
|
+
if (cacheStrategy === utils_1.CacheStrategies.CACHE_FIRST && courses) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
fetchCourses()
|
|
68
|
+
.then((data) => {
|
|
69
|
+
setData({ courses: data, isLoading: false });
|
|
70
|
+
utils_1.LRUCache.set(__coursesCacheKey, data.map((course) => {
|
|
71
|
+
const __courseCacheKey = (0, Cache_1.getCourseObjectCacheKey)(course.id);
|
|
72
|
+
utils_1.LRUCache.set(__courseCacheKey, course);
|
|
73
|
+
return course.id;
|
|
74
|
+
}));
|
|
75
|
+
})
|
|
76
|
+
.catch((error) => {
|
|
77
|
+
console.log(error);
|
|
78
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, 'Unable to retrieve courses');
|
|
79
|
+
});
|
|
80
|
+
}, []);
|
|
81
|
+
return data;
|
|
82
|
+
};
|
|
83
|
+
exports.default = useSCFetchCourses;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SCCourseLessonType } from '@selfcommunity/types';
|
|
2
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
3
|
+
/**
|
|
4
|
+
:::info
|
|
5
|
+
This custom hook is used to fetch a lesson object.
|
|
6
|
+
:::
|
|
7
|
+
* @param object
|
|
8
|
+
* @param object.id
|
|
9
|
+
* @param object.lesson
|
|
10
|
+
* @param object.cacheStrategy
|
|
11
|
+
*/
|
|
12
|
+
export default function useSCFetchLesson({ id, lesson, courseId, sectionId, cacheStrategy, }: {
|
|
13
|
+
id?: number | string;
|
|
14
|
+
lesson?: SCCourseLessonType;
|
|
15
|
+
courseId: number | string;
|
|
16
|
+
sectionId: number | string;
|
|
17
|
+
cacheStrategy?: CacheStrategies;
|
|
18
|
+
}): {
|
|
19
|
+
scLesson: SCCourseLessonType;
|
|
20
|
+
setSCLesson: (lesson: SCCourseLessonType) => void;
|
|
21
|
+
error: string;
|
|
22
|
+
};
|