import { OrganizationListLoadState, OrganizationSelectionState, OrganizationSwitcherEntity } from './organization-selection-state.js'; import { OrganizationSwitcherOption } from './organization-switcher.js'; import { OrganizationCapableAuthClient } from './use-organization-auth.js'; export interface OrganizationSwitcherSuccessEvent { organizationId: string | null; type: "switch" | "create"; } export interface UseOrganizationSwitcherOptions { /** * Controlled / server-selected active organization id (e.g. cookie or RSC prop). * Used for display resolution; session cache is still patched so client * `useSession` subscribers update without a page refresh. */ activeOrganizationId?: string | null; /** * Explicit organization-capable auth client; falls back to `AuthProvider` * via `useOrganizationAuth`. */ authClient?: OrganizationCapableAuthClient | null; /** When true, treat personal account (null org) as unavailable for switch. */ hidePersonalAccount?: boolean; /** * App-specific invalidation after session sync (tenant tables, billing, …). * Session cache is already handled by the hook — do not re-invalidate * `["auth", "getSession"]` here unless you have a second session key. */ onInvalidate?: () => void | Promise; /** * Optional post-success hook. Use for RSC `router.refresh()` only when * server components read active org outside React Query. Not required for * client session/org UI correctness. */ onSuccess?: (event: OrganizationSwitcherSuccessEvent) => void | Promise; /** Shell overlay / global switch guard. */ onSwitchingChange?: (isSwitching: boolean) => void; /** Forwarded to `useOrganizationList`. */ queryOptions?: { refetchOnMount?: boolean; refetchOnWindowFocus?: boolean; }; } export interface UseOrganizationSwitcherResult { activeOrganization: OrganizationSwitcherEntity | null; activeOrganizationId: string | null; createOrganization: (input: { name: string; slug?: string; }) => Promise; hidePersonalAccount: boolean; isCreatePending: boolean; isListEmpty: boolean; isPending: boolean; isReady: boolean; isSwitching: boolean; listError: unknown; listState: OrganizationListLoadState; localization: { cancel: string; createOrganization: string; name: string; personalAccount: string; title: string; }; options: OrganizationSwitcherOption[]; organizations: OrganizationSwitcherEntity[]; refetchOrganizations: () => Promise; selection: OrganizationSelectionState; switchOrganization: (organizationId: string | null) => Promise; } /** * Headless organization list/switch/create. * * Canonical identity: `athena.auth.session` (SSOT). Switcher selection is * optimistic; session identity stays pessimistic until `setActive` commits. * * TanStack Query session keys are a **derived** mirror for legacy BA hooks — * not the authoritative store. * * Apps do not need `router.refresh()` for client state. Pass `onSuccess` only * when Server Components still read active org from cookies outside TanStack. */ export declare function useOrganizationSwitcher(options?: UseOrganizationSwitcherOptions): UseOrganizationSwitcherResult;