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