import neo4j from 'neo4j-driver';
import { useState, useEffect } from 'react';

// Define TypeScript interface for Neo4jGraphData
export interface Neo4jGraphData {
  nodes: Array<{
    id: string;
    labels: string[];
    properties: Record<string, any>;
  }>;
  relationships: Array<{
    id: string;
    type: string;
    startNodeId: string;
    endNodeId: string;
    properties: Record<string, any>;
  }>;
}

// // Move loadNeo4jData outside the component


// const DataLoader = (query: string) => {
//   const [graphData, setGraphData] = useState<Neo4jGraphData>({ nodes: [], relationships: [] });

//   useEffect(() => {
//     const fetchData = async () => {
//       try {
//         const data = await loadNeo4jData(query,
//           process.env.REACT_APP_NEO4J_URI || 'bolt://neo4:7687',
//           process.env.REACT_APP_NEO4J_USERNAME || 'neo4j',
//           process.env.REACT_APP_NEO4J_PASSWORD || 'password'
//         );
//         setGraphData(data);
//       } catch (error) {
//         console.error('Failed to load graph data:', error);
//       }
//     };
//     fetchData();
//   }, []); // Empty dependency array since loadNeo4jData is stable

//   // Render graph data (replace with a proper visualization library in production)
//   return <div>{JSON.stringify(graphData)}</div>;
// };

// export default DataLoader;