import type { FC } from 'react' import React from 'react' import type { NodeProps } from 'reactflow' import { useTranslation } from 'react-i18next' import { NodeTargetHandle } from '../_base/components/node-handle' import { BlockEnum } from '../../types' import type { VariableAssignerNodeType } from './types' import { VarBlockIcon } from '@/app/components/workflow/block-icon' import { Line3 } from '@/app/components/base/icons/src/public/common' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { useWorkflow, } from '@/app/components/workflow/hooks' const i18nPrefix = 'workflow.nodes.variableAssigner' const Node: FC> = (props) => { const { t } = useTranslation() const { id, data } = props const { variables: originVariables, output_type } = data const { getTreeLeafNodes } = useWorkflow() const availableNodes = getTreeLeafNodes(id) const variables = originVariables.filter(item => item.length > 0) return (
{t(`${i18nPrefix}.title`)}
{ variables.length === 0 && (
{t(`${i18nPrefix}.varNotSet`)}
) } {variables.length > 0 && ( <>
{variables.map((item, index) => { const node = availableNodes.find(node => node.id === item[0]) const varName = item[item.length - 1] return (
{node?.data.title}
{varName}
{/*
{output_type}
*/}
) }, )}
{t(`${i18nPrefix}.outputType`)}
{t(`${i18nPrefix}.type.${output_type}`)}
) }
) } export default React.memo(Node)