MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / handleCreateFile

Function handleCreateFile

src/components/FileBrowser.tsx:399–416  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

397
398 // Create file
399 const handleCreateFile = async () => {
400 if (!newFileName.trim()) return;
401 const filePath = path ? `${path}/${newFileName.trim()}` : newFileName.trim();
402 try {
403 await fetch("/api/files/write", {
404 method: "POST",
405 headers: { "Content-Type": "application/json" },
406 body: JSON.stringify({ workspace, path: filePath, content: "" }),
407 });
408 setNewFileName("");
409 setShowNewFile(false);
410 loadItems();
411 // Open editor immediately
412 setEditorFile({ workspace, path: filePath, name: newFileName.trim() });
413 } catch {
414 alert("Failed to create file");
415 }
416 };
417
418 // Drag and drop
419 const handleDragOver = (e: React.DragEvent) => { e.preventDefault(); setDragging(true); };

Callers 1

FileBrowserFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected