import { useEffect, useState } from 'react' import type { Card, ClientMessage } from '../types' import { fetchCatalog } from '../api' import { CardView } from './CardView' interface Props { canGrant: boolean // shop phase — grants only land then pack: string // active pack, so the catalog matches the game send: (msg: ClientMessage) => void } // DebugPanel is a testing aid (server DEBUG mode only): a collapsible drawer // listing every card in the active pack, tier by tier. Clicking one drops it // into your deck for free, off-turn. export function DebugPanel({ canGrant, pack, send }: Props) { const [open, setOpen] = useState(false) const [catalog, setCatalog] = useState([]) useEffect(() => { fetchCatalog(pack) .then(setCatalog) .catch(() => setCatalog([])) }, [pack]) const tiers = [...new Set(catalog.map((c) => c.tier ?? 0))].sort((a, b) => a - b) return (
{open && (
Buy any card {!canGrant && · only in the shop}
{tiers.map((tier) => (
Tier {tier}
{catalog .filter((c) => (c.tier ?? 0) === tier) .map((c) => ( send({ type: 'debugAdd', name: c.name }) : undefined} /> ))}
))}
)}
) }