import { Link } from "react-router-dom" import { Globe, Share2 } from "lucide-react" import { KIND_ICONS } from "@/lib/labels" import { useGateway, useJobs, useMeshStatus, useNodes, usePrograms, useServices, useStatus, } from "@/services/api/hooks" import { NodeBar } from "@/components/NodeBar" import { PageHeader } from "@/components/PageHeader" import { ConvergePanel } from "@/components/ConvergePanel" export function Overview() { const { data: services } = useServices() const { data: jobs } = useJobs() const { data: tools } = usePrograms("tool") const { data: programs } = usePrograms() const { data: statusResp } = useStatus() const { data: gateway } = useGateway() const { data: mesh } = useMeshStatus() const { data: nodes } = useNodes() const statuses = statusResp?.statuses ?? [] const upCount = (ids: string[]) => statuses.filter((s) => ids.includes(s.id) && s.status === "up").length const serviceIds = (services ?? []).map((s) => s.id) const routeCount = gateway?.routes?.length ?? 0 const tiles = [ { to: "/services", icon: KIND_ICONS.service, label: "Services", value: services?.length ?? 0, detail: services ? `${upCount(serviceIds)} up` : "", }, { to: "/scheduled", icon: KIND_ICONS.job, label: "Scheduled", value: jobs?.length ?? 0, detail: jobs ? `${jobs.length === 1 ? "job" : "jobs"}` : "", }, { to: "/tools", icon: KIND_ICONS.tool, label: "Tools", value: tools?.length ?? 0, detail: tools ? "on PATH" : "", }, { to: "/programs", icon: KIND_ICONS.program, label: "Programs", value: programs?.length ?? 0, detail: programs ? "in catalog" : "", }, { to: "/gateway", icon: Globe, label: "Gateway", value: routeCount, detail: gateway ? `tls: ${gateway.tls ?? "off"}` : "", }, { to: "/mesh", icon: Share2, label: "Mesh", value: mesh?.enabled ? mesh.peer_count : "—", detail: mesh?.enabled ? "peers" : "disabled", }, ] return (