@frontegg/react-hooks 6.143.0-alpha.1 → 6.143.0-alpha.2

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.
@@ -14,3 +14,10 @@ export declare const usePermissionEntitlements: (key: string) => Entitlement;
14
14
  @returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
15
15
  */
16
16
  export declare const useEntitlements: (options: EntitledToOptions) => Entitlement;
17
+ /**
18
+ @param entitledToOptions including permission or feature key
19
+ @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
20
+ */
21
+ export declare const useEntitlementsActions: () => {
22
+ isEntitledTo: (options: EntitledToOptions) => Entitlement;
23
+ };
@@ -1,5 +1,6 @@
1
1
  import { getPermissionEntitlements, getFeatureEntitlements, getEntitlements } from '@frontegg/redux-store';
2
2
  import { useAuth } from './hooks';
3
+ import { useMemo } from 'react';
3
4
 
4
5
  /**
5
6
  * @returns entitlemenets state as stored in the user
@@ -33,4 +34,15 @@ export const usePermissionEntitlements = key => {
33
34
  export const useEntitlements = options => {
34
35
  const entitlements = useEntitlementsState();
35
36
  return getEntitlements(entitlements, options);
37
+ };
38
+
39
+ /**
40
+ @param entitledToOptions including permission or feature key
41
+ @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
42
+ */
43
+ export const useEntitlementsActions = () => {
44
+ const entitlements = useEntitlementsState();
45
+ return useMemo(() => ({
46
+ isEntitledTo: options => getEntitlements(entitlements, options)
47
+ }), [entitlements]);
36
48
  };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.143.0-alpha.1
1
+ /** @license Frontegg v6.143.0-alpha.2
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.
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.usePermissionEntitlements = exports.useFeatureEntitlements = exports.useEntitlements = void 0;
6
+ exports.usePermissionEntitlements = exports.useFeatureEntitlements = exports.useEntitlementsActions = exports.useEntitlements = void 0;
7
7
  var _reduxStore = require("@frontegg/redux-store");
8
8
  var _hooks = require("./hooks");
9
+ var _react = require("react");
9
10
  /**
10
11
  * @returns entitlemenets state as stored in the user
11
12
  */
@@ -41,4 +42,16 @@ const useEntitlements = options => {
41
42
  const entitlements = useEntitlementsState();
42
43
  return (0, _reduxStore.getEntitlements)(entitlements, options);
43
44
  };
44
- exports.useEntitlements = useEntitlements;
45
+
46
+ /**
47
+ @param entitledToOptions including permission or feature key
48
+ @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
49
+ */
50
+ exports.useEntitlements = useEntitlements;
51
+ const useEntitlementsActions = () => {
52
+ const entitlements = useEntitlementsState();
53
+ return (0, _react.useMemo)(() => ({
54
+ isEntitledTo: options => (0, _reduxStore.getEntitlements)(entitlements, options)
55
+ }), [entitlements]);
56
+ };
57
+ exports.useEntitlementsActions = useEntitlementsActions;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.143.0-alpha.1
1
+ /** @license Frontegg v6.143.0-alpha.2
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.143.0-alpha.1",
3
+ "version": "6.143.0-alpha.2",
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.143.0-alpha.1",
10
- "@frontegg/types": "6.143.0-alpha.1",
9
+ "@frontegg/redux-store": "6.143.0-alpha.2",
10
+ "@frontegg/types": "6.143.0-alpha.2",
11
11
  "@types/react": "*",
12
12
  "get-value": "^3.0.1",
13
13
  "react-redux": "^7.x"