@selfcommunity/react-core 0.6.7-alpha.8 → 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
|
@@ -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) => {
|
|
@@ -136,11 +136,18 @@ export const CONFIGURATIONS_EVENTS_ENABLED = `${SCPreferenceSection.CONFIGURATIO
|
|
|
136
136
|
export const CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_ONLY_STAFF_ENABLED}`;
|
|
137
137
|
export const CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_VISIBILITY_ENABLED}`;
|
|
138
138
|
export const CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_PRIVATE_ENABLED}`;
|
|
139
|
+
export const CONFIGURATIONS_COURSES_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.COURSES_ENABLED}`;
|
|
140
|
+
export const CONFIGURATIONS_COURSES_ONLY_STAFF_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.COURSES_ONLY_STAFF_ENABLED}`;
|
|
141
|
+
export const CONFIGURATIONS_COURSES_VISIBILITY_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.COURSES_VISIBILITY_ENABLED}`;
|
|
142
|
+
export const CONFIGURATIONS_COURSES_PRIVATE_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.COURSES_PRIVATE_ENABLED}`;
|
|
139
143
|
export const CONFIGURATIONS_ONBOARDING_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.ONBOARDING_ENABLED}`;
|
|
140
144
|
export const CONFIGURATIONS_ONBOARDING_HIDDEN = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.ONBOARDING_HIDDEN}`;
|
|
141
145
|
export const CONFIGURATIONS_LIVE_STREAM_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.LIVE_STREAM_ENABLED}`;
|
|
142
146
|
export const CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.LIVE_STREAM_ONLY_STAFF_ENABLED}`;
|
|
147
|
+
export const CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.LIVE_STREAM_VIDEO_CONFERENCE_ENABLED}`;
|
|
143
148
|
export const CONFIGURATIONS_SUBSCRIPTION_TIER = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.SUBSCRIPTION_TIER}`;
|
|
149
|
+
export const CONFIGURATIONS_PAYMENTS_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.PAYMENTS_ENABLED}`;
|
|
150
|
+
export const CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.STRIPE_CONNECTED_ACCOUNT_ID}`;
|
|
144
151
|
/**
|
|
145
152
|
* PROVIDERS
|
|
146
153
|
*/
|
|
@@ -167,6 +174,12 @@ export const PROVIDERS_WEB_PUSH_ENABLED = `${SCPreferenceSection.PROVIDERS}.${SC
|
|
|
167
174
|
export const WEBMASTER_META_ROBOTS = `${SCPreferenceSection.WEBMASTER}.${SCPreferenceName.META_ROBOTS}`;
|
|
168
175
|
export const WEBMASTER_META_TITLE_HOME_NOT_LOGGED = `${SCPreferenceSection.WEBMASTER}.${SCPreferenceName.META_TITLE_HOME_NOT_LOGGED}`;
|
|
169
176
|
export const WEBMASTER_META_DESCRIPTION = `${SCPreferenceSection.WEBMASTER}.${SCPreferenceName.META_DESCRIPTION}`;
|
|
177
|
+
/**
|
|
178
|
+
* STATIC
|
|
179
|
+
*/
|
|
180
|
+
export const STATIC_ENVIRONMENT = `${SCPreferenceSection.STATIC}.${SCPreferenceName.ENVIRONMENT}`;
|
|
181
|
+
export const STATIC_STACKID = `${SCPreferenceSection.STATIC}.${SCPreferenceName.STACK_ID}`;
|
|
182
|
+
export const STATIC_STRIPE_PUBLIC_KEY = `${SCPreferenceSection.STATIC}.${SCPreferenceName.STRIPE_PUBLIC_KEY}`;
|
|
170
183
|
const booleanType = (value) => {
|
|
171
184
|
if (value === 'True') {
|
|
172
185
|
return true;
|
|
@@ -286,11 +299,18 @@ export const DATA_TYPES = {
|
|
|
286
299
|
[CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED]: booleanType,
|
|
287
300
|
[CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED]: booleanType,
|
|
288
301
|
[CONFIGURATIONS_EVENTS_PRIVATE_ENABLED]: booleanType,
|
|
302
|
+
[CONFIGURATIONS_COURSES_ENABLED]: booleanType,
|
|
303
|
+
[CONFIGURATIONS_COURSES_ONLY_STAFF_ENABLED]: booleanType,
|
|
304
|
+
[CONFIGURATIONS_COURSES_VISIBILITY_ENABLED]: booleanType,
|
|
305
|
+
[CONFIGURATIONS_COURSES_PRIVATE_ENABLED]: booleanType,
|
|
289
306
|
[CONFIGURATIONS_ONBOARDING_ENABLED]: booleanType,
|
|
290
307
|
[CONFIGURATIONS_ONBOARDING_HIDDEN]: booleanType,
|
|
291
308
|
[CONFIGURATIONS_LIVE_STREAM_ENABLED]: booleanType,
|
|
292
309
|
[CONFIGURATIONS_LIVE_STREAM_ONLY_STAFF_ENABLED]: booleanType,
|
|
310
|
+
[CONFIGURATIONS_LIVE_VIDEO_CONFERENCE_ENABLED]: booleanType,
|
|
293
311
|
[CONFIGURATIONS_SUBSCRIPTION_TIER]: stringType,
|
|
312
|
+
[CONFIGURATIONS_PAYMENTS_ENABLED]: booleanType,
|
|
313
|
+
[CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID]: stringType,
|
|
294
314
|
[PROVIDERS_APP_URL_ON_APP_STORE]: stringType,
|
|
295
315
|
[PROVIDERS_APP_URL_ON_GOOGLE_PLAY]: stringType,
|
|
296
316
|
[PROVIDERS_FACEBOOK_SIGNIN_ENABLED]: stringType,
|
|
@@ -311,4 +331,7 @@ export const DATA_TYPES = {
|
|
|
311
331
|
[WEBMASTER_META_ROBOTS]: stringType,
|
|
312
332
|
[WEBMASTER_META_TITLE_HOME_NOT_LOGGED]: stringType,
|
|
313
333
|
[WEBMASTER_META_DESCRIPTION]: stringType,
|
|
334
|
+
[STATIC_ENVIRONMENT]: stringType,
|
|
335
|
+
[STATIC_STACKID]: stringType,
|
|
336
|
+
[STATIC_STRIPE_PUBLIC_KEY]: stringType,
|
|
314
337
|
};
|
|
@@ -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}}
|
|
@@ -38,10 +38,18 @@ export const GROUPS_ROUTE_NAME = 'groups';
|
|
|
38
38
|
export const GROUPS_SUBSCRIBED_ROUTE_NAME = 'groups_subscribed';
|
|
39
39
|
export const EVENT_ROUTE_NAME = 'event';
|
|
40
40
|
export const EVENTS_ROUTE_NAME = 'events';
|
|
41
|
+
export const COURSE_ROUTE_NAME = 'course';
|
|
42
|
+
export const COURSE_EDIT_ROUTE_NAME = 'course_edit';
|
|
43
|
+
export const COURSE_DASHBOARD_ROUTE_NAME = 'course_dashboard';
|
|
44
|
+
export const COURSE_LESSON_ROUTE_NAME = 'course_lesson';
|
|
45
|
+
export const COURSE_LESSON_EDIT_ROUTE_NAME = 'course_lesson_edit';
|
|
46
|
+
export const COURSE_LESSON_COMMENT_ROUTE_NAME = 'course_lesson_comment';
|
|
47
|
+
export const COURSES_ROUTE_NAME = 'courses';
|
|
41
48
|
export const EVENTS_SUGGESTED_ROUTE_NAME = 'events_suggested';
|
|
42
49
|
export const EVENTS_SUBSCRIBED_ROUTE_NAME = 'events_subscribed';
|
|
43
50
|
export const EVENTS_HIGHLIGHT_ROUTE_NAME = 'events_highlight';
|
|
44
51
|
export const LIVESTREAM_ROUTE_NAME = 'live';
|
|
52
|
+
export 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}}
|
|
@@ -85,5 +93,13 @@ export const defaultRoutes = {
|
|
|
85
93
|
[EVENT_ROUTE_NAME]: '/event/:id/:slug/',
|
|
86
94
|
[EVENTS_SUBSCRIBED_ROUTE_NAME]: '/events/subscribed/',
|
|
87
95
|
[EVENTS_HIGHLIGHT_ROUTE_NAME]: '/events/highlight/',
|
|
96
|
+
[COURSE_ROUTE_NAME]: '/course/:id/:slug/',
|
|
97
|
+
[COURSES_ROUTE_NAME]: '/courses/',
|
|
98
|
+
[COURSE_EDIT_ROUTE_NAME]: '/course/:id/:slug/edit/:tab',
|
|
99
|
+
[COURSE_DASHBOARD_ROUTE_NAME]: '/course/:id/:slug/dashboard',
|
|
100
|
+
[COURSE_LESSON_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/',
|
|
101
|
+
[COURSE_LESSON_EDIT_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/edit',
|
|
102
|
+
[COURSE_LESSON_COMMENT_ROUTE_NAME]: '/course/:id/:slug/section/:section_id/lesson/:lesson_id/comment/:comment_id',
|
|
88
103
|
[LIVESTREAM_ROUTE_NAME]: '/live/:slug/',
|
|
104
|
+
[CHECKOUT_PAYMENT]: '/checkout/:content_type/:content_id/price/:price_id',
|
|
89
105
|
};
|
|
@@ -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;
|
|
@@ -6,7 +6,7 @@ import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
|
|
|
6
6
|
import { getCategoriesObjectCacheKey, getCategoryObjectCacheKey } from '../constants/Cache';
|
|
7
7
|
const init = { categories: [], isLoading: true };
|
|
8
8
|
// HYDRATE the cache
|
|
9
|
-
const hydrate = (ids) => {
|
|
9
|
+
const hydrate = (ids, endpointQueryParams) => {
|
|
10
10
|
if (!ids) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
@@ -18,6 +18,9 @@ const hydrate = (ids) => {
|
|
|
18
18
|
// REVALIDATE CACHE
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
+
if (endpointQueryParams === null || endpointQueryParams === void 0 ? void 0 : endpointQueryParams.can_create_content) {
|
|
22
|
+
return categories.filter((c) => !c.content_only_staff);
|
|
23
|
+
}
|
|
21
24
|
return categories;
|
|
22
25
|
};
|
|
23
26
|
/**
|
|
@@ -34,17 +37,17 @@ const hydrate = (ids) => {
|
|
|
34
37
|
*/
|
|
35
38
|
const useSCFetchCategories = (props) => {
|
|
36
39
|
// PROPS
|
|
37
|
-
const { cacheStrategy = CacheStrategies.CACHE_FIRST } = props || {};
|
|
40
|
+
const { cacheStrategy = CacheStrategies.CACHE_FIRST, endpointQueryParams = {} } = props || {};
|
|
38
41
|
// CACHE
|
|
39
42
|
const __categoriesCacheKey = getCategoriesObjectCacheKey();
|
|
40
43
|
// STATE
|
|
41
|
-
const categories = cacheStrategy !== CacheStrategies.NETWORK_ONLY ? hydrate(LRUCache.get(__categoriesCacheKey, null)) : null;
|
|
44
|
+
const categories = cacheStrategy !== CacheStrategies.NETWORK_ONLY ? hydrate(LRUCache.get(__categoriesCacheKey, null), endpointQueryParams) : null;
|
|
42
45
|
const [data, setData] = useState(categories !== null ? { categories, isLoading: false } : init);
|
|
43
46
|
/**
|
|
44
47
|
* Fetch categories
|
|
45
48
|
*/
|
|
46
49
|
const fetchCategories = (next = Endpoints.CategoryList.url()) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const data = yield CategoryService.getAllCategories({ active: true }, { url: next });
|
|
50
|
+
const data = yield CategoryService.getAllCategories(Object.assign({ active: true }, endpointQueryParams), { url: next });
|
|
48
51
|
return data.next ? data.results.concat(yield fetchCategories(data.next)) : data.results;
|
|
49
52
|
});
|
|
50
53
|
/**
|
|
@@ -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,78 @@
|
|
|
1
|
+
import { Endpoints, http } from '@selfcommunity/api-services';
|
|
2
|
+
import { CacheStrategies, Logger, LRUCache, objectWithoutProperties } 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 { getCourseObjectCacheKey } from '../constants/Cache';
|
|
7
|
+
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
8
|
+
/**
|
|
9
|
+
:::info
|
|
10
|
+
This custom hook is used to fetch an course object.
|
|
11
|
+
:::
|
|
12
|
+
* @param object
|
|
13
|
+
* @param object.id
|
|
14
|
+
* @param object.course
|
|
15
|
+
* @param object.cacheStrategy
|
|
16
|
+
* @param object.params
|
|
17
|
+
*/
|
|
18
|
+
export default function useSCFetchCourse({ id = null, course = null, cacheStrategy = CacheStrategies.CACHE_FIRST, params = null, }) {
|
|
19
|
+
const __courseId = useMemo(() => (course === null || course === void 0 ? void 0 : course.id) || id, [course, id]);
|
|
20
|
+
// CONTEXT
|
|
21
|
+
const scUserContext = useSCUser();
|
|
22
|
+
const authUserId = useMemo(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) || null; }, [scUserContext.user]);
|
|
23
|
+
// CACHE
|
|
24
|
+
const __courseCacheKey = useMemo(() => getCourseObjectCacheKey(__courseId), [__courseId]);
|
|
25
|
+
const __course = useMemo(() => (authUserId ? course : objectWithoutProperties(course, ['join_status'])), [authUserId, course]);
|
|
26
|
+
const [scCourse, setScCourse] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__courseCacheKey, __course) : null);
|
|
27
|
+
const [error, setError] = useState(null);
|
|
28
|
+
const setSCCourse = useCallback((c) => {
|
|
29
|
+
setScCourse(c);
|
|
30
|
+
LRUCache.set(__courseCacheKey, c);
|
|
31
|
+
}, [setScCourse, __courseCacheKey]);
|
|
32
|
+
/**
|
|
33
|
+
* Memoized fetchTag
|
|
34
|
+
*/
|
|
35
|
+
const fetchCourse = useMemo(() => (id) => {
|
|
36
|
+
return http
|
|
37
|
+
.request({
|
|
38
|
+
url: Endpoints.GetCourseInfo.url({ id }),
|
|
39
|
+
method: Endpoints.GetCourseInfo.method,
|
|
40
|
+
params: params !== null && params !== void 0 ? params : {},
|
|
41
|
+
})
|
|
42
|
+
.then((res) => {
|
|
43
|
+
if (res.status >= 300) {
|
|
44
|
+
return Promise.reject(res);
|
|
45
|
+
}
|
|
46
|
+
return Promise.resolve(res.data);
|
|
47
|
+
});
|
|
48
|
+
}, []);
|
|
49
|
+
/**
|
|
50
|
+
* If id attempt to get the course by id
|
|
51
|
+
*/
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (id !== null && id !== undefined && !course) {
|
|
54
|
+
fetchCourse(id)
|
|
55
|
+
.then((e) => {
|
|
56
|
+
setSCCourse(e);
|
|
57
|
+
})
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
LRUCache.delete(__courseCacheKey);
|
|
60
|
+
if (err.status === 403) {
|
|
61
|
+
setError('You do not have permission to perform this action.');
|
|
62
|
+
Logger.error(SCOPE_SC_CORE, 'You do not have permission to perform this action.');
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
setError(`Course with id ${id} not found`);
|
|
66
|
+
Logger.error(SCOPE_SC_CORE, `Course with id ${id} not found`);
|
|
67
|
+
}
|
|
68
|
+
Logger.error(SCOPE_SC_CORE, err.message);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}, [id, course, authUserId]);
|
|
72
|
+
useDeepCompareEffectNoCheck(() => {
|
|
73
|
+
if (course) {
|
|
74
|
+
setSCCourse(course);
|
|
75
|
+
}
|
|
76
|
+
}, [course, authUserId]);
|
|
77
|
+
return { scCourse, setSCCourse, error };
|
|
78
|
+
}
|
|
@@ -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,81 @@
|
|
|
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 { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
|
|
6
|
+
import { getCourseObjectCacheKey, getCoursesObjectCacheKey } from '../constants/Cache';
|
|
7
|
+
const init = { courses: [], isLoading: true };
|
|
8
|
+
// HYDRATE the cache
|
|
9
|
+
const hydrate = (ids) => {
|
|
10
|
+
if (!ids) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const courses = ids.map((id) => {
|
|
14
|
+
const __courseCacheKey = getCourseObjectCacheKey(id);
|
|
15
|
+
return LRUCache.get(__courseCacheKey);
|
|
16
|
+
});
|
|
17
|
+
if (courses.filter((c) => !c).length > 0) {
|
|
18
|
+
// REVALIDATE CACHE
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return courses;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
:::info
|
|
25
|
+
This custom hook is used to fetch courses.
|
|
26
|
+
@param object.cacheStrategy
|
|
27
|
+
|
|
28
|
+
:::tip Context can be consumed in this way:
|
|
29
|
+
|
|
30
|
+
```jsx
|
|
31
|
+
const {courses, isLoading} = useSCFetchCourses();
|
|
32
|
+
```
|
|
33
|
+
:::
|
|
34
|
+
* @param props
|
|
35
|
+
*/
|
|
36
|
+
const useSCFetchCourses = (props) => {
|
|
37
|
+
// PROPS
|
|
38
|
+
const { cacheStrategy = CacheStrategies.CACHE_FIRST } = props || {};
|
|
39
|
+
// CACHE
|
|
40
|
+
const __coursesCacheKey = getCoursesObjectCacheKey();
|
|
41
|
+
// STATE
|
|
42
|
+
const courses = cacheStrategy !== CacheStrategies.NETWORK_ONLY ? hydrate(LRUCache.get(__coursesCacheKey, null)) : null;
|
|
43
|
+
const [data, setData] = useState(courses !== null ? { courses, isLoading: false } : init);
|
|
44
|
+
/**
|
|
45
|
+
* Fetch courses
|
|
46
|
+
*/
|
|
47
|
+
const fetchCourses = (next = Endpoints.GetJoinedCourses.url()) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
const response = yield http.request({
|
|
49
|
+
url: next,
|
|
50
|
+
method: Endpoints.GetJoinedCourses.method,
|
|
51
|
+
});
|
|
52
|
+
const data = response.data;
|
|
53
|
+
if (data.next) {
|
|
54
|
+
return data.results.concat(yield fetchCourses(data.next));
|
|
55
|
+
}
|
|
56
|
+
return data.results;
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* Get courses
|
|
60
|
+
*/
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (cacheStrategy === CacheStrategies.CACHE_FIRST && courses) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
fetchCourses()
|
|
66
|
+
.then((data) => {
|
|
67
|
+
setData({ courses: data, isLoading: false });
|
|
68
|
+
LRUCache.set(__coursesCacheKey, data.map((course) => {
|
|
69
|
+
const __courseCacheKey = getCourseObjectCacheKey(course.id);
|
|
70
|
+
LRUCache.set(__courseCacheKey, course);
|
|
71
|
+
return course.id;
|
|
72
|
+
}));
|
|
73
|
+
})
|
|
74
|
+
.catch((error) => {
|
|
75
|
+
console.log(error);
|
|
76
|
+
Logger.error(SCOPE_SC_CORE, 'Unable to retrieve courses');
|
|
77
|
+
});
|
|
78
|
+
}, []);
|
|
79
|
+
return data;
|
|
80
|
+
};
|
|
81
|
+
export 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
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Endpoints, http } from '@selfcommunity/api-services';
|
|
2
|
+
import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
5
|
+
import { useSCUser } from '../components/provider/SCUserProvider';
|
|
6
|
+
import { getLessonObjectCacheKey } from '../constants/Cache';
|
|
7
|
+
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
8
|
+
/**
|
|
9
|
+
:::info
|
|
10
|
+
This custom hook is used to fetch a lesson object.
|
|
11
|
+
:::
|
|
12
|
+
* @param object
|
|
13
|
+
* @param object.id
|
|
14
|
+
* @param object.lesson
|
|
15
|
+
* @param object.cacheStrategy
|
|
16
|
+
*/
|
|
17
|
+
export default function useSCFetchLesson({ id = null, lesson = null, courseId = null, sectionId = null, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
|
|
18
|
+
const __lessonId = useMemo(() => (lesson === null || lesson === void 0 ? void 0 : lesson.id) || id, [lesson, 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 __lessonCacheKey = useMemo(() => getLessonObjectCacheKey(__lessonId), [__lessonId]);
|
|
24
|
+
const [scLesson, setScLesson] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__lessonCacheKey, lesson) : null);
|
|
25
|
+
const [error, setError] = useState(null);
|
|
26
|
+
const setSCLesson = (lesson) => {
|
|
27
|
+
setScLesson(lesson);
|
|
28
|
+
LRUCache.set(__lessonCacheKey, lesson);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Memoized fetchTag
|
|
32
|
+
*/
|
|
33
|
+
const fetchLesson = useMemo(() => (id) => {
|
|
34
|
+
return http
|
|
35
|
+
.request({
|
|
36
|
+
url: Endpoints.GetCourseLesson.url({ id: courseId, section_id: sectionId, lesson_id: id }),
|
|
37
|
+
method: Endpoints.GetCourseLesson.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 lesson by id
|
|
48
|
+
*/
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (id !== null && id !== undefined && courseId !== null && courseId !== undefined && sectionId) {
|
|
51
|
+
fetchLesson(id)
|
|
52
|
+
.then((e) => {
|
|
53
|
+
setSCLesson(e);
|
|
54
|
+
})
|
|
55
|
+
.catch((err) => {
|
|
56
|
+
LRUCache.delete(__lessonCacheKey);
|
|
57
|
+
setError(`Lesson with id ${id} not found`);
|
|
58
|
+
Logger.error(SCOPE_SC_CORE, `Lesson with id ${id} not found`);
|
|
59
|
+
Logger.error(SCOPE_SC_CORE, err.message);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [id, courseId, authUserId, sectionId]);
|
|
63
|
+
useDeepCompareEffectNoCheck(() => {
|
|
64
|
+
if (lesson) {
|
|
65
|
+
setSCLesson(lesson);
|
|
66
|
+
}
|
|
67
|
+
}, [lesson, authUserId]);
|
|
68
|
+
return { scLesson, setSCLesson, error };
|
|
69
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SCCourseCommentType, SCCourseLessonType } from '@selfcommunity/types';
|
|
3
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
4
|
+
/**
|
|
5
|
+
:::info
|
|
6
|
+
This custom hooks is used to fetch a course lesson comment.
|
|
7
|
+
:::
|
|
8
|
+
* @param object
|
|
9
|
+
* @param object.id
|
|
10
|
+
* @param object.commentObject
|
|
11
|
+
* @param object.lesson
|
|
12
|
+
* @param object.cacheStrategy
|
|
13
|
+
*/
|
|
14
|
+
export default function useSCFetchLessonCommentObject({ id, commentObject, lesson, cacheStrategy, }: {
|
|
15
|
+
id?: number;
|
|
16
|
+
commentObject?: SCCourseCommentType;
|
|
17
|
+
lesson: SCCourseLessonType;
|
|
18
|
+
cacheStrategy?: CacheStrategies;
|
|
19
|
+
}): {
|
|
20
|
+
obj: SCCourseCommentType;
|
|
21
|
+
setObj: import("react").Dispatch<import("react").SetStateAction<SCCourseCommentType>>;
|
|
22
|
+
error: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
3
|
+
import { http, Endpoints } from '@selfcommunity/api-services';
|
|
4
|
+
import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
|
|
5
|
+
import { getLessonCommentCacheKey } from '../constants/Cache';
|
|
6
|
+
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
7
|
+
/**
|
|
8
|
+
:::info
|
|
9
|
+
This custom hooks is used to fetch a course lesson comment.
|
|
10
|
+
:::
|
|
11
|
+
* @param object
|
|
12
|
+
* @param object.id
|
|
13
|
+
* @param object.commentObject
|
|
14
|
+
* @param object.lesson
|
|
15
|
+
* @param object.cacheStrategy
|
|
16
|
+
*/
|
|
17
|
+
export default function useSCFetchLessonCommentObject({ id = null, commentObject = null, lesson = null, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
|
|
18
|
+
const __commentObjectId = commentObject ? commentObject.id : id;
|
|
19
|
+
// CACHE
|
|
20
|
+
const __commentObjectCacheKey = getLessonCommentCacheKey(__commentObjectId);
|
|
21
|
+
const [obj, setObj] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__commentObjectCacheKey, commentObject) : commentObject);
|
|
22
|
+
const [error, setError] = useState(null);
|
|
23
|
+
/**
|
|
24
|
+
* Memoized fetchLessonCommentObject
|
|
25
|
+
*/
|
|
26
|
+
const fetchLessonCommentObject = useMemo(() => () => {
|
|
27
|
+
return http
|
|
28
|
+
.request({
|
|
29
|
+
url: Endpoints.GetCourseLessonComment.url({
|
|
30
|
+
id: lesson.course_id,
|
|
31
|
+
section_id: lesson.section_id,
|
|
32
|
+
lesson_id: lesson.id,
|
|
33
|
+
comment_id: __commentObjectId,
|
|
34
|
+
}),
|
|
35
|
+
method: Endpoints.GetCourseLessonComment.method,
|
|
36
|
+
})
|
|
37
|
+
.then((res) => {
|
|
38
|
+
if (res.status >= 300) {
|
|
39
|
+
return Promise.reject(res);
|
|
40
|
+
}
|
|
41
|
+
return Promise.resolve(res.data);
|
|
42
|
+
});
|
|
43
|
+
}, [__commentObjectId, lesson]);
|
|
44
|
+
/**
|
|
45
|
+
* If course commentObject resolve it
|
|
46
|
+
*/
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (__commentObjectId && lesson && (!obj || cacheStrategy === CacheStrategies.STALE_WHILE_REVALIDATE)) {
|
|
49
|
+
fetchLessonCommentObject()
|
|
50
|
+
.then((obj) => {
|
|
51
|
+
setObj(obj);
|
|
52
|
+
LRUCache.set(__commentObjectCacheKey, obj);
|
|
53
|
+
})
|
|
54
|
+
.catch((err) => {
|
|
55
|
+
LRUCache.delete(__commentObjectCacheKey);
|
|
56
|
+
setError(`Course Lesson comment Object with id ${id} not found`);
|
|
57
|
+
Logger.error(SCOPE_SC_CORE, `Course Lesson comment Object with id ${id} not found`);
|
|
58
|
+
Logger.error(SCOPE_SC_CORE, err.message);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [__commentObjectId, lesson]);
|
|
62
|
+
useDeepCompareEffectNoCheck(() => {
|
|
63
|
+
if (commentObject) {
|
|
64
|
+
setObj(commentObject);
|
|
65
|
+
LRUCache.set(__commentObjectCacheKey, obj);
|
|
66
|
+
}
|
|
67
|
+
}, [commentObject]);
|
|
68
|
+
return { obj, setObj, error };
|
|
69
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SCCommentsOrderBy, SCCourseCommentType, SCCourseLessonType } from '@selfcommunity/types';
|
|
2
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Interface SCLessonCommentsObjectType
|
|
5
|
+
*/
|
|
6
|
+
export interface SCLessonCommentsObjectType {
|
|
7
|
+
componentLoaded: boolean;
|
|
8
|
+
comments: SCCourseCommentType[];
|
|
9
|
+
total: number;
|
|
10
|
+
next: string;
|
|
11
|
+
previous: string;
|
|
12
|
+
isLoadingNext: boolean;
|
|
13
|
+
isLoadingPrevious: boolean;
|
|
14
|
+
page: number;
|
|
15
|
+
reload: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
* We have complex state logic that involves multiple sub-values,
|
|
20
|
+
* so useReducer is preferable to useState.
|
|
21
|
+
* Define all possible auth action types label
|
|
22
|
+
* Use this to export actions and dispatch an action
|
|
23
|
+
*/
|
|
24
|
+
export declare const commentsObjectActionTypes: {
|
|
25
|
+
LOADING_NEXT: string;
|
|
26
|
+
LOADING_PREVIOUS: string;
|
|
27
|
+
DATA_NEXT_LOADED: string;
|
|
28
|
+
DATA_PREVIOUS_LOADED: string;
|
|
29
|
+
DATA_RELOAD: string;
|
|
30
|
+
DATA_RELOADED: string;
|
|
31
|
+
DATA_REVALIDATE: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
:::info
|
|
35
|
+
This custom hooks is used to fetch paginated comments for a specific course lesson.
|
|
36
|
+
:::
|
|
37
|
+
* @param props
|
|
38
|
+
*/
|
|
39
|
+
export default function useSCFetchLessonCommentObjects(props: {
|
|
40
|
+
id?: number;
|
|
41
|
+
lessonObject?: SCCourseLessonType;
|
|
42
|
+
offset?: number;
|
|
43
|
+
pageSize?: number;
|
|
44
|
+
orderBy?: SCCommentsOrderBy;
|
|
45
|
+
parent?: number;
|
|
46
|
+
onChangePage?: (page: any) => any;
|
|
47
|
+
cacheStrategy?: CacheStrategies;
|
|
48
|
+
}): any;
|