feat: add feature guard as hook and component.

This commit is contained in:
a.bouhuolia
2022-02-13 16:29:50 +02:00
parent fdd52f1ecf
commit 9b7befc544
12 changed files with 134 additions and 39 deletions

View File

@@ -0,0 +1,17 @@
import { useSelector } from 'react-redux';
import { createSelector } from 'reselect';
const featuresSelector = createSelector(
(state) => state.dashboard.features,
(features) => features,
);
export const useFeatureCan = () => {
const features = useSelector(featuresSelector);
return {
featureCan: (feature) => {
return !!features[feature];
},
};
};

View File

@@ -3,4 +3,5 @@ export * from './authentication';
export * from './globalErrors';
export * from './subscriptions';
export * from './organizations';
export * from './settings';
export * from './settings';
export * from './feature';