'use client'; import React, { useState, useCallback } from 'react'; import * as Tabs from '@radix-ui/react-tabs'; import { Search } from 'lucide-react'; import { type Node as FlowNode } from '@xyflow/react'; import { getNodeId } from '@/utils/react-flow'; import { useEventCatalogResourcesStore } from '@/stores/eventcatalog-resources-store'; import { useFlowStoreActions } from '@/stores/flow-store'; import DesignList from './DesignList'; import ResourcesTabContent from './ResourcesTabContent'; import type { CatalogResource, CatalogItemData } from './types'; const CatalogList = () => { const [searchTerm, setSearchTerm] = useState(''); const [hoveredItemId, setHoveredItemId] = useState(null); const { resources, studioFilesFromEventCatalogDirectory } = useEventCatalogResourcesStore(); const { addNode } = useFlowStoreActions(); const onDragStart = useCallback((event: React.DragEvent, nodeType: string, label: string, data: CatalogItemData) => { event.dataTransfer.setData('application/reactflow', JSON.stringify({ nodeType, label, data })); event.dataTransfer.effectAllowed = 'move'; }, []); const handleAddNode = useCallback((nodeType: string, label: string, itemData: CatalogItemData) => { const position = { x: Math.random() * 400, y: Math.random() * 400 }; const newNode: FlowNode = { id: getNodeId(nodeType), type: nodeType, position, data: { ...itemData, label }, }; addNode(newNode); }, [addNode]); const handleItemMouseEnter = useCallback((itemId: string) => { setHoveredItemId(itemId); }, []); const handleItemMouseLeave = useCallback(() => { setHoveredItemId(null); }, []); // Check if we have designs to show tabs const hasDesigns = studioFilesFromEventCatalogDirectory && studioFilesFromEventCatalogDirectory.length > 0; // If no resources and no designs, show empty state if ((!resources || resources.length === 0) && !hasDesigns) { return (

Users can use resources documented from EventCatalog in their diagrams.

Open and run the Studio within your catalog directory and Studio will automatically pull these resources in for your diagrams.

); } // If we have designs, show tabs if (hasDesigns) { return (
setSearchTerm(e.target.value)} value={searchTerm} />
Resources Designs
); } // Fallback: only resources, no tabs return (
setSearchTerm(e.target.value)} value={searchTerm} />
); }; export default CatalogList;