import { useEnvironmentStore } from '../environment-store'; import { api } from '../client'; /** Returns the currently selected env slug, throwing if none is selected. * Alerts routes require an env context — callers should gate on `selectedEnv` * via `enabled:` before invoking these hooks. */ export function useSelectedEnvOrThrow(): string { const env = useEnvironmentStore((s) => s.environment); if (!env) { throw new Error('Alerting requires a selected environment.'); } return env; } export function useSelectedEnv(): string | undefined { return useEnvironmentStore((s) => s.environment); } /** Re-exported openapi-fetch client for alerting query hooks. * The underlying export in `../client` is named `api`; we re-export as * `apiClient` so alerting hooks can import it under the plan's canonical name. */ export { api as apiClient };