@frontegg/react-hooks 6.147.0-alpha.7 → 6.148.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.
@@ -88,16 +88,22 @@ export const useEntitlements = (options, customAttributes) => {
88
88
  @returns an action your can use to detect if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
89
89
  */
90
90
  export const useEntitlementsActions = () => {
91
+ // this code is duplicated because React is yelling when using useEntitlementsQueryData inside the isEntitledTo function because it's not a hook
92
+ const user = useUserState();
93
+ const entitlements = useEntitlementsState();
94
+ const {
95
+ appName
96
+ } = useRootState();
97
+ const [useEntitlementsV2] = FeatureFlags.getFeatureFlags([USE_ENTITLEMENTS_V2_ENDPOINT_FF], appName);
91
98
  return useMemo(() => ({
92
99
  isEntitledTo: (options, customAttributes) => {
93
- const {
94
- entitlements,
95
- attributes,
96
- isV2
97
- } = useEntitlementsQueryData(customAttributes);
98
- return getEntitlements(entitlements, options, attributes, isV2);
100
+ const attributes = {
101
+ custom: customAttributes,
102
+ jwt: user
103
+ };
104
+ return getEntitlements(entitlements, options, attributes, useEntitlementsV2);
99
105
  }
100
- }), []);
106
+ }), [user, entitlements, useEntitlementsV2]);
101
107
  };
102
108
 
103
109
  /**
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.147.0-alpha.7
1
+ /** @license Frontegg v6.148.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -96,16 +96,22 @@ const useEntitlements = (options, customAttributes) => {
96
96
  */
97
97
  exports.useEntitlements = useEntitlements;
98
98
  const useEntitlementsActions = () => {
99
+ // this code is duplicated because React is yelling when using useEntitlementsQueryData inside the isEntitledTo function because it's not a hook
100
+ const user = useUserState();
101
+ const entitlements = useEntitlementsState();
102
+ const {
103
+ appName
104
+ } = (0, _common.useRootState)();
105
+ const [useEntitlementsV2] = _restApi.FeatureFlags.getFeatureFlags([_restApi.USE_ENTITLEMENTS_V2_ENDPOINT_FF], appName);
99
106
  return (0, _react.useMemo)(() => ({
100
107
  isEntitledTo: (options, customAttributes) => {
101
- const {
102
- entitlements,
103
- attributes,
104
- isV2
105
- } = useEntitlementsQueryData(customAttributes);
106
- return (0, _reduxStore.getEntitlements)(entitlements, options, attributes, isV2);
108
+ const attributes = {
109
+ custom: customAttributes,
110
+ jwt: user
111
+ };
112
+ return (0, _reduxStore.getEntitlements)(entitlements, options, attributes, useEntitlementsV2);
107
113
  }
108
- }), []);
114
+ }), [user, entitlements, useEntitlementsV2]);
109
115
  };
110
116
 
111
117
  /**
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.147.0-alpha.7
1
+ /** @license Frontegg v6.148.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/react-hooks",
3
- "version": "6.147.0-alpha.7",
3
+ "version": "6.148.0-alpha.0",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
- "@frontegg/redux-store": "6.147.0-alpha.7",
10
- "@frontegg/types": "6.147.0-alpha.7",
9
+ "@frontegg/redux-store": "6.148.0-alpha.0",
10
+ "@frontegg/types": "6.148.0-alpha.0",
11
11
  "@types/react": "*",
12
12
  "get-value": "^3.0.1",
13
13
  "react-redux": "^7.x"