import { useMemo, useRef, useState, } from 'react' import type { OnSelectBlock, ToolWithProvider, } from '../types' import { ToolTypeEnum } from './types' import Tools from './tools' import { useToolTabs } from './hooks' import ViewTypeSelect, { ViewType } from './view-type-select' import cn from '@/utils/classnames' import { useGetLanguage } from '@/context/i18n' import PluginList from '@/app/components/workflow/block-selector/market-place-plugin/list' import { extensionDallE, modelGPT4, toolNotion } from '@/app/components/plugins/card/card-mock' type AllToolsProps = { searchText: string buildInTools: ToolWithProvider[] customTools: ToolWithProvider[] workflowTools: ToolWithProvider[] onSelect: OnSelectBlock } const AllTools = ({ searchText, onSelect, buildInTools, workflowTools, customTools, }: AllToolsProps) => { const language = useGetLanguage() const tabs = useToolTabs() const [activeTab, setActiveTab] = useState(ToolTypeEnum.All) const [activeView, setActiveView] = useState(ViewType.list) const tools = useMemo(() => { let mergedTools: ToolWithProvider[] = [] if (activeTab === ToolTypeEnum.All) mergedTools = [...buildInTools, ...customTools, ...workflowTools] if (activeTab === ToolTypeEnum.BuiltIn) mergedTools = buildInTools if (activeTab === ToolTypeEnum.Custom) mergedTools = customTools if (activeTab === ToolTypeEnum.Workflow) mergedTools = workflowTools return mergedTools.filter((toolWithProvider) => { return toolWithProvider.tools.some((tool) => { return tool.label[language].toLowerCase().includes(searchText.toLowerCase()) }) }) }, [activeTab, buildInTools, customTools, workflowTools, searchText, language]) const pluginRef = useRef(null) const wrapElemRef = useRef(null) return (
{ tabs.map(tab => (
setActiveTab(tab.key)} > {tab.name}
)) }
{/* Plugins from marketplace */}
) } export default AllTools