feat: view config feature flag (#13171)
* feat: add view_configurations feature flag - Add feature flag provider and hooks to admin dashboard - Add backend API endpoint for feature flags - Create view_configurations feature flag (disabled by default) - Update order list table to use legacy version when flag is disabled - Can be enabled with MEDUSA_FF_VIEW_CONFIGURATIONS=true env var * fix: naming * fix: feature flags unauthenticated * fix: add test
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { sdk } from "../../lib/client"
|
||||
|
||||
export type FeatureFlags = {
|
||||
view_configurations?: boolean
|
||||
[key: string]: boolean | undefined
|
||||
}
|
||||
|
||||
export const useFeatureFlags = () => {
|
||||
return useQuery<FeatureFlags>({
|
||||
queryKey: ["admin", "feature-flags"],
|
||||
queryFn: async () => {
|
||||
const response = await sdk.client.fetch<{ feature_flags: FeatureFlags }>("/admin/feature-flags", {
|
||||
method: "GET",
|
||||
})
|
||||
|
||||
return response.feature_flags
|
||||
},
|
||||
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
|
||||
cacheTime: 10 * 60 * 1000, // Keep in cache for 10 minutes
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user