import { type Catalog, words } from "../catalog"; import { EXPORT } from "../export/Export"; import { IMPORT } from "../import/Import"; import { useWaiting } from "../import/runner"; import { rkey } from "../oauth/repo"; import { Link } from "../router"; import type { Holdings } from "./cards"; import { type Containers, UNFILED } from "./containers"; import { Place } from "./Place"; const UNDER = "/collection/"; // What you own and where it sits, and one level down, what one place holds. export function Collection({ catalog, containers, owning, path, }: { catalog: Catalog | null; containers: Containers; owning: Holdings; path: string; }) { const key = path.startsWith(UNDER) ? path.slice(UNDER.length) : ""; // The total takes `waiting` in too, because those copies are owned. What // they are not is editable, so it says so. const left = useWaiting().reduce((sum, one) => sum + one.quantity, 0); if (key) { const here = containers.held.find((one) => rkey(one.uri) === key); // An unknown key is a container this account no longer has, which reads // as an empty place rather than an error. return ( ); } const unfiled = owning.copies(null); const empty = owning.total === 0 && containers.held.length === 0; return ( <>

{owning.total.toLocaleString()} card{owning.total === 1 ? "" : "s"} {left > 0 && ( {" "} · {left.toLocaleString()} still landing )}

Import a CSV {owning.total > 0 && ( <> {" · "} Export one )}

{empty ? (

Nothing yet. Search for a card and press the plus beside a printing.

) : ( )} ); }