diff --git a/src/components/ConfigPanel.tsx b/src/components/ConfigPanel.tsx index 7ce1766..6d993b3 100644 --- a/src/components/ConfigPanel.tsx +++ b/src/components/ConfigPanel.tsx @@ -1,7 +1,7 @@ -import React, { useState } from 'react'; -import { X, Plus, Trash } from 'lucide-react'; -import { Node } from 'reactflow'; -import { useFlowStore } from '../store/flowStore'; +import React, { useState } from "react"; +import { X, Plus, Trash } from "lucide-react"; +import { Node } from "reactflow"; +import { useFlowStore } from "../store/flowStore"; interface ConfigPanelProps { node: Node | null; @@ -17,18 +17,27 @@ interface Field { export function ConfigPanel({ node, onClose, onUpdateNode }: ConfigPanelProps) { const { models } = useFlowStore(); - const [newField, setNewField] = useState({ name: '', type: 'string' }); + const [newField, setNewField] = useState({ name: "", type: "string" }); if (!node) return null; - const handleChange = (e: React.ChangeEvent) => { + const handleChange = ( + e: React.ChangeEvent< + HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement + > + ) => { onUpdateNode(node.id, { ...node.data, [e.target.name]: e.target.value, }); }; - const handleArrayChange = (index: number, field: string, value: string, arrayName: string) => { + const handleArrayChange = ( + index: number, + field: string, + value: string, + arrayName: string + ) => { const array = [...(node.data[arrayName] || [])]; array[index] = { ...array[index], [field]: value }; onUpdateNode(node.id, { @@ -43,7 +52,7 @@ export function ConfigPanel({ node, onClose, onUpdateNode }: ConfigPanelProps) { ...node.data, [arrayName]: array, }); - setNewField({ name: '', type: 'string' }); + setNewField({ name: "", type: "string" }); }; const removeField = (index: number, arrayName: string) => { @@ -55,19 +64,35 @@ export function ConfigPanel({ node, onClose, onUpdateNode }: ConfigPanelProps) { }); }; + const copyQueryFields = () => { + const currentFields = node.data.fields || []; + navigator.clipboard.writeText(JSON.stringify(currentFields, null, 2)); + }; + + const extractQueryParams = (path: string) => { + const params = path.match(/:[a-zA-Z]+/g) || []; + return params.map((param) => ({ + name: param.substring(1), + type: "string", + validation: "", + })); + }; + const renderDatabaseFields = () => ( <>
@@ -75,7 +100,7 @@ export function ConfigPanel({ node, onClose, onUpdateNode }: ConfigPanelProps) {