()
| 55 | }, []); |
| 56 | |
| 57 | const handleAdd = async () => { |
| 58 | if (!newName.trim()) { |
| 59 | toast.error("Command name is required"); |
| 60 | return; |
| 61 | } |
| 62 | if (!newTemplate.trim()) { |
| 63 | toast.error("Template is required"); |
| 64 | return; |
| 65 | } |
| 66 | if (commands.some(c => c.name === newName.trim())) { |
| 67 | toast.error("Command already exists"); |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | try { |
| 72 | await saveCommand(newName.trim(), newTemplate); |
| 73 | toast.success(`Command "${newName}" created`); |
| 74 | setNewName(""); |
| 75 | setNewTemplate(""); |
| 76 | setAddOpen(false); |
| 77 | fetchCommands(); |
| 78 | } catch { |
| 79 | toast.error("Failed to create command"); |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | |
| 84 |
nothing calls this directly
no test coverage detected