mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat: add feature guard as hook and component.
This commit is contained in:
17
src/hooks/state/feature.js
Normal file
17
src/hooks/state/feature.js
Normal 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];
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -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';
|
||||
Reference in New Issue
Block a user