@selfcommunity/react-core 0.6.7-payments.169 → 0.7.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/cjs/constants/Cache.d.ts +0 -3
  2. package/lib/cjs/constants/Cache.js +1 -5
  3. package/lib/cjs/constants/Preferences.d.ts +0 -3
  4. package/lib/cjs/constants/Preferences.js +1 -7
  5. package/lib/cjs/constants/Routes.d.ts +0 -3
  6. package/lib/cjs/constants/Routes.js +1 -8
  7. package/lib/cjs/hooks/useSCFetchCategory.d.ts +0 -1
  8. package/lib/cjs/hooks/useSCFetchCategory.js +1 -18
  9. package/lib/cjs/hooks/useSCFetchCourse.js +15 -15
  10. package/lib/cjs/hooks/useSCFetchEvent.d.ts +0 -1
  11. package/lib/cjs/hooks/useSCFetchEvent.js +1 -16
  12. package/lib/cjs/hooks/useSCFetchGroup.d.ts +0 -1
  13. package/lib/cjs/hooks/useSCFetchGroup.js +1 -16
  14. package/lib/cjs/hooks/useSCJoinedCoursesManager.js +4 -4
  15. package/lib/cjs/hooks/useSCSubscribedEventsManager.js +4 -4
  16. package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +4 -4
  17. package/lib/cjs/index.d.ts +1 -3
  18. package/lib/cjs/index.js +1 -5
  19. package/lib/cjs/themes/theme.js +0 -12
  20. package/lib/cjs/types/theme.d.ts +0 -52
  21. package/lib/esm/constants/Cache.d.ts +0 -3
  22. package/lib/esm/constants/Cache.js +0 -3
  23. package/lib/esm/constants/Preferences.d.ts +0 -3
  24. package/lib/esm/constants/Preferences.js +0 -6
  25. package/lib/esm/constants/Routes.d.ts +0 -3
  26. package/lib/esm/constants/Routes.js +0 -6
  27. package/lib/esm/hooks/useSCFetchCategory.d.ts +0 -1
  28. package/lib/esm/hooks/useSCFetchCategory.js +1 -18
  29. package/lib/esm/hooks/useSCFetchCourse.js +15 -15
  30. package/lib/esm/hooks/useSCFetchEvent.d.ts +0 -1
  31. package/lib/esm/hooks/useSCFetchEvent.js +1 -16
  32. package/lib/esm/hooks/useSCFetchGroup.d.ts +0 -1
  33. package/lib/esm/hooks/useSCFetchGroup.js +1 -16
  34. package/lib/esm/hooks/useSCJoinedCoursesManager.js +4 -4
  35. package/lib/esm/hooks/useSCSubscribedEventsManager.js +4 -4
  36. package/lib/esm/hooks/useSCSubscribedGroupsManager.js +4 -4
  37. package/lib/esm/index.d.ts +1 -3
  38. package/lib/esm/index.js +1 -3
  39. package/lib/esm/themes/theme.js +0 -12
  40. package/lib/esm/types/theme.d.ts +0 -52
  41. package/lib/umd/react-core.js +1 -1
  42. package/package.json +6 -6
  43. package/lib/cjs/hooks/useSCFetchPaymentProduct.d.ts +0 -20
  44. package/lib/cjs/hooks/useSCFetchPaymentProduct.js +0 -70
  45. package/lib/cjs/hooks/useSCPaymentsEnabled.d.ts +0 -18
  46. package/lib/cjs/hooks/useSCPaymentsEnabled.js +0 -35
  47. package/lib/esm/hooks/useSCFetchPaymentProduct.d.ts +0 -20
  48. package/lib/esm/hooks/useSCFetchPaymentProduct.js +0 -67
  49. package/lib/esm/hooks/useSCPaymentsEnabled.d.ts +0 -18
  50. package/lib/esm/hooks/useSCPaymentsEnabled.js +0 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selfcommunity/react-core",
3
- "version": "0.6.7-payments.169+035bd7112",
3
+ "version": "0.7.0-alpha.0",
4
4
  "description": "React Core Components useful for integrating UI Community components (react-ui).",
5
5
  "author": "SelfCommunity <https://www.selfcommunity.com>",
6
6
  "homepage": "https://www.selfcommunity.com",
@@ -68,10 +68,10 @@
68
68
  "react-intl": "^6.4.7"
69
69
  },
70
70
  "dependencies": {
71
- "@selfcommunity/api-services": "0.6.7-payments.169+035bd7112",
72
- "@selfcommunity/react-i18n": "0.7.7-payments.169+035bd7112",
73
- "@selfcommunity/types": "0.7.7-payments.169+035bd7112",
74
- "@selfcommunity/utils": "0.2.64-payments.169+035bd7112",
71
+ "@selfcommunity/api-services": "^0.7.0-alpha.0",
72
+ "@selfcommunity/react-i18n": "^0.8.0-alpha.14",
73
+ "@selfcommunity/types": "^0.8.0-alpha.0",
74
+ "@selfcommunity/utils": "^0.2.64-alpha.1",
75
75
  "js-cookie": "^3.0.5",
76
76
  "pubsub-js": "^1.9.5",
77
77
  "use-deep-compare-effect": "^1.8.1",
@@ -130,5 +130,5 @@
130
130
  "bugs": {
131
131
  "url": "https://github.com/selfcommunity/community-js/issues"
132
132
  },
133
- "gitHead": "035bd7112ea24db5ce43bb903662d6123e572d06"
133
+ "gitHead": "03d4b894685ad0ab6a4db32b1ac5f8dfecf4befb"
134
134
  }
@@ -1,20 +0,0 @@
1
- import { SCPaymentProduct } from '@selfcommunity/types';
2
- import { CacheStrategies } from '@selfcommunity/utils';
3
- /**
4
- :::info
5
- This custom hook is used to fetch a payment product.
6
- :::
7
- * @param object
8
- * @param object.id
9
- * @param object.paymentProduct
10
- * @param object.cacheStrategy
11
- */
12
- export default function useSCFetchPaymentProduct({ id, paymentProduct, cacheStrategy, }: {
13
- id?: number | string;
14
- paymentProduct?: SCPaymentProduct;
15
- cacheStrategy?: CacheStrategies;
16
- }): {
17
- scPaymentProduct: SCPaymentProduct;
18
- setSCPaymentProduct: (c: SCPaymentProduct) => void;
19
- error: string;
20
- };
@@ -1,70 +0,0 @@
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 product.
13
- :::
14
- * @param object
15
- * @param object.id
16
- * @param object.paymentProduct
17
- * @param object.cacheStrategy
18
- */
19
- function useSCFetchPaymentProduct({ id = null, paymentProduct = null, cacheStrategy = utils_1.CacheStrategies.NETWORK_ONLY, }) {
20
- const __paymentProductId = (0, react_1.useMemo)(() => (paymentProduct === null || paymentProduct === void 0 ? void 0 : paymentProduct.id) || id, [paymentProduct, 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 __paymentProductCacheKey = (0, react_1.useMemo)(() => (0, Cache_1.getPaymentProductObjectCacheKey)(__paymentProductId), [__paymentProductId]);
26
- const [scPaymentProduct, setScPaymentProduct] = (0, react_1.useState)(cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? utils_1.LRUCache.get(__paymentProductCacheKey, paymentProduct) : null);
27
- const [error, setError] = (0, react_1.useState)(null);
28
- const setSCPaymentProduct = (0, react_1.useCallback)((c) => {
29
- setScPaymentProduct(c);
30
- utils_1.LRUCache.set(__paymentProductCacheKey, c);
31
- }, [setScPaymentProduct, __paymentProductCacheKey]);
32
- /**
33
- * Memoized fetch product
34
- */
35
- const fetchPaymentProduct = (0, react_1.useMemo)(() => (id) => {
36
- return api_services_1.http
37
- .request({
38
- url: api_services_1.Endpoints.GetProduct.url({ id }),
39
- method: api_services_1.Endpoints.GetProduct.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 && !paymentProduct) {
53
- fetchPaymentProduct(id)
54
- .then((e) => {
55
- setSCPaymentProduct(e);
56
- })
57
- .catch((err) => {
58
- utils_1.LRUCache.delete(__paymentProductCacheKey);
59
- utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, err.message);
60
- });
61
- }
62
- }, [id, paymentProduct, authUserId]);
63
- (0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
64
- if (paymentProduct) {
65
- setSCPaymentProduct(paymentProduct);
66
- }
67
- }, [paymentProduct, authUserId]);
68
- return { scPaymentProduct, setSCPaymentProduct, error };
69
- }
70
- exports.default = useSCFetchPaymentProduct;
@@ -1,18 +0,0 @@
1
- /**
2
- :::info
3
- This custom hook is used to check if the payments are enabled
4
- :::
5
- :::tip How to use it:
6
-
7
- Follow these steps:
8
- ```jsx
9
- 1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
10
- 2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
11
- ```
12
- :::
13
- */
14
- export default function useSCPaymentsEnabled(): {
15
- isPaymentsEnabled: any;
16
- stripePublicKey: any;
17
- stripeConnectedAccountId: any;
18
- };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const react_1 = require("react");
5
- const types_1 = require("@selfcommunity/types");
6
- const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
7
- const SCPreferences = tslib_1.__importStar(require("../constants/Preferences"));
8
- /**
9
- :::info
10
- This custom hook is used to check if the payments are enabled
11
- :::
12
- :::tip How to use it:
13
-
14
- Follow these steps:
15
- ```jsx
16
- 1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
17
- 2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
18
- ```
19
- :::
20
- */
21
- function useSCPaymentsEnabled() {
22
- // CONTEXT
23
- const { preferences, features } = (0, SCPreferencesProvider_1.useSCPreferences)();
24
- const isPaymentsEnabled = (0, react_1.useMemo)(() => preferences &&
25
- features &&
26
- features.includes(types_1.SCFeatureName.PAYMENTS) &&
27
- SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED in preferences &&
28
- preferences[SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED].value, [preferences]);
29
- const stripePublicKey = (0, react_1.useMemo)(() => preferences && SCPreferences.STATIC_STRIPE_PUBLIC_KEY in preferences && preferences[SCPreferences.STATIC_STRIPE_PUBLIC_KEY].value, [preferences]);
30
- const stripeConnectedAccountId = (0, react_1.useMemo)(() => preferences &&
31
- SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID in preferences &&
32
- preferences[SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID].value, [preferences]);
33
- return { isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId };
34
- }
35
- exports.default = useSCPaymentsEnabled;
@@ -1,20 +0,0 @@
1
- import { SCPaymentProduct } from '@selfcommunity/types';
2
- import { CacheStrategies } from '@selfcommunity/utils';
3
- /**
4
- :::info
5
- This custom hook is used to fetch a payment product.
6
- :::
7
- * @param object
8
- * @param object.id
9
- * @param object.paymentProduct
10
- * @param object.cacheStrategy
11
- */
12
- export default function useSCFetchPaymentProduct({ id, paymentProduct, cacheStrategy, }: {
13
- id?: number | string;
14
- paymentProduct?: SCPaymentProduct;
15
- cacheStrategy?: CacheStrategies;
16
- }): {
17
- scPaymentProduct: SCPaymentProduct;
18
- setSCPaymentProduct: (c: SCPaymentProduct) => void;
19
- error: string;
20
- };
@@ -1,67 +0,0 @@
1
- import { Endpoints, http } from '@selfcommunity/api-services';
2
- import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
3
- import { useCallback, useEffect, useMemo, useState } from 'react';
4
- import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
5
- import { useSCUser } from '../components/provider/SCUserProvider';
6
- import { getPaymentProductObjectCacheKey } from '../constants/Cache';
7
- import { SCOPE_SC_CORE } from '../constants/Errors';
8
- /**
9
- :::info
10
- This custom hook is used to fetch a payment product.
11
- :::
12
- * @param object
13
- * @param object.id
14
- * @param object.paymentProduct
15
- * @param object.cacheStrategy
16
- */
17
- export default function useSCFetchPaymentProduct({ id = null, paymentProduct = null, cacheStrategy = CacheStrategies.NETWORK_ONLY, }) {
18
- const __paymentProductId = useMemo(() => (paymentProduct === null || paymentProduct === void 0 ? void 0 : paymentProduct.id) || id, [paymentProduct, id]);
19
- // CONTEXT
20
- const scUserContext = useSCUser();
21
- const authUserId = useMemo(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) || null; }, [scUserContext.user]);
22
- // CACHE
23
- const __paymentProductCacheKey = useMemo(() => getPaymentProductObjectCacheKey(__paymentProductId), [__paymentProductId]);
24
- const [scPaymentProduct, setScPaymentProduct] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__paymentProductCacheKey, paymentProduct) : null);
25
- const [error, setError] = useState(null);
26
- const setSCPaymentProduct = useCallback((c) => {
27
- setScPaymentProduct(c);
28
- LRUCache.set(__paymentProductCacheKey, c);
29
- }, [setScPaymentProduct, __paymentProductCacheKey]);
30
- /**
31
- * Memoized fetch product
32
- */
33
- const fetchPaymentProduct = useMemo(() => (id) => {
34
- return http
35
- .request({
36
- url: Endpoints.GetProduct.url({ id }),
37
- method: Endpoints.GetProduct.method,
38
- })
39
- .then((res) => {
40
- if (res.status >= 300) {
41
- return Promise.reject(res);
42
- }
43
- return Promise.resolve(res.data);
44
- });
45
- }, []);
46
- /**
47
- * If id attempt to get the course by id
48
- */
49
- useEffect(() => {
50
- if (id !== null && id !== undefined && !paymentProduct) {
51
- fetchPaymentProduct(id)
52
- .then((e) => {
53
- setSCPaymentProduct(e);
54
- })
55
- .catch((err) => {
56
- LRUCache.delete(__paymentProductCacheKey);
57
- Logger.error(SCOPE_SC_CORE, err.message);
58
- });
59
- }
60
- }, [id, paymentProduct, authUserId]);
61
- useDeepCompareEffectNoCheck(() => {
62
- if (paymentProduct) {
63
- setSCPaymentProduct(paymentProduct);
64
- }
65
- }, [paymentProduct, authUserId]);
66
- return { scPaymentProduct, setSCPaymentProduct, error };
67
- }
@@ -1,18 +0,0 @@
1
- /**
2
- :::info
3
- This custom hook is used to check if the payments are enabled
4
- :::
5
- :::tip How to use it:
6
-
7
- Follow these steps:
8
- ```jsx
9
- 1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
10
- 2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
11
- ```
12
- :::
13
- */
14
- export default function useSCPaymentsEnabled(): {
15
- isPaymentsEnabled: any;
16
- stripePublicKey: any;
17
- stripeConnectedAccountId: any;
18
- };
@@ -1,31 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { SCFeatureName } from '@selfcommunity/types';
3
- import { useSCPreferences } from '../components/provider/SCPreferencesProvider';
4
- import * as SCPreferences from '../constants/Preferences';
5
- /**
6
- :::info
7
- This custom hook is used to check if the payments are enabled
8
- :::
9
- :::tip How to use it:
10
-
11
- Follow these steps:
12
- ```jsx
13
- 1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
14
- 2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
15
- ```
16
- :::
17
- */
18
- export default function useSCPaymentsEnabled() {
19
- // CONTEXT
20
- const { preferences, features } = useSCPreferences();
21
- const isPaymentsEnabled = useMemo(() => preferences &&
22
- features &&
23
- features.includes(SCFeatureName.PAYMENTS) &&
24
- SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED in preferences &&
25
- preferences[SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED].value, [preferences]);
26
- const stripePublicKey = useMemo(() => preferences && SCPreferences.STATIC_STRIPE_PUBLIC_KEY in preferences && preferences[SCPreferences.STATIC_STRIPE_PUBLIC_KEY].value, [preferences]);
27
- const stripeConnectedAccountId = useMemo(() => preferences &&
28
- SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID in preferences &&
29
- preferences[SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID].value, [preferences]);
30
- return { isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId };
31
- }