|
1
|
import { useQuery } from "@tanstack/react-query" |
|
2
|
import { sdk } from "../../lib/client" |
|
3
|
|
|
4
|
export type FeatureFlags = { |
|
5
|
view_configurations?: boolean |
|
6
|
translation?: boolean |
|
7
|
rbac?: boolean |
|
8
|
[key: string]: boolean | undefined |
|
9
|
} |
|
10
|
|
|
11
|
export const useFeatureFlags = () => { |
|
12
|
return useQuery<FeatureFlags>({ |
|
13
|
queryKey: ["admin", "feature-flags"], |
|
14
|
queryFn: async () => { |
|
15
|
const response = await sdk.client.fetch<{ feature_flags: FeatureFlags }>( |
|
16
|
"/admin/feature-flags", |
|
17
|
{ |
|
18
|
method: "GET", |
|
19
|
} |
|
20
|
) |
|
21
|
|
|
22
|
return response.feature_flags |
|
23
|
}, |
|
24
|
staleTime: 5 * 60 * 1000, // Cache for 5 minutes |
|
25
|
gcTime: 10 * 60 * 1000, // Keep in cache for 10 minutes |
|
26
|
}) |
|
27
|
} |