File size: 1,940 Bytes
1dd9186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { memo } from 'react';
import NodeShell from '../components/NodeShell.jsx';
import { NodeDraftTextarea } from '../components/NodeDraftField.jsx';
import { useWorkflow } from '../context/WorkflowContext.jsx';
import { getNodeAccent } from '../lib/nodeRegistry.js';

function QuestionFlowNode({ id, data, selected, type }) {
  const { getNodeHandles, patchNodeData } = useWorkflow();
  const handles = getNodeHandles(type, data);
  const runtime = data.runtime || {};

  return (
    <NodeShell
      nodeId={id}
      title={data.title}
      accent={getNodeAccent(type)}
      selected={selected}
      status={runtime.status}
      inputs={handles.inputs}
      outputs={handles.outputs}
    >
      <div className="field-stack">
        <NodeDraftTextarea
          className="nodrag nowheel node-textarea node-textarea--inline is-editing"
          value={data.question || ''}
          placeholder="Текст вопроса..."
          style={{ minHeight: '96px' }}
          onCommit={(value) => patchNodeData(id, { question: value })}
        />

        <label className="field-row">
          <input
            className="nodrag"
            type="checkbox"
            checked={Boolean(data.paraphrase)}
            onChange={(event) => patchNodeData(id, { paraphrase: event.target.checked })}
          />
          <span>Перефразировать при запуске</span>
        </label>

        <div className="node-note">
          {runtime.answer
            ? `Ответ: ${runtime.answer}`
            : runtime.question
              ? `Ожидает: ${runtime.question}`
              : 'Интерактивный прогон останавливается здесь и ждет ответ пользователя.'}
        </div>

        {runtime.error ? <div className="node-error">{runtime.error}</div> : null}
      </div>
    </NodeShell>
  );
}

export default memo(QuestionFlowNode);