Skip to content

Commit 8b11802

Browse files
committed
wip
1 parent 9bb9857 commit 8b11802

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/vue/src/auth/entitlements.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import {
99
AuthState,
1010
} from '@frontegg/redux-store';
1111

12-
import { FeatureFlags, USE_ENTITLEMENTS_V2_ENDPOINT_FF } from '@frontegg/rest-api';
12+
import { USE_ENTITLEMENTS_V2_ENDPOINT_FF } from '@frontegg/rest-api';
1313

1414
import { authStateKey } from '../constants';
15-
import { useFronteggStore } from '../auth/mapAuthState';
15+
import { useFeatureFlag } from '../auth/mapAuthState';
1616

1717
/**
1818
* @returns user state
@@ -26,9 +26,7 @@ const useGetUserState = () => {
2626
* @returns true when need to use entitlements V2 API
2727
*/
2828
const useIsV2API = () => {
29-
// TODO: check should it be immediate or we can recursively inject (check when app name change?)
30-
const { appName } = useFronteggStore();
31-
const [useEntitlementsV2] = FeatureFlags.getFeatureFlags([USE_ENTITLEMENTS_V2_ENDPOINT_FF], appName);
29+
const [useEntitlementsV2] = useFeatureFlag([USE_ENTITLEMENTS_V2_ENDPOINT_FF]);
3230
return useEntitlementsV2;
3331
};
3432

@@ -41,7 +39,7 @@ const useEntitlementsQueryData = (customAttributes?: CustomAttributes) => {
4139
const entitlements = user?.entitlements;
4240
const isV2 = useIsV2API();
4341

44-
const attributes: Attributes | undefined = {
42+
const attributes: Attributes = {
4543
custom: customAttributes,
4644
jwt: user as JwtAttributes | undefined,
4745
};

packages/vue/src/auth/mapAuthState.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-ignore
22
import { inject, onUpdated, onMounted, reactive, onBeforeUnmount, computed } from 'vue';
3+
import { FeatureFlags } from '@frontegg/rest-api';
34
import { defaultGetterGenerator, objectMappers } from '../helpers';
45
import {
56
AcceptInvitationActions,
@@ -154,6 +155,11 @@ export const useLoadEntitlements = () => {
154155
return inject(loadEntitlementsKey);
155156
};
156157

158+
export const useFeatureFlag = (keys: string[]) => {
159+
const { appName } = useFronteggStore();
160+
return FeatureFlags.getFeatureFlags(keys, appName);
161+
};
162+
157163
export const useFrontegg = () => {
158164
const fronteggLoaded = useFronteggLoaded();
159165
const unsubscribeFronteggStore = useUnsubscribeFronteggStore();

0 commit comments

Comments
 (0)