import { memo, useCallback, } from 'react' import { RiAddLine, } from '@remixicon/react' import { useTranslation } from 'react-i18next' import { useAvailableBlocks, useNodesInteractions, useNodesReadOnly, } from '../../hooks' import type { IterationNodeType } from './types' import cn from '@/utils/classnames' import BlockSelector from '@/app/components/workflow/block-selector' import type { OnSelectBlock, } from '@/app/components/workflow/types' import { BlockEnum, } from '@/app/components/workflow/types' type AddBlockProps = { iterationNodeId: string iterationNodeData: IterationNodeType } const AddBlock = ({ iterationNodeData, }: AddBlockProps) => { const { t } = useTranslation() const { nodesReadOnly } = useNodesReadOnly() const { handleNodeAdd } = useNodesInteractions() const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, true) const handleSelect = useCallback((type, toolDefaultValue) => { handleNodeAdd( { nodeType: type, toolDefaultValue, }, { prevNodeId: iterationNodeData.start_node_id, prevNodeSourceHandle: 'source', }, ) }, [handleNodeAdd, iterationNodeData.start_node_id]) const renderTriggerElement = useCallback((open: boolean) => { return (
{t('workflow.common.addBlock')}
) }, [nodesReadOnly, t]) return (
) } export default memo(AddBlock)