diff --git a/src/client/components/CatalogSearchOverlay.tsx b/src/client/components/CatalogSearchOverlay.tsx index 33141f0..aed2236 100644 --- a/src/client/components/CatalogSearchOverlay.tsx +++ b/src/client/components/CatalogSearchOverlay.tsx @@ -97,8 +97,16 @@ export function CatalogSearchOverlay() { setSelectedTags((prev) => prev.filter((t) => t !== tagName)); } - function handleAddStub() { - // Stub: actual add-to-collection / add-to-thread wired in Phase 21 + const openAddToCollection = useUIStore((s) => s.openAddToCollection); + const openAddToThread = useUIStore((s) => s.openAddToThread); + + function handleAdd(item: { id: number; brand: string; model: string }) { + const itemName = `${item.brand} ${item.model}`; + if (catalogSearchMode === "collection") { + openAddToCollection(item.id, itemName); + } else if (catalogSearchMode === "thread") { + openAddToThread(item.id, itemName); + } } const contextText = @@ -398,7 +406,7 @@ export function CatalogSearchOverlay() { handleAdd(item)} weight={weight} price={price} /> @@ -410,7 +418,7 @@ export function CatalogSearchOverlay() { handleAdd(item)} weight={weight} price={price} /> diff --git a/src/client/routes/global-items/$globalItemId.tsx b/src/client/routes/global-items/$globalItemId.tsx index c6a227a..41a09c7 100644 --- a/src/client/routes/global-items/$globalItemId.tsx +++ b/src/client/routes/global-items/$globalItemId.tsx @@ -1,6 +1,7 @@ import { createFileRoute, Link } from "@tanstack/react-router"; import { useFormatters } from "../../hooks/useFormatters"; import { useGlobalItem } from "../../hooks/useGlobalItems"; +import { useUIStore } from "../../stores/uiStore"; export const Route = createFileRoute("/global-items/$globalItemId")({ component: GlobalItemDetail, @@ -10,6 +11,8 @@ function GlobalItemDetail() { const { globalItemId } = Route.useParams(); const { data: item, isLoading, error } = useGlobalItem(Number(globalItemId)); const { weight, price } = useFormatters(); + const openAddToCollection = useUIStore((s) => s.openAddToCollection); + const openAddToThread = useUIStore((s) => s.openAddToThread); if (isLoading) { return ( @@ -126,15 +129,22 @@ function GlobalItemDetail() { )} - {/* Add to Collection */} -
+ {/* Action buttons */} +
+
{/* Description */}