"use client"; import { useRouter } from "next/navigation"; import { useState, type FormEvent } from "react"; import { SearchIcon } from "@/components/icons/search"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { searchExplorer } from "@/lib/explorer-mock"; export function ExplorerSearch() { const router = useRouter(); const [q, setQ] = useState(""); const [error, setError] = useState(null); function onSubmit(e: FormEvent) { e.preventDefault(); const hit = searchExplorer(q); if (hit.kind === "tx") { setError(null); router.push(`/portal/explorer/tx/${encodeURIComponent(hit.id)}`); return; } if (hit.kind === "block") { setError(null); router.push(`/portal/explorer/block/${encodeURIComponent(hit.id)}`); return; } setError( "No mock match. Try a full or partial tx hash, a block height (e.g. 1284901), or an address from the lists.", ); } return (
{ setQ(e.target.value); if (error) setError(null); }} placeholder="Search by tx hash, block height, or address…" className="h-11 pl-9 font-mono text-sm" aria-label="Search explorer" autoComplete="off" />
{error ? (

{error}

) : (

Mock data only — try height{" "} {" "} or paste a hash from the tables below.

)}
); }