import { useState, useEffect } from 'react' /** * QuestionAugmentationPanel - Fragenergänzungs-Konfiguration * * Props: * - node: React Flow Node object (type='analysis') * - onChange: (nodeId, updates) => void */ export function QuestionAugmentationPanel({ node, onChange }) { const [questions, setQuestions] = useState(node.data.questions || []) // Sync to parent when questions change useEffect(() => { onChange(node.id, { questions }) }, [questions]) const handleAddQuestion = () => { const newQuestion = { id: `q${Date.now()}`, type: 'relevanz', question: '', answer_spectrum: [] } setQuestions([...questions, newQuestion]) } const handleRemoveQuestion = (index) => { setQuestions(questions.filter((_, i) => i !== index)) } const handleQuestionChange = (index, field, value) => { const updated = [...questions] updated[index] = { ...updated[index], [field]: value } setQuestions(updated) } return (

Fragenergänzung

{questions.length === 0 && (
Keine Fragen definiert. Fügen Sie Fragen hinzu, um Signale für Logik-Knoten zu erzeugen.
)} {questions.map((q, idx) => ( handleQuestionChange(idx, field, value)} onRemove={() => handleRemoveQuestion(idx)} /> ))}
) } /** * QuestionEditor - Einzelne Frage editieren */ function QuestionEditor({ question, index, onChange, onRemove }) { const [spectrumInput, setSpectrumInput] = useState('') const handleAddAnswer = () => { if (!spectrumInput.trim()) return const newSpectrum = [...(question.answer_spectrum || []), spectrumInput.trim()] onChange('answer_spectrum', newSpectrum) setSpectrumInput('') } const handleRemoveAnswer = (answer) => { const newSpectrum = question.answer_spectrum.filter(a => a !== answer) onChange('answer_spectrum', newSpectrum) } const handleKeyPress = (e) => { if (e.key === 'Enter') { e.preventDefault() handleAddAnswer() } } return (
Frage {index + 1}
onChange('id', e.target.value)} placeholder="z.B. relevanz" />