import { useEffect, useState } from "react"; export interface GraphNode { id: string; published: boolean; title: string | null; } export interface GraphEdge { source: string; target: string; } export interface GraphData { nodes: GraphNode[]; edges: GraphEdge[]; } export function useGraph() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { (async () => { try { const res = await fetch("/api/graph"); setData(await res.json()); } finally { setLoading(false); } })(); }, []); return { data, loading }; }