import type { Metadata } from "next"; import Link from "next/link"; import { InstrumentTable } from "@/components/market/instrument-table"; import { Empty, Page, PageHeader, Section } from "@/components/ui/section"; import { StatusBadge } from "@/components/ui/status-badge"; import { api } from "@/lib/api"; import { ASSET_CLASS_LABEL } from "@/lib/format"; import type { InstrumentWithQuote, SearchResult } from "@/lib/types"; export const metadata: Metadata = { title: "Search", robots: { index: false } }; export const dynamic = "force-dynamic"; export default async function SearchPage({ searchParams }: { searchParams: Promise> }) { const sp = await searchParams; const q = typeof sp.q === "string" ? sp.q.trim() : ""; const res = q ? await api(`/v1/search?q=${encodeURIComponent(q)}&limit=50`) : null; const groups = res?.groups ?? {}; const instrumentGroups = Object.entries(groups).filter(([g]) => g !== "EXCHANGE" && g !== "COUNTRY"); return (
{q && !res?.results.length && No results for “{q}”.} {(groups.EXCHANGE as Array> | undefined)?.length ? (
    {(groups.EXCHANGE as Array>).map((e) => (
  • {e.name}
    {e.mic ?? ""} · {e.country}
  • ))}
) : null} {(groups.COUNTRY as Array> | undefined)?.length ? (
    {(groups.COUNTRY as Array>).map((c) => (
  • {c.name} {c.code}
  • ))}
) : null} {instrumentGroups.map(([g, items]) => (
))}
); }