-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f37f0e
commit 9f14088
Showing
4 changed files
with
97 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
import getFeaturesFlags from 'api/features/getFeatureFlags'; | ||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys'; | ||
import { useQuery, UseQueryResult } from 'react-query'; | ||
import { useSelector } from 'react-redux'; | ||
import { AppState } from 'store/reducers'; | ||
import { FeatureFlagProps } from 'types/api/features/getFeaturesFlags'; | ||
|
||
const useGetFeatureFlag = ( | ||
onSuccessHandler: (routes: FeatureFlagProps[]) => void, | ||
): UseQueryResult<FeatureFlagProps[], unknown> => { | ||
const userId: string = useSelector<AppState, string>( | ||
(state) => state.app.user?.userId || '', | ||
); | ||
|
||
return useQuery<FeatureFlagProps[]>({ | ||
userEmail: string, | ||
): UseQueryResult<FeatureFlagProps[], unknown> => | ||
useQuery<FeatureFlagProps[]>({ | ||
queryFn: getFeaturesFlags, | ||
queryKey: [REACT_QUERY_KEY.GET_FEATURES_FLAGS, userId], | ||
queryKey: [REACT_QUERY_KEY.GET_FEATURES_FLAGS, userEmail], | ||
onSuccess: onSuccessHandler, | ||
retryOnMount: false, | ||
enabled: !!userEmail, | ||
}); | ||
}; | ||
|
||
export default useGetFeatureFlag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters