@selfcommunity/react-core 0.6.7-payments.182 → 0.6.7-payments.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/constants/Cache.d.ts +4 -1
- package/lib/cjs/constants/Cache.js +6 -2
- package/lib/cjs/constants/Routes.d.ts +1 -0
- package/lib/cjs/constants/Routes.js +4 -2
- package/lib/cjs/hooks/useSCFetchPaymentOrder.d.ts +20 -0
- package/lib/cjs/hooks/useSCFetchPaymentOrder.js +70 -0
- package/lib/cjs/hooks/useSCJoinedCoursesManager.js +8 -8
- package/lib/cjs/hooks/useSCSubscribedEventsManager.js +13 -6
- package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +8 -8
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +4 -1
- package/lib/cjs/utils/hooks/index.d.ts +2 -1
- package/lib/cjs/utils/hooks/index.js +3 -1
- package/lib/cjs/utils/hooks/useResizeObserver.d.ts +1 -0
- package/lib/cjs/utils/hooks/useResizeObserver.js +16 -0
- package/lib/esm/constants/Cache.d.ts +4 -1
- package/lib/esm/constants/Cache.js +4 -1
- package/lib/esm/constants/Routes.d.ts +1 -0
- package/lib/esm/constants/Routes.js +2 -0
- package/lib/esm/hooks/useSCFetchPaymentOrder.d.ts +20 -0
- package/lib/esm/hooks/useSCFetchPaymentOrder.js +67 -0
- package/lib/esm/hooks/useSCJoinedCoursesManager.js +7 -7
- package/lib/esm/hooks/useSCSubscribedEventsManager.js +14 -7
- package/lib/esm/hooks/useSCSubscribedGroupsManager.js +7 -7
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +3 -2
- package/lib/esm/utils/hooks/index.d.ts +2 -1
- package/lib/esm/utils/hooks/index.js +2 -1
- package/lib/esm/utils/hooks/useResizeObserver.d.ts +1 -0
- package/lib/esm/utils/hooks/useResizeObserver.js +13 -0
- package/lib/umd/react-core.js +1 -1
- package/package.json +5 -5
|
@@ -76,9 +76,12 @@ export declare const getPmSnippetsObjectCacheKey: () => string;
|
|
|
76
76
|
/** PRIVATE MESSAGE SNIPPET OBJECT **/
|
|
77
77
|
export declare const PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = "_pms_";
|
|
78
78
|
export declare const getPmSnippetObjectCacheKey: (id: any) => string;
|
|
79
|
-
/**
|
|
79
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
80
80
|
export declare const PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY = "_ppo_";
|
|
81
81
|
export declare const getPaymentProductObjectCacheKey: (id: any) => string;
|
|
82
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
83
|
+
export declare const PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = "_pord_";
|
|
84
|
+
export declare const getPaymentOrderObjectCacheKey: (id: any) => string;
|
|
82
85
|
/** TOOLS */
|
|
83
86
|
export declare const CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = "_cListWidget_";
|
|
84
87
|
export declare const CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = "_cFolWidget_";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
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.USERS_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USERS_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_CREATED_COURSES_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.getPaymentProductObjectCacheKey = exports.PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY = exports.getPmSnippetObjectCacheKey = exports.PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = exports.getPmSnippetsObjectCacheKey = 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.USERS_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY = exports.USERS_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_CREATED_COURSES_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.getPaymentOrderObjectCacheKey = exports.PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = exports.getPaymentProductObjectCacheKey = exports.PAYMENT_PRODUCT_OBJECT_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}`;
|
|
@@ -112,10 +112,14 @@ exports.getPmSnippetsObjectCacheKey = getPmSnippetsObjectCacheKey;
|
|
|
112
112
|
exports.PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = '_pms_';
|
|
113
113
|
const getPmSnippetObjectCacheKey = (id) => `${exports.PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
114
114
|
exports.getPmSnippetObjectCacheKey = getPmSnippetObjectCacheKey;
|
|
115
|
-
/**
|
|
115
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
116
116
|
exports.PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY = '_ppo_';
|
|
117
117
|
const getPaymentProductObjectCacheKey = (id) => `${exports.PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
118
118
|
exports.getPaymentProductObjectCacheKey = getPaymentProductObjectCacheKey;
|
|
119
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
120
|
+
exports.PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = '_pord_';
|
|
121
|
+
const getPaymentOrderObjectCacheKey = (id) => `${exports.PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
122
|
+
exports.getPaymentOrderObjectCacheKey = getPaymentOrderObjectCacheKey;
|
|
119
123
|
/** TOOLS */
|
|
120
124
|
exports.CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = '_cListWidget_';
|
|
121
125
|
exports.CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = '_cFolWidget_';
|
|
@@ -25,6 +25,7 @@ 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
26
|
export declare const USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = "user_followed_discussions";
|
|
27
27
|
export declare const USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME = "user_payments_history_orders";
|
|
28
|
+
export declare const USER_PAYMENTS_ORDER_PDF_ROUTE_NAME = "user_payments_order_pdf";
|
|
28
29
|
export declare const USER_PAYMENT_METHODS_ROUTE_NAME = "user_payment_methods";
|
|
29
30
|
export declare const LOYALTY_ROUTE_NAME = "loyalty";
|
|
30
31
|
export declare const INCUBATOR_ROUTE_NAME = "incubator";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.defaultRoutes = exports.CHECKOUT_PAYMENT = exports.LIVESTREAM_ROUTE_NAME = void 0;
|
|
3
|
+
exports.EVENTS_SUBSCRIBED_ROUTE_NAME = exports.EVENTS_SUGGESTED_ROUTE_NAME = exports.COURSES_ROUTE_NAME = exports.COURSE_LESSON_COMMENTS_ROUTE_NAME = exports.COURSE_LESSON_EDIT_ROUTE_NAME = exports.COURSE_LESSON_PREVIEW_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_PAYMENT_METHODS_ROUTE_NAME = exports.USER_PAYMENTS_ORDER_PDF_ROUTE_NAME = exports.USER_PAYMENTS_HISTORY_ORDERS_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
|
+
exports.defaultRoutes = exports.CHECKOUT_PAYMENT = exports.LIVESTREAM_ROUTE_NAME = exports.EVENTS_HIGHLIGHT_ROUTE_NAME = void 0;
|
|
5
5
|
exports.PORTAL_OPTION = 'portal';
|
|
6
6
|
exports.ROUTER_OPTION = 'router';
|
|
7
7
|
/**
|
|
@@ -29,6 +29,7 @@ exports.USER_PROFILE_CATEGORIES_ROUTE_NAME = 'user_categories';
|
|
|
29
29
|
exports.USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME = 'user_followed_posts';
|
|
30
30
|
exports.USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = 'user_followed_discussions';
|
|
31
31
|
exports.USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME = 'user_payments_history_orders';
|
|
32
|
+
exports.USER_PAYMENTS_ORDER_PDF_ROUTE_NAME = 'user_payments_order_pdf';
|
|
32
33
|
exports.USER_PAYMENT_METHODS_ROUTE_NAME = 'user_payment_methods';
|
|
33
34
|
exports.LOYALTY_ROUTE_NAME = 'loyalty';
|
|
34
35
|
exports.INCUBATOR_ROUTE_NAME = 'incubator';
|
|
@@ -84,6 +85,7 @@ exports.defaultRoutes = {
|
|
|
84
85
|
[exports.USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME]: '/user/:id/posts/followed/',
|
|
85
86
|
[exports.USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME]: '/user/:id/discussions/followed/',
|
|
86
87
|
[exports.USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME]: '/user/:id/:username/history_orders/',
|
|
88
|
+
[exports.USER_PAYMENTS_ORDER_PDF_ROUTE_NAME]: '/user/:id/:username/order/:pid/pdf/',
|
|
87
89
|
[exports.USER_PAYMENT_METHODS_ROUTE_NAME]: '/user/:id/:username/payment_methods/',
|
|
88
90
|
[exports.LOYALTY_ROUTE_NAME]: '/loyalty/',
|
|
89
91
|
[exports.INCUBATOR_ROUTE_NAME]: '/incubator/:id/',
|
|
@@ -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,70 @@
|
|
|
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 a payment order.
|
|
13
|
+
:::
|
|
14
|
+
* @param object
|
|
15
|
+
* @param object.id
|
|
16
|
+
* @param object.paymentOrder
|
|
17
|
+
* @param object.cacheStrategy
|
|
18
|
+
*/
|
|
19
|
+
function useSCFetchPaymentOrder({ id = null, paymentOrder = null, cacheStrategy = utils_1.CacheStrategies.NETWORK_ONLY, }) {
|
|
20
|
+
const __paymentOrderId = (0, react_1.useMemo)(() => (paymentOrder === null || paymentOrder === void 0 ? void 0 : paymentOrder.id) || id, [paymentOrder, id]);
|
|
21
|
+
// CONTEXT
|
|
22
|
+
const scUserContext = (0, SCUserProvider_1.useSCUser)();
|
|
23
|
+
const authUserId = (0, react_1.useMemo)(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) || null; }, [scUserContext.user]);
|
|
24
|
+
// CACHE
|
|
25
|
+
const __paymentOrderCacheKey = (0, react_1.useMemo)(() => (0, Cache_1.getPaymentOrderObjectCacheKey)(__paymentOrderId), [__paymentOrderId]);
|
|
26
|
+
const [scPaymentOrder, setScPaymentOrder] = (0, react_1.useState)(cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? utils_1.LRUCache.get(__paymentOrderCacheKey, paymentOrder) : null);
|
|
27
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
28
|
+
const setSCPaymentOrder = (0, react_1.useCallback)((c) => {
|
|
29
|
+
setScPaymentOrder(c);
|
|
30
|
+
utils_1.LRUCache.set(__paymentOrderCacheKey, c);
|
|
31
|
+
}, [setScPaymentOrder, __paymentOrderCacheKey]);
|
|
32
|
+
/**
|
|
33
|
+
* Memoized fetch order
|
|
34
|
+
*/
|
|
35
|
+
const fetchPaymentOrder = (0, react_1.useMemo)(() => (id) => {
|
|
36
|
+
return api_services_1.http
|
|
37
|
+
.request({
|
|
38
|
+
url: api_services_1.Endpoints.GetPaymentOrder.url({ id }),
|
|
39
|
+
method: api_services_1.Endpoints.GetPaymentOrder.method,
|
|
40
|
+
})
|
|
41
|
+
.then((res) => {
|
|
42
|
+
if (res.status >= 300) {
|
|
43
|
+
return Promise.reject(res);
|
|
44
|
+
}
|
|
45
|
+
return Promise.resolve(res.data);
|
|
46
|
+
});
|
|
47
|
+
}, []);
|
|
48
|
+
/**
|
|
49
|
+
* If id attempt to get the course by id
|
|
50
|
+
*/
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
if (id !== null && id !== undefined && !paymentOrder) {
|
|
53
|
+
fetchPaymentOrder(id)
|
|
54
|
+
.then((e) => {
|
|
55
|
+
setSCPaymentOrder(e);
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
utils_1.LRUCache.delete(__paymentOrderCacheKey);
|
|
59
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, err.message);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [id, paymentOrder, authUserId]);
|
|
63
|
+
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
64
|
+
if (paymentOrder) {
|
|
65
|
+
setSCPaymentOrder(paymentOrder);
|
|
66
|
+
}
|
|
67
|
+
}, [paymentOrder, authUserId]);
|
|
68
|
+
return { scPaymentOrder, setSCPaymentOrder, error };
|
|
69
|
+
}
|
|
70
|
+
exports.default = useSCFetchPaymentOrder;
|
|
@@ -66,12 +66,12 @@ function useSCJoinedCoursesManager(user) {
|
|
|
66
66
|
case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_COURSE:
|
|
67
67
|
_status = types_1.SCCourseJoinStatusType.INVITED;
|
|
68
68
|
break;
|
|
69
|
-
case
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
/* case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
|
|
70
|
+
_status = SCCourseJoinStatusType.REQUESTED;
|
|
71
|
+
break;
|
|
72
|
+
case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_COURSE:
|
|
73
|
+
_status = SCCourseJoinStatusType.JOINED;
|
|
74
|
+
break; */
|
|
75
75
|
case types_1.SCNotificationTypologyType.USER_ADDED_TO_COURSE:
|
|
76
76
|
_status = types_1.SCCourseJoinStatusType.JOINED;
|
|
77
77
|
break;
|
|
@@ -250,7 +250,7 @@ function useSCJoinedCoursesManager(user) {
|
|
|
250
250
|
if (cache.includes(course.id)) {
|
|
251
251
|
return getCurrentCourseCacheStatus(course);
|
|
252
252
|
}
|
|
253
|
-
if (authUserId) {
|
|
253
|
+
if (authUserId && course) {
|
|
254
254
|
if ('join_status' in course) {
|
|
255
255
|
return getJoinStatus(course);
|
|
256
256
|
}
|
|
@@ -259,7 +259,7 @@ function useSCJoinedCoursesManager(user) {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
return null;
|
|
262
|
-
}, [loading, cache, authUserId]);
|
|
262
|
+
}, [loading, cache, authUserId, getJoinStatus, getCurrentCourseCacheStatus]);
|
|
263
263
|
/**
|
|
264
264
|
* Empty cache on logout
|
|
265
265
|
*/
|
|
@@ -13,6 +13,8 @@ const Notification_1 = require("../constants/Notification");
|
|
|
13
13
|
const Preferences_1 = require("../constants/Preferences");
|
|
14
14
|
const event_1 = require("../utils/event");
|
|
15
15
|
const useSCCachingManager_1 = tslib_1.__importDefault(require("./useSCCachingManager"));
|
|
16
|
+
const SCRoutingProvider_1 = require("../components/provider/SCRoutingProvider");
|
|
17
|
+
const SCRoutes = tslib_1.__importStar(require("../constants/Routes"));
|
|
16
18
|
/**
|
|
17
19
|
:::info
|
|
18
20
|
This custom hook is used to manage the events followed.
|
|
@@ -30,6 +32,7 @@ const useSCCachingManager_1 = tslib_1.__importDefault(require("./useSCCachingMan
|
|
|
30
32
|
function useSCSubscribedEventsManager(user) {
|
|
31
33
|
const { cache, updateCache, emptyCache, data, setData, loading, setLoading, setUnLoading, isLoading } = (0, useSCCachingManager_1.default)();
|
|
32
34
|
const { preferences, features } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
35
|
+
const scRoutingContext = (0, react_1.useContext)(SCRoutingProvider_1.SCRoutingContext);
|
|
33
36
|
const authUserId = user ? user.id : null;
|
|
34
37
|
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
35
38
|
features &&
|
|
@@ -66,13 +69,17 @@ function useSCSubscribedEventsManager(user) {
|
|
|
66
69
|
switch (Notification_1.SCNotificationMapping[dataMsg.data.activity_type]) {
|
|
67
70
|
case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT:
|
|
68
71
|
_status = types_1.SCEventSubscriptionStatusType.INVITED;
|
|
72
|
+
if ((0, utils_1.isClientSideRendering)() &&
|
|
73
|
+
window.document.location.href.indexOf(scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, dataMsg.data.notification_obj.event)) > -1) {
|
|
74
|
+
checkEventSubscriptionStatus(dataMsg.data.notification_obj.event);
|
|
75
|
+
}
|
|
69
76
|
break;
|
|
70
|
-
case
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
case
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
/* case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT:
|
|
78
|
+
_status = SCEventSubscriptionStatusType.REQUESTED;
|
|
79
|
+
break;
|
|
80
|
+
case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT:
|
|
81
|
+
_status = SCEventSubscriptionStatusType.SUBSCRIBED;
|
|
82
|
+
break; */
|
|
76
83
|
case types_1.SCNotificationTypologyType.USER_ADDED_TO_EVENT:
|
|
77
84
|
_status = types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
|
|
78
85
|
break;
|
|
@@ -67,12 +67,12 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
67
67
|
case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP:
|
|
68
68
|
_status = types_1.SCGroupSubscriptionStatusType.INVITED;
|
|
69
69
|
break;
|
|
70
|
-
case
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
case
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
/* case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP:
|
|
71
|
+
_status = SCGroupSubscriptionStatusType.REQUESTED;
|
|
72
|
+
break;
|
|
73
|
+
case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP:
|
|
74
|
+
_status = SCGroupSubscriptionStatusType.SUBSCRIBED;
|
|
75
|
+
break; */
|
|
76
76
|
case types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP:
|
|
77
77
|
_status = types_1.SCGroupSubscriptionStatusType.SUBSCRIBED;
|
|
78
78
|
break;
|
|
@@ -251,7 +251,7 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
251
251
|
if (cache.includes(group.id)) {
|
|
252
252
|
return getCurrentGroupCacheStatus(group);
|
|
253
253
|
}
|
|
254
|
-
if (authUserId) {
|
|
254
|
+
if (authUserId && group) {
|
|
255
255
|
if ('subscription_status' in group) {
|
|
256
256
|
return getSubscriptionStatus(group);
|
|
257
257
|
}
|
|
@@ -260,7 +260,7 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
return null;
|
|
263
|
-
}, [loading, cache, authUserId]);
|
|
263
|
+
}, [loading, cache, authUserId, getSubscriptionStatus, getCurrentGroupCacheStatus]);
|
|
264
264
|
/**
|
|
265
265
|
* Empty cache on logout
|
|
266
266
|
*/
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ import useSCFetchCourses from './hooks/useSCFetchCourses';
|
|
|
73
73
|
import useSCFetchLesson from './hooks/useSCFetchLesson';
|
|
74
74
|
import useSCPaymentsEnabled from './hooks/useSCPaymentsEnabled';
|
|
75
75
|
import useSCFetchPaymentProduct from './hooks/useSCFetchPaymentProduct';
|
|
76
|
+
import useSCFetchPaymentOrder from './hooks/useSCFetchPaymentOrder';
|
|
76
77
|
/**
|
|
77
78
|
* Routing component
|
|
78
79
|
*/
|
|
@@ -84,7 +85,7 @@ import * as SCRoutes from './constants/Routes';
|
|
|
84
85
|
*/
|
|
85
86
|
import * as UserUtils from './utils/user';
|
|
86
87
|
import getTheme from './themes/theme';
|
|
87
|
-
import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility } from './utils/hooks';
|
|
88
|
+
import { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver } from './utils/hooks';
|
|
88
89
|
import { getEventStatus } from './utils/event';
|
|
89
90
|
/**
|
|
90
91
|
* Constants:
|
|
@@ -95,4 +96,4 @@ import * as Preferences from './constants/Preferences';
|
|
|
95
96
|
/**
|
|
96
97
|
* List all exports
|
|
97
98
|
*/
|
|
98
|
-
export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType, SCJoinedCoursesManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, };
|
|
99
|
+
export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType, SCJoinedCoursesManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, getTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, getEventStatus, Locale, Preferences, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchLessonCommentObject, useSCFetchLessonCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent, useSCFetchEvents, useSCFetchLiveStream, useSCGoogleApiLoader, useSCFetchCourse, useSCFetchCourses, useSCFetchLesson, useSCPaymentsEnabled, useSCFetchPaymentProduct, useSCFetchPaymentOrder, };
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSCFetchCategories = exports.useSCFetchCategory = exports.useSCFetchAddressingTagList = exports.useSCFetchTag = exports.useSCFetchCustomAdv = exports.useSCFetchLessonCommentObjects = exports.useSCFetchLessonCommentObject = exports.useSCFetchCommentObjects = exports.useSCFetchCommentObject = exports.useSCFetchFeedObject = exports.useSCFetchVote = exports.useSCFetchUserProviders = exports.useSCFetchUser = exports.Preferences = exports.Locale = exports.getEventStatus = exports.UserUtils = exports.SCCache = exports.SCRoutes = exports.Link = exports.useSCAlertMessages = exports.SCAlertMessagesContext = exports.SCAlertMessagesProvider = exports.useSCNotification = exports.SCNotificationContext = exports.SCNotificationProvider = exports.SCNotification = exports.SCFeatures = exports.SCPreferences = exports.SCPreferencesProvider = exports.withSCLocale = exports.useSCLocale = exports.SCLocaleProvider = exports.useSCRouting = exports.SCRoutingProvider = exports.getTheme = exports.withSCTheme = exports.useSCTheme = exports.SCThemeProvider = exports.useSCPreferences = exports.useSCUser = exports.SCUserProvider = exports.SCContextProvider = exports.useSCContext = exports.SCPreferencesContext = exports.SCLocaleContext = exports.SCRoutingContext = exports.SCThemeContext = exports.SCUserContext = exports.SCContext = void 0;
|
|
4
|
-
exports.useSCFetchPaymentProduct = exports.useSCPaymentsEnabled = exports.useSCFetchLesson = exports.useSCFetchCourses = exports.useSCFetchCourse = exports.useSCGoogleApiLoader = exports.useSCFetchLiveStream = exports.useSCFetchEvents = exports.useSCFetchEvent = exports.useSCFetchGroups = exports.useSCFetchGroup = exports.useSCUserIsBlocked = exports.useSCFetchUserBlockedBy = exports.useSCFetchBroadcastMessages = exports.useSCFetchPrivateMessageSnippets = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = exports.useSCFetchFeed = exports.useSCFetchContributors = exports.useSCMediaClick = exports.useSCFetchIncubator = void 0;
|
|
4
|
+
exports.useSCFetchPaymentOrder = exports.useSCFetchPaymentProduct = exports.useSCPaymentsEnabled = exports.useSCFetchLesson = exports.useSCFetchCourses = exports.useSCFetchCourse = exports.useSCGoogleApiLoader = exports.useSCFetchLiveStream = exports.useSCFetchEvents = exports.useSCFetchEvent = exports.useSCFetchGroups = exports.useSCFetchGroup = exports.useSCUserIsBlocked = exports.useSCFetchUserBlockedBy = exports.useSCFetchBroadcastMessages = exports.useSCFetchPrivateMessageSnippets = exports.useResizeObserver = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = exports.useSCFetchFeed = exports.useSCFetchContributors = exports.useSCMediaClick = exports.useSCFetchIncubator = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
/**
|
|
7
7
|
* ContextProvider component
|
|
@@ -136,6 +136,8 @@ const useSCPaymentsEnabled_1 = tslib_1.__importDefault(require("./hooks/useSCPay
|
|
|
136
136
|
exports.useSCPaymentsEnabled = useSCPaymentsEnabled_1.default;
|
|
137
137
|
const useSCFetchPaymentProduct_1 = tslib_1.__importDefault(require("./hooks/useSCFetchPaymentProduct"));
|
|
138
138
|
exports.useSCFetchPaymentProduct = useSCFetchPaymentProduct_1.default;
|
|
139
|
+
const useSCFetchPaymentOrder_1 = tslib_1.__importDefault(require("./hooks/useSCFetchPaymentOrder"));
|
|
140
|
+
exports.useSCFetchPaymentOrder = useSCFetchPaymentOrder_1.default;
|
|
139
141
|
/**
|
|
140
142
|
* Routing component
|
|
141
143
|
*/
|
|
@@ -158,6 +160,7 @@ Object.defineProperty(exports, "useIsomorphicLayoutEffect", { enumerable: true,
|
|
|
158
160
|
Object.defineProperty(exports, "useEffectOnce", { enumerable: true, get: function () { return hooks_1.useEffectOnce; } });
|
|
159
161
|
Object.defineProperty(exports, "useNoInitialEffect", { enumerable: true, get: function () { return hooks_1.useNoInitialEffect; } });
|
|
160
162
|
Object.defineProperty(exports, "usePageVisibility", { enumerable: true, get: function () { return hooks_1.usePageVisibility; } });
|
|
163
|
+
Object.defineProperty(exports, "useResizeObserver", { enumerable: true, get: function () { return hooks_1.useResizeObserver; } });
|
|
161
164
|
const event_1 = require("./utils/event");
|
|
162
165
|
Object.defineProperty(exports, "getEventStatus", { enumerable: true, get: function () { return event_1.getEventStatus; } });
|
|
163
166
|
/**
|
|
@@ -4,4 +4,5 @@ import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';
|
|
|
4
4
|
import useEffectOnce from './useEffectOnce';
|
|
5
5
|
import useNoInitialEffect from './useNoInitialEffect';
|
|
6
6
|
import usePageVisibility from './usePageVisibility';
|
|
7
|
-
|
|
7
|
+
import useResizeObserver from './useResizeObserver';
|
|
8
|
+
export { useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, usePageVisibility, useResizeObserver, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = void 0;
|
|
3
|
+
exports.useResizeObserver = exports.usePageVisibility = exports.useNoInitialEffect = exports.useEffectOnce = exports.useIsomorphicLayoutEffect = exports.usePreviousValue = exports.useIsComponentMountedRef = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const useIsComponentMountedRef_1 = tslib_1.__importDefault(require("./useIsComponentMountedRef"));
|
|
6
6
|
exports.useIsComponentMountedRef = useIsComponentMountedRef_1.default;
|
|
@@ -14,3 +14,5 @@ const useNoInitialEffect_1 = tslib_1.__importDefault(require("./useNoInitialEffe
|
|
|
14
14
|
exports.useNoInitialEffect = useNoInitialEffect_1.default;
|
|
15
15
|
const usePageVisibility_1 = tslib_1.__importDefault(require("./usePageVisibility"));
|
|
16
16
|
exports.usePageVisibility = usePageVisibility_1.default;
|
|
17
|
+
const useResizeObserver_1 = tslib_1.__importDefault(require("./useResizeObserver"));
|
|
18
|
+
exports.useResizeObserver = useResizeObserver_1.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useResizeObserver(element: Element | null, options: ResizeObserverOptions | undefined, observerCallback: ResizeObserverCallback): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
function useResizeObserver(element, options, observerCallback) {
|
|
5
|
+
(0, react_1.useEffect)(() => {
|
|
6
|
+
if (!element || !('ResizeObserver' in window)) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const observer = new ResizeObserver(observerCallback);
|
|
10
|
+
observer.observe(element, options);
|
|
11
|
+
return () => {
|
|
12
|
+
observer.disconnect();
|
|
13
|
+
};
|
|
14
|
+
}, [element, options, observerCallback]);
|
|
15
|
+
}
|
|
16
|
+
exports.default = useResizeObserver;
|
|
@@ -76,9 +76,12 @@ export declare const getPmSnippetsObjectCacheKey: () => string;
|
|
|
76
76
|
/** PRIVATE MESSAGE SNIPPET OBJECT **/
|
|
77
77
|
export declare const PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = "_pms_";
|
|
78
78
|
export declare const getPmSnippetObjectCacheKey: (id: any) => string;
|
|
79
|
-
/**
|
|
79
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
80
80
|
export declare const PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY = "_ppo_";
|
|
81
81
|
export declare const getPaymentProductObjectCacheKey: (id: any) => string;
|
|
82
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
83
|
+
export declare const PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = "_pord_";
|
|
84
|
+
export declare const getPaymentOrderObjectCacheKey: (id: any) => string;
|
|
82
85
|
/** TOOLS */
|
|
83
86
|
export declare const CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = "_cListWidget_";
|
|
84
87
|
export declare const CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = "_cFolWidget_";
|
|
@@ -80,9 +80,12 @@ export const getPmSnippetsObjectCacheKey = () => `${PM_SNIPPETS_OBJECT_CACHE_PRE
|
|
|
80
80
|
/** PRIVATE MESSAGE SNIPPET OBJECT **/
|
|
81
81
|
export const PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY = '_pms_';
|
|
82
82
|
export const getPmSnippetObjectCacheKey = (id) => `${PM_SNIPPET_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
83
|
-
/**
|
|
83
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
84
84
|
export const PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY = '_ppo_';
|
|
85
85
|
export const getPaymentProductObjectCacheKey = (id) => `${PAYMENT_PRODUCT_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
86
|
+
/** PAYMENT PRODUCT OBJECT **/
|
|
87
|
+
export const PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY = '_pord_';
|
|
88
|
+
export const getPaymentOrderObjectCacheKey = (id) => `${PAYMENT_ORDER_OBJECT_CACHE_PREFIX_KEY}${id}`;
|
|
86
89
|
/** TOOLS */
|
|
87
90
|
export const CATEGORIES_LIST_TOOLS_STATE_CACHE_PREFIX_KEY = '_cListWidget_';
|
|
88
91
|
export const CATEGORIES_FOLLOWED_TOOLS_STATE_CACHE_PREFIX_KEY = '_cFolWidget_';
|
|
@@ -25,6 +25,7 @@ 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
26
|
export declare const USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = "user_followed_discussions";
|
|
27
27
|
export declare const USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME = "user_payments_history_orders";
|
|
28
|
+
export declare const USER_PAYMENTS_ORDER_PDF_ROUTE_NAME = "user_payments_order_pdf";
|
|
28
29
|
export declare const USER_PAYMENT_METHODS_ROUTE_NAME = "user_payment_methods";
|
|
29
30
|
export declare const LOYALTY_ROUTE_NAME = "loyalty";
|
|
30
31
|
export declare const INCUBATOR_ROUTE_NAME = "incubator";
|
|
@@ -25,6 +25,7 @@ export const USER_PROFILE_CATEGORIES_ROUTE_NAME = 'user_categories';
|
|
|
25
25
|
export const USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME = 'user_followed_posts';
|
|
26
26
|
export const USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME = 'user_followed_discussions';
|
|
27
27
|
export const USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME = 'user_payments_history_orders';
|
|
28
|
+
export const USER_PAYMENTS_ORDER_PDF_ROUTE_NAME = 'user_payments_order_pdf';
|
|
28
29
|
export const USER_PAYMENT_METHODS_ROUTE_NAME = 'user_payment_methods';
|
|
29
30
|
export const LOYALTY_ROUTE_NAME = 'loyalty';
|
|
30
31
|
export const INCUBATOR_ROUTE_NAME = 'incubator';
|
|
@@ -80,6 +81,7 @@ export const defaultRoutes = {
|
|
|
80
81
|
[USER_PROFILE_FOLLOWED_POSTS_ROUTE_NAME]: '/user/:id/posts/followed/',
|
|
81
82
|
[USER_PROFILE_FOLLOWED_DISCUSSIONS_ROUTE_NAME]: '/user/:id/discussions/followed/',
|
|
82
83
|
[USER_PAYMENTS_HISTORY_ORDERS_ROUTE_NAME]: '/user/:id/:username/history_orders/',
|
|
84
|
+
[USER_PAYMENTS_ORDER_PDF_ROUTE_NAME]: '/user/:id/:username/order/:pid/pdf/',
|
|
83
85
|
[USER_PAYMENT_METHODS_ROUTE_NAME]: '/user/:id/:username/payment_methods/',
|
|
84
86
|
[LOYALTY_ROUTE_NAME]: '/loyalty/',
|
|
85
87
|
[INCUBATOR_ROUTE_NAME]: '/incubator/:id/',
|
|
@@ -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
|
+
}
|
|
@@ -63,12 +63,12 @@ export default function useSCJoinedCoursesManager(user) {
|
|
|
63
63
|
case SCNotificationTypologyType.USER_INVITED_TO_JOIN_COURSE:
|
|
64
64
|
_status = SCCourseJoinStatusType.INVITED;
|
|
65
65
|
break;
|
|
66
|
-
case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
/* case SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
|
|
67
|
+
_status = SCCourseJoinStatusType.REQUESTED;
|
|
68
|
+
break;
|
|
69
69
|
case SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_COURSE:
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
_status = SCCourseJoinStatusType.JOINED;
|
|
71
|
+
break; */
|
|
72
72
|
case SCNotificationTypologyType.USER_ADDED_TO_COURSE:
|
|
73
73
|
_status = SCCourseJoinStatusType.JOINED;
|
|
74
74
|
break;
|
|
@@ -247,7 +247,7 @@ export default function useSCJoinedCoursesManager(user) {
|
|
|
247
247
|
if (cache.includes(course.id)) {
|
|
248
248
|
return getCurrentCourseCacheStatus(course);
|
|
249
249
|
}
|
|
250
|
-
if (authUserId) {
|
|
250
|
+
if (authUserId && course) {
|
|
251
251
|
if ('join_status' in course) {
|
|
252
252
|
return getJoinStatus(course);
|
|
253
253
|
}
|
|
@@ -256,7 +256,7 @@ export default function useSCJoinedCoursesManager(user) {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
return null;
|
|
259
|
-
}, [loading, cache, authUserId]);
|
|
259
|
+
}, [loading, cache, authUserId, getJoinStatus, getCurrentCourseCacheStatus]);
|
|
260
260
|
/**
|
|
261
261
|
* Empty cache on logout
|
|
262
262
|
*/
|