import { useState } from "react"; import { useNavigate } from "@tanstack/react-router"; import { motion, type Variants } from "framer-motion"; import { Boxes, ChevronRight, Clock } from "lucide-react"; import { useWorkspaces } from "@/api/queries"; import { PageLoader } from "@/components/shared/LoadingSpinner"; import { ErrorAlert } from "@/components/shared/ErrorAlert"; import { Pagination } from "@/components/shared/Pagination"; import { EmptyState } from "@/components/shared/EmptyState"; import type { components } from "@/api/schema.d.ts"; type Workspace = components["schemas"]["Workspace"]; const container: Variants = { hidden: { opacity: 0 }, show: { opacity: 1, transition: { staggerChildren: 0.06 } }, }; const item: Variants = { hidden: { opacity: 0, y: 12 }, show: { opacity: 1, y: 0, transition: { type: "spring", stiffness: 300, damping: 25 } }, }; export function WorkspaceList() { const [page, setPage] = useState(1); const navigate = useNavigate(); const { data, isLoading, error } = useWorkspaces(page); const workspaces: Workspace[] = (data as { items?: Workspace[] } | undefined)?.items ?? []; const totalPages = (data as { pages?: number } | undefined)?.pages ?? 1; const total = (data as { total?: number } | undefined)?.total ?? 0; return (

Workspaces

{total > 0 && ( {total} )}

All workspaces in your Honcho instance

{isLoading && } {!isLoading && workspaces.length === 0 && ( )} {!isLoading && workspaces.length > 0 && ( <> {workspaces.map((ws) => ( navigate({ to: "/workspaces/$workspaceId", params: { workspaceId: ws.id } as never, }) } className="w-full text-left rounded-xl px-5 py-4 group transition-all" style={{ background: "rgba(255,255,255,0.02)", border: "1px solid rgba(255,255,255,0.06)", }} whileHover={{ background: "rgba(99,102,241,0.06)", borderColor: "rgba(99,102,241,0.2)", x: 2, }} >
{ws.id}
{ws.created_at && (

{new Date(ws.created_at).toLocaleString()}

)}
))}
)}
); }