Co-authored-by: Michael Chihlas <michael@resolutionflow.com> Co-committed-by: Michael Chihlas <michael@resolutionflow.com>
17 lines
576 B
TypeScript
17 lines
576 B
TypeScript
import { useBillingStore } from '@/store/billingStore'
|
|
|
|
/**
|
|
* Returns whether a feature flag is enabled for the current account.
|
|
*
|
|
* Reads from `useBillingStore.enabledFeatures`, which is populated by
|
|
* `GET /billing/state`. Returns `false` when the flag is absent (closed-by-default).
|
|
*
|
|
* The hook subscribes to the store so updates from `refetch()` propagate
|
|
* without manual refetch in the component.
|
|
*/
|
|
export function useFeature(flagKey: string): boolean {
|
|
return useBillingStore((state) => Boolean(state.enabledFeatures[flagKey]))
|
|
}
|
|
|
|
export default useFeature
|