Update src/App.tsx
Browse files- src/App.tsx +35 -19
src/App.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import React, { useCallback, useState } from 'react';
|
| 2 |
import ReactFlow, { Controls, useNodesState, useEdgesState, addEdge, Node, Edge } from 'reactflow';
|
| 3 |
import { FiFile } from 'react-icons/fi';
|
| 4 |
|
|
@@ -7,6 +7,7 @@ import './index.css';
|
|
| 7 |
import TurboNode, { TurboNodeData } from './TurboNode';
|
| 8 |
import TurboEdge from './TurboEdge';
|
| 9 |
import FunctionIcon from './FunctionIcon';
|
|
|
|
| 10 |
|
| 11 |
const initialNodes: Node<TurboNodeData>[] = [
|
| 12 |
{
|
|
@@ -146,10 +147,35 @@ const App = () => {
|
|
| 146 |
}
|
| 147 |
};
|
| 148 |
|
| 149 |
-
const handleInputChange = (event) => {
|
| 150 |
setInputData(event.target.value);
|
| 151 |
};
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
return (
|
| 154 |
<div className="flow-container">
|
| 155 |
<ReactFlow
|
|
@@ -186,23 +212,13 @@ const App = () => {
|
|
| 186 |
</defs>
|
| 187 |
</svg>
|
| 188 |
</ReactFlow>
|
| 189 |
-
<
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
onChange={(e) => setRecursiveSteps(parseInt(e.target.value))}
|
| 197 |
-
/>
|
| 198 |
-
<button onClick={addRecursiveStep}>+</button>
|
| 199 |
-
<button onClick={removeRecursiveStep}>-</button>
|
| 200 |
-
</div>
|
| 201 |
-
<div>
|
| 202 |
-
<label>Input Data:</label>
|
| 203 |
-
<textarea value={inputData} onChange={handleInputChange} />
|
| 204 |
-
</div>
|
| 205 |
-
</div>
|
| 206 |
</div>
|
| 207 |
);
|
| 208 |
};
|
|
|
|
| 1 |
+
import React, { useCallback, useEffect, useState } from 'react';
|
| 2 |
import ReactFlow, { Controls, useNodesState, useEdgesState, addEdge, Node, Edge } from 'reactflow';
|
| 3 |
import { FiFile } from 'react-icons/fi';
|
| 4 |
|
|
|
|
| 7 |
import TurboNode, { TurboNodeData } from './TurboNode';
|
| 8 |
import TurboEdge from './TurboEdge';
|
| 9 |
import FunctionIcon from './FunctionIcon';
|
| 10 |
+
import Sidebar from './Sidebar';
|
| 11 |
|
| 12 |
const initialNodes: Node<TurboNodeData>[] = [
|
| 13 |
{
|
|
|
|
| 147 |
}
|
| 148 |
};
|
| 149 |
|
| 150 |
+
const handleInputChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
| 151 |
setInputData(event.target.value);
|
| 152 |
};
|
| 153 |
|
| 154 |
+
useEffect(() => {
|
| 155 |
+
// Update nodes based on recursive steps and input data
|
| 156 |
+
// You can modify the nodes array or create new nodes dynamically
|
| 157 |
+
// based on the recursiveSteps and inputData values
|
| 158 |
+
// For example:
|
| 159 |
+
// const newNodes = [...nodes];
|
| 160 |
+
// for (let i = 0; i < recursiveSteps; i++) {
|
| 161 |
+
// newNodes.push({
|
| 162 |
+
// id: `recursive-${i}`,
|
| 163 |
+
// position: { x: 100 * i, y: 200 },
|
| 164 |
+
// data: {
|
| 165 |
+
// icon: <FunctionIcon />,
|
| 166 |
+
// title: `Recursive Step ${i + 1}`,
|
| 167 |
+
// subline: 'Recursive prompt',
|
| 168 |
+
// inputFields: [
|
| 169 |
+
// { id: `recursive-input-${i}`, label: `Input ${i + 1}`, value: '' },
|
| 170 |
+
// ],
|
| 171 |
+
// options: [],
|
| 172 |
+
// },
|
| 173 |
+
// type: 'turbo',
|
| 174 |
+
// });
|
| 175 |
+
// }
|
| 176 |
+
// setNodes(newNodes);
|
| 177 |
+
}, [recursiveSteps, inputData]);
|
| 178 |
+
|
| 179 |
return (
|
| 180 |
<div className="flow-container">
|
| 181 |
<ReactFlow
|
|
|
|
| 212 |
</defs>
|
| 213 |
</svg>
|
| 214 |
</ReactFlow>
|
| 215 |
+
<Sidebar
|
| 216 |
+
recursiveSteps={recursiveSteps}
|
| 217 |
+
addRecursiveStep={addRecursiveStep}
|
| 218 |
+
removeRecursiveStep={removeRecursiveStep}
|
| 219 |
+
inputData={inputData}
|
| 220 |
+
handleInputChange={handleInputChange}
|
| 221 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
</div>
|
| 223 |
);
|
| 224 |
};
|