import * as React from "react"; import { Link } from "react-router-dom"; import { Loader2, Plus, Trash2 } from "lucide-react"; import { useCreateProject, useDeleteProject, useProjects } from "@/lib/api"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; function CreateProjectDialog() { const create = useCreateProject(); const [open, setOpen] = React.useState(false); const [name, setName] = React.useState(""); const [slug, setSlug] = React.useState(""); const submit = async () => { if (!name.trim()) return; await create.mutateAsync({ name: name.trim(), slug: slug.trim() || undefined, }); setName(""); setSlug(""); setOpen(false); }; return ( Create a project A project holds a tree of KiCad files you can open in the browser.
setName(e.target.value)} />
setSlug(e.target.value)} />
{create.error && (

{(create.error as Error).message}

)}
); } export function ProjectsPage() { const { data: projects, isLoading, error } = useProjects(); const del = useDeleteProject(); return (

Projects

Create a project, upload KiCad files, open them in the browser.

{isLoading && (

loading…

)} {error && (

Could not load projects: {(error as Error).message}

)}
{projects?.map((p) => ( {p.name} /p/{p.slug} ))}
{projects && projects.length === 0 && !isLoading && (

No projects yet. Create one above.

)}
); }