- pipeline funnel: count active interests by current stage (drop created_at window) — backfill had collapsed it to early stages (UAT 2026-06-03) - pipeline value tile: render current-state (don't thread the date range) - deal pulse chip: gate on the pulse_enabled master toggle (default ON) — was rendering even when admin turned it off; useFeatureFlag gains a default arg + the feature-flag endpoint a ?default= param (default-ON safe) - contact phone display: show international format + country flag (E164), not the bare national format that hid the country - berths: remove the dead row-density toggle; widen "Under offer to" chip on desktop so client names aren't truncated Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
25 lines
805 B
TypeScript
25 lines
805 B
TypeScript
'use client';
|
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import { apiFetch } from '@/lib/api/client';
|
|
|
|
/**
|
|
* Returns true when the given feature flag is enabled for the current port.
|
|
* Result is cached for 5 minutes.
|
|
*/
|
|
export function useFeatureFlag(key: string, defaultValue = false): boolean {
|
|
const { data } = useQuery<{ enabled: boolean }>({
|
|
queryKey: ['feature-flag', key, defaultValue],
|
|
queryFn: () =>
|
|
apiFetch(
|
|
`/api/v1/settings/feature-flag?key=${encodeURIComponent(key)}&default=${defaultValue}`,
|
|
),
|
|
staleTime: 300_000, // 5 min
|
|
});
|
|
// `defaultValue` is the fallback both while loading AND when the port has
|
|
// never written the setting — so default-ON flags (chip visible) don't
|
|
// flash hidden.
|
|
return data?.enabled ?? defaultValue;
|
|
}
|