import React, { useRef, useState } from "react"; import { UploadSimple, FileText, FilePdf, Plus } from "@phosphor-icons/react"; import { api } from "./api.js"; import { handleTabListKeyDown, Modal } from "./ui.jsx"; export function ImportDialog({ open, onOpenChange, kind, onImported, notify }) { const [tab, setTab] = useState("upload"), [title, setTitle] = useState(""), [body, setBody] = useState(""), [busy, setBusy] = useState(false), [drag, setDrag] = useState(false); const input = useRef(); const importFile = async (file) => { if (!file) return; setBusy(true); try { const form = new FormData(); form.append("file", file); const material = await api("/import", { method: "POST", body: form }); await onImported(material); onOpenChange(false); notify( material.restored ? `Restored ${material.restored} materials.` : "Imported successfully.", ); } catch (e) { notify(e.message, "error"); } finally { setBusy(false); if (input.current) input.current.value = ""; } }; return ( {kind !== "book" && (
)} {tab === "upload" || kind === "book" ? ( <> importFile(e.target.files[0])} />

Agent lessons use lesson.json,{" "} content.md and an assets/ folder inside a ZIP. Mermaid diagrams, math and cited sources are supported.

) : (
{ e.preventDefault(); setBusy(true); try { const m = await api("/materials", { method: "POST", body: { title, content: body }, }); await onImported(m); onOpenChange(false); setTitle(""); setBody(""); } catch (e) { notify(e.message, "error"); } finally { setBusy(false); } }} >