From 576dff4e39a3b45edaecaa5df402e82f1cdfb48a Mon Sep 17 00:00:00 2001 From: ryanwong Date: Fri, 15 Nov 2024 06:00:35 -0500 Subject: [PATCH] add in admin and member automatically generated --- src/components/ConfigPanel.tsx | 421 ++++++++++++++++++-------- src/components/DefaultTablesModal.tsx | 73 ++++- src/components/RouteFlowEditor.tsx | 49 +-- src/components/RouteModal.tsx | 31 +- src/components/RoutesPanel.tsx | 104 ++++--- 5 files changed, 473 insertions(+), 205 deletions(-) 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) {