import React, { useState } from 'react'; import { Handle, Position } from 'reactflow'; import api from './api'; // Import the centralized api import './CustomNode.css'; // A dedicated component for the slider to manage its own state const SliderInput = ({ id, label, props }) => { const [value, setValue] = useState(props.value || props.minimum); return (
setValue(e.target.value)} />
); }; // This component renders a single input row, including a target handle if applicable const InputRow = ({ node_id, input, isConnected, isConnectable }) => { const { type, label, props = {} } = input; const controlId = `node-${node_id}-input-${input.id}`; const isPrimary = ['textbox', 'image', 'audio', 'video', 'file'].includes(type); const [uploadStatus, setUploadStatus] = useState('idle'); const [filePath, setFilePath] = useState(''); const handleFileChange = async (event) => { const file = event.target.files[0]; if (!file) return; const formData = new FormData(); formData.append('file', file); setUploadStatus('uploading'); try { const response = await api.post('/upload/', formData, { headers: { 'Content-Type': 'multipart/form-data', }, }); setFilePath(response.data.path); setUploadStatus('success'); } catch (error) { console.error('File upload failed:', error); setUploadStatus('error'); } }; if (isConnected) { return (
{isPrimary && } Connected via edge
); } const renderControl = () => { switch (type) { case 'textbox': return