'use client'; import { useState } from 'react'; import { Play, Terminal, Copy, Check } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; import api from '@/lib/axios'; interface CypherResult { cypher: string; explanation: string; records: Record[]; success: boolean; error?: string; } export function CypherEditor() { const [query, setQuery] = useState(''); const [result, setResult] = useState(null); const [loading, setLoading] = useState(false); const [copied, setCopied] = useState(false); async function runQuery() { if (!query.trim()) return; setLoading(true); try { const { data } = await api.post('/graph/cypher/', { query }); setResult(data); } catch (err: any) { setResult({ cypher: query, explanation: '', records: [], success: false, error: err.response?.data?.error || 'Failed to execute query.', }); } finally { setLoading(false); } } function copyCypher() { if (result?.cypher) { navigator.clipboard.writeText(result.cypher); setCopied(true); setTimeout(() => setCopied(false), 2000); } } return (
Cypher Query Editor