mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
re-structure to monorepo.
This commit is contained in:
14
packages/webapp/src/components/FeatureGuard/FeatureCan.tsx
Normal file
14
packages/webapp/src/components/FeatureGuard/FeatureCan.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import * as R from 'ramda';
|
||||
import withFeatureCan from './withFeatureCan';
|
||||
|
||||
function FeatureCanJSX({ feature, children, isFeatureCan }) {
|
||||
return isFeatureCan && children;
|
||||
}
|
||||
|
||||
export const FeatureCan = R.compose(
|
||||
withFeatureCan(({ isFeatureCan }) => ({
|
||||
isFeatureCan,
|
||||
})),
|
||||
)(FeatureCanJSX);
|
||||
2
packages/webapp/src/components/FeatureGuard/index.tsx
Normal file
2
packages/webapp/src/components/FeatureGuard/index.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
// @ts-nocheck
|
||||
export * from './FeatureCan';
|
||||
@@ -0,0 +1,18 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
import { getDashboardFeaturesSelector } from '@/store/dashboard/dashboard.selectors';
|
||||
|
||||
export default (mapState) => {
|
||||
const featuresSelector = getDashboardFeaturesSelector();
|
||||
|
||||
const mapStateToProps = (state, props) => {
|
||||
const features = featuresSelector(state);
|
||||
|
||||
const mapped = {
|
||||
isFeatureCan: !!features[props.feature],
|
||||
features,
|
||||
};
|
||||
return mapState ? mapState(mapped, state, props) : mapped;
|
||||
};
|
||||
return connect(mapStateToProps);
|
||||
};
|
||||
Reference in New Issue
Block a user