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 (
All workspaces in your Honcho instance
{new Date(ws.created_at).toLocaleString()}