"use client"; import { useState, useEffect } from "react"; import { api } from "@/lib/api"; interface WorkspaceOption { id: string; name: string; tier: number; } export function CreateWorkspaceButton() { const [open, setOpen] = useState(false); return ( <> {open && setOpen(false)} />} ); } function CreateDialog({ onClose }: { onClose: () => void }) { const [name, setName] = useState(""); const [role, setRole] = useState(""); const [tier, setTier] = useState(1); const [template, setTemplate] = useState(""); const [parentId, setParentId] = useState(""); const [creating, setCreating] = useState(false); const [error, setError] = useState(null); const [workspaces, setWorkspaces] = useState([]); useEffect(() => { api.get("/workspaces") .then((ws) => setWorkspaces(ws)) .catch(() => {}); }, []); const handleCreate = async () => { if (!name.trim()) { setError("Name is required"); return; } setCreating(true); setError(null); try { await api.post("/workspaces", { name: name.trim(), role: role.trim() || undefined, template: template.trim() || undefined, tier, parent_id: parentId || undefined, canvas: { x: Math.random() * 400 + 100, y: Math.random() * 300 + 100 }, }); onClose(); } catch (e) { setError(e instanceof Error ? e.message : "Failed to create workspace"); } finally { setCreating(false); } }; return (

Create Workspace

Add a new workspace node to the canvas

{[ { value: 1, label: "T1", desc: "Sandboxed" }, { value: 2, label: "T2", desc: "Standard" }, { value: 3, label: "T3", desc: "Full Access" }, ].map((t) => ( ))}
{error && (
{error}
)}
); } function InputField({ label, value, onChange, placeholder, required, autoFocus, mono, }: { label: string; value: string; onChange: (v: string) => void; placeholder?: string; required?: boolean; autoFocus?: boolean; mono?: boolean; }) { return (
onChange(e.target.value)} placeholder={placeholder} autoFocus={autoFocus} className={`w-full bg-zinc-800/60 border border-zinc-700/50 rounded-lg px-3 py-2 text-sm text-zinc-100 placeholder-zinc-600 focus:outline-none focus:border-blue-500/60 focus:ring-1 focus:ring-blue-500/20 transition-colors ${mono ? "font-mono text-xs" : ""}`} />
); }