"use client"; import { useState } from "react"; import { api } from "@/lib/api"; import { Search, RefreshCw, Bug } from "lucide-react"; export default function NostrToolsPage() { const [fetchInput, setFetchInput] = useState(""); const [fetchResult, setFetchResult] = useState(null); const [fetching, setFetching] = useState(false); const [cacheStatus, setCacheStatus] = useState(""); const [refreshing, setRefreshing] = useState(false); const [debugInput, setDebugInput] = useState(""); const [debugResult, setDebugResult] = useState(null); const [debugging, setDebugging] = useState(false); const [error, setError] = useState(""); const handleFetch = async () => { if (!fetchInput.trim()) return; setFetching(true); setError(""); setFetchResult(null); try { const isNaddr = fetchInput.startsWith("naddr"); const data = await api.fetchNostrEvent( isNaddr ? { naddr: fetchInput } : { eventId: fetchInput } ); setFetchResult(data); } catch (err: any) { setError(err.message); } finally { setFetching(false); } }; const handleRefreshCache = async () => { setRefreshing(true); setCacheStatus(""); setError(""); try { const result = await api.refreshCache(); setCacheStatus(result.message || "Cache refreshed successfully."); } catch (err: any) { setError(err.message); } finally { setRefreshing(false); } }; const handleDebug = async () => { if (!debugInput.trim()) return; setDebugging(true); setError(""); setDebugResult(null); try { const data = await api.debugEvent(debugInput); setDebugResult(data); } catch (err: any) { setError(err.message); } finally { setDebugging(false); } }; return (

Nostr Tools

{error &&

{error}

}

Manual Fetch

setFetchInput(e.target.value)} className="bg-surface-container-highest text-on-surface rounded-lg px-4 py-3 w-full focus:outline-none focus:ring-1 focus:ring-primary/40 flex-1" />
{fetchResult && (
            {JSON.stringify(fetchResult, null, 2)}
          
)}

Cache Management

{cacheStatus && (

{cacheStatus}

)}

Debug Event

setDebugInput(e.target.value)} className="bg-surface-container-highest text-on-surface rounded-lg px-4 py-3 w-full focus:outline-none focus:ring-1 focus:ring-primary/40 flex-1" />
{debugResult && (
            {JSON.stringify(debugResult, null, 2)}
          
)}
); }