import { useState } from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { Link } from 'react-router-dom'; import { apiFetch } from '../lib/api'; import ImportDialog from './ImportDialog'; type ProjectSummary = { id: string; name: string; description: string | null; openApiVersion: string; updatedAt: string; _count: { endpoints: number; modules: number }; }; export default function Projects() { const [showImport, setShowImport] = useState(false); const queryClient = useQueryClient(); const { data: projects, isLoading } = useQuery({ queryKey: ['projects'], queryFn: () => apiFetch('/projects'), }); const deleteMutation = useMutation({ mutationFn: (id: string) => apiFetch(`/projects/${id}`, { method: 'DELETE' }), onSuccess: () => queryClient.invalidateQueries({ queryKey: ['projects'] }), }); if (isLoading) return
Loading projects...
; return (

Projects

{projects?.length === 0 &&

No projects yet. Import an OpenAPI document to get started.

}
{projects?.map((p) => (

{p.name}

{p.description &&

{p.description}

}
OpenAPI {p.openApiVersion} {p._count.modules} modules {p._count.endpoints} endpoints
))}
{showImport && setShowImport(false)} />}
); }