import { memo, useState, } from 'react' import { useTranslation } from 'react-i18next' import { useNodes } from 'reactflow' import FormItem from '../../nodes/_base/components/before-run-form/form-item' import { BlockEnum } from '../../types' import { useStore, useWorkflowStore, } from '../../store' import type { StartNodeType } from '../../nodes/start/types' import { ChevronDown } from '@/app/components/base/icons/src/vender/line/arrows' const UserInput = () => { const { t } = useTranslation() const workflowStore = useWorkflowStore() const [expanded, setExpanded] = useState(true) const inputs = useStore(s => s.inputs) const nodes = useNodes() const startNode = nodes.find(node => node.data.type === BlockEnum.Start) const variables = startNode?.data.variables || [] const handleValueChange = (variable: string, v: string) => { workflowStore.getState().setInputs({ ...inputs, [variable]: v, }) } if (!variables.length) return null return (
setExpanded(!expanded)} > {t('workflow.panel.userInputField').toLocaleUpperCase()}
{ expanded && (
{ variables.map((variable, index) => (
handleValueChange(variable.variable, v)} />
)) }
) }
) } export default memo(UserInput)