'use client' import { useMemo, useState } from 'react' import NewMCPCard from './create-card' import MCPCard from './provider-card' import { useAllMCPTools, useInvalidateAllMCPTools } from '@/service/use-tools' import type { MCPProvider } from '@/app/components/tools/types' import cn from '@/utils/classnames' type Props = { searchText: string } const MCPList = ({ searchText, }: Props) => { const { data: list = [] } = useAllMCPTools() const invalidateMCPList = useInvalidateAllMCPTools() const filteredList = useMemo(() => { return list.filter((collection) => { if (searchText) return Object.values(collection.name).some(value => (value as string).toLowerCase().includes(searchText.toLowerCase())) return true }) }, [list, searchText]) const [currentProvider, setCurrentProvider] = useState() function renderDefaultCard() { const defaultCards = Array.from({ length: 36 }, (_, index) => (
= 4 && index < 8 && 'opacity-50', index >= 8 && index < 12 && 'opacity-40', index >= 12 && index < 16 && 'opacity-30', index >= 16 && index < 20 && 'opacity-25', index >= 20 && index < 24 && 'opacity-20', )} >
)) return defaultCards } return ( <>
{filteredList.map(provider => ( ))} {!list.length && renderDefaultCard()}
) } export default MCPList