Seed core views in dev + fixes (#14071)
Seed core views in dev --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@@ -1,24 +1,10 @@
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { extractFeatureFlagMapFromWorkspace } from '@/workspace/utils/extractFeatureFlagMapFromWorkspace';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { FeatureFlagKey } from '~/generated/graphql';
|
||||
import { buildRecordFromKeysWithSameValue } from '~/utils/array/buildRecordFromKeysWithSameValue';
|
||||
import { type FeatureFlagKey } from '~/generated/graphql';
|
||||
|
||||
export const useFeatureFlagsMap = (): Record<FeatureFlagKey, boolean> => {
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||
|
||||
const currentWorkspaceFeatureFlags = currentWorkspace?.featureFlags;
|
||||
|
||||
const initialFeatureFlags = buildRecordFromKeysWithSameValue(
|
||||
Object.values(FeatureFlagKey),
|
||||
false,
|
||||
);
|
||||
|
||||
if (!currentWorkspaceFeatureFlags) {
|
||||
return initialFeatureFlags;
|
||||
}
|
||||
|
||||
return currentWorkspaceFeatureFlags.reduce((acc, featureFlag) => {
|
||||
acc[featureFlag.key] = featureFlag.value;
|
||||
return acc;
|
||||
}, initialFeatureFlags);
|
||||
return extractFeatureFlagMapFromWorkspace(currentWorkspace);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user