"use client"; import { Modal } from "../ui/Modal"; import { Button } from "../ui/Button"; import { Input } from "../ui/Input"; import { BashEditor } from "../BashEditor"; import { BashSnippetHelper } from "../BashSnippetHelper"; import { Plus } from "lucide-react"; import { showToast } from "../ui/Toast"; interface CreateScriptModalProps { isOpen: boolean; onClose: () => void; onSubmit: ( formData: FormData ) => Promise<{ success: boolean; message: string }>; form: { name: string; description: string; content: string; }; onFormChange: (updates: Partial) => void; } export function CreateScriptModal({ isOpen, onClose, onSubmit, form, onFormChange, }: CreateScriptModalProps) { const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); const formData = new FormData(); formData.append("name", form.name); formData.append("description", form.description); formData.append("content", form.content); const result = await onSubmit(formData); if (result.success) { onClose(); } else { showToast("error", "Failed to create script", result.message); } }; const handleInsertSnippet = (snippet: string) => { onFormChange({ content: snippet }); }; return (
onFormChange({ name: e.target.value })} placeholder="My Script" required />
onFormChange({ description: e.target.value })} placeholder="What does this script do?" />
onFormChange({ content: value })} placeholder="#!/bin/bash # Your script here echo 'Hello World'" />
); }