import { useCallback } from "react"; import { agentsApi, type OrgNode } from "../api/agents"; import { useCompany } from "../context/CompanyContext"; import { useApi } from "../hooks/useApi"; import { StatusBadge } from "../components/StatusBadge"; import { Card, CardContent } from "@/components/ui/card"; function OrgTree({ nodes, depth = 0 }: { nodes: OrgNode[]; depth?: number }) { return (
{nodes.map((node) => (

{node.name}

{node.role}

{node.reports.length > 0 && }
))}
); } export function Org() { const { selectedCompanyId } = useCompany(); const fetcher = useCallback(() => { if (!selectedCompanyId) return Promise.resolve([] as OrgNode[]); return agentsApi.org(selectedCompanyId); }, [selectedCompanyId]); const { data, loading, error } = useApi(fetcher); if (!selectedCompanyId) { return

Select a company first.

; } return (

Org Chart

{loading &&

Loading...

} {error &&

{error.message}

} {data && data.length === 0 &&

No agents in org.

} {data && data.length > 0 && }
); }