import { Navigate, createFileRoute } from "@tanstack/react-router"; import { useQuery } from "@tanstack/react-query"; import { GithubLogoIcon, KanbanIcon, SlackLogoIcon } from "@phosphor-icons/react"; import type { ComponentType } from "react"; import type { ReposPayload } from "@/lib/api"; import { AppShell, SettingsSection } from "@/components/AppShell"; import { Skeleton } from "@/components/ui/skeleton"; import { ApiError, api } from "@/lib/api"; import { useSession } from "@/lib/session"; import { cn } from "@/lib/utils"; export const Route = createFileRoute("/integrations")({ component: IntegrationsPage }); type IconType = ComponentType<{ className?: string; weight?: "regular" | "fill" | "duotone" }>; interface IntegrationRowProps { icon: IconType; name: string; description: string; connected: boolean; badge?: string; } function IntegrationRow({ icon: Icon, name, description, connected, badge }: IntegrationRowProps) { return (
{name} {badge && ( {badge} )}

{description}

{connected ? "Connected" : "Not connected"}
); } function IntegrationsPage() { const session = useSession(); const repos = useQuery({ queryKey: ["repos"], queryFn: async () => { try { return await api.repos(); } catch (e) { if (e instanceof ApiError && e.status === 401) return { installations: [], repositories: [] }; throw e; } }, enabled: !!session.data, }); if (session.isLoading) { return (
); } if (!session.data) return ; const installs = repos.data?.installations ?? []; const githubDescription = installs.length ? `Connected to ${installs.length} ${installs.length === 1 ? "installation" : "installations"}: ${installs .map((i) => i.account ?? "?") .join(", ")}` : "Install the open-swe GitHub App to enable PR and issue triggers."; return ( 0} /> ); }