import { useState } from "react"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { useToast } from "@/hooks/use-toast"; import { ClipboardPaste } from "lucide-react"; import { Node, Edge } from "reactflow"; import { NodeData } from "./node-editor"; interface ImportWorkflowDialogProps { open: boolean; onOpenChange: (open: boolean) => void; onImport: (nodes: Node[], edges: Edge[]) => void; } export function ImportWorkflowDialog({ open, onOpenChange, onImport }: ImportWorkflowDialogProps) { const [json, setJson] = useState(""); const { toast } = useToast(); const handleImport = () => { try { const data = JSON.parse(json); if (!data.nodes || !Array.isArray(data.nodes) || !data.edges || !Array.isArray(data.edges)) { throw new Error("Invalid workflow JSON format"); } onImport(data.nodes, data.edges); setJson(""); onOpenChange(false); toast({ title: "Success", description: "Workflow imported successfully", }); } catch { toast({ title: "Error", description: "Failed to parse JSON. Please check the format.", variant: "destructive", }); } }; return ( Import Workflow JSON Paste the workflow JSON below to import it. This will replace the current workflow.