"use client" import { useState } from "react" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Check, Copy, Play } from "@luxfi/ui/icons" import { useBrand } from "@/components/brand-provider" const CHAINS = ["Ethereum", "Solana", "Base", "Arbitrum", "Polygon"] const METHODS = [ "eth_getBlockByNumber", "eth_getBalance", "eth_call", "eth_getLogs", ] export function CodeDemo() { const [selectedChain, setSelectedChain] = useState("Ethereum") const [selectedMethod, setSelectedMethod] = useState("eth_getBlockByNumber") const [copied, setCopied] = useState(false) const [response, setResponse] = useState(null) const [loading, setLoading] = useState(false) const brand = useBrand() const code = `curl -X POST ${brand.apiUrl}/v1/rpc/${selectedChain.toLowerCase()}/mainnet \\ -H "Content-Type: application/json" \\ -H "X-API-Key: your_api_key" \\ -d '{ "jsonrpc": "2.0", "method": "${selectedMethod}", "params": [ "latest", false ], "id": 1 }'` const handleCopy = async () => { await navigator.clipboard.writeText(code) setCopied(true) setTimeout(() => setCopied(false), 2000) } const handleRun = async () => { setLoading(true) // Simulate API response await new Promise((resolve) => setTimeout(resolve, 500)) setResponse(JSON.stringify({ jsonrpc: "2.0", id: 1, result: { number: "0x13a40f7", hash: "0x7f5c9...", timestamp: "0x66a4e3c0", transactions: ["0xabc...", "0xdef..."], }, }, null, 2)) setLoading(false) } return (
{/* Controls */}
{CHAINS.map((chain) => ( ))}
{METHODS.map((method) => ( setSelectedMethod(method)} > {method} ))}
{/* Code Block */}
Request
          {code}
        
{/* Response */} {response && (
Response 200 OK
            {response}
          
)}
) }