feat(22-01): wire catalog search and detail page to collection/thread modals
- Replace handleAddStub with handleAdd dispatching to correct modal by mode - Global item detail page: add both "Add to Collection" and "Add to Thread" buttons - Remove console.log stub from detail page - Import useUIStore in both components Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -97,8 +97,16 @@ export function CatalogSearchOverlay() {
|
|||||||
setSelectedTags((prev) => prev.filter((t) => t !== tagName));
|
setSelectedTags((prev) => prev.filter((t) => t !== tagName));
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAddStub() {
|
const openAddToCollection = useUIStore((s) => s.openAddToCollection);
|
||||||
// Stub: actual add-to-collection / add-to-thread wired in Phase 21
|
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 =
|
const contextText =
|
||||||
@@ -398,7 +406,7 @@ export function CatalogSearchOverlay() {
|
|||||||
<GridCard
|
<GridCard
|
||||||
key={item.id}
|
key={item.id}
|
||||||
item={item}
|
item={item}
|
||||||
onAdd={handleAddStub}
|
onAdd={() => handleAdd(item)}
|
||||||
weight={weight}
|
weight={weight}
|
||||||
price={price}
|
price={price}
|
||||||
/>
|
/>
|
||||||
@@ -410,7 +418,7 @@ export function CatalogSearchOverlay() {
|
|||||||
<ListRow
|
<ListRow
|
||||||
key={item.id}
|
key={item.id}
|
||||||
item={item}
|
item={item}
|
||||||
onAdd={handleAddStub}
|
onAdd={() => handleAdd(item)}
|
||||||
weight={weight}
|
weight={weight}
|
||||||
price={price}
|
price={price}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||||
import { useFormatters } from "../../hooks/useFormatters";
|
import { useFormatters } from "../../hooks/useFormatters";
|
||||||
import { useGlobalItem } from "../../hooks/useGlobalItems";
|
import { useGlobalItem } from "../../hooks/useGlobalItems";
|
||||||
|
import { useUIStore } from "../../stores/uiStore";
|
||||||
|
|
||||||
export const Route = createFileRoute("/global-items/$globalItemId")({
|
export const Route = createFileRoute("/global-items/$globalItemId")({
|
||||||
component: GlobalItemDetail,
|
component: GlobalItemDetail,
|
||||||
@@ -10,6 +11,8 @@ function GlobalItemDetail() {
|
|||||||
const { globalItemId } = Route.useParams();
|
const { globalItemId } = Route.useParams();
|
||||||
const { data: item, isLoading, error } = useGlobalItem(Number(globalItemId));
|
const { data: item, isLoading, error } = useGlobalItem(Number(globalItemId));
|
||||||
const { weight, price } = useFormatters();
|
const { weight, price } = useFormatters();
|
||||||
|
const openAddToCollection = useUIStore((s) => s.openAddToCollection);
|
||||||
|
const openAddToThread = useUIStore((s) => s.openAddToThread);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
@@ -126,15 +129,22 @@ function GlobalItemDetail() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Add to Collection */}
|
{/* Action buttons */}
|
||||||
<div className="mb-6">
|
<div className="flex gap-3 mb-6">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => console.log("Add to collection — wired in Phase 22")}
|
onClick={() => openAddToCollection(item.id, `${item.brand} ${item.model}`)}
|
||||||
className="bg-gray-700 text-white rounded-lg px-5 py-2.5 text-sm font-medium hover:bg-gray-800 transition-colors"
|
className="bg-gray-700 text-white rounded-lg px-5 py-2.5 text-sm font-medium hover:bg-gray-800 transition-colors"
|
||||||
>
|
>
|
||||||
Add to Collection
|
Add to Collection
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => openAddToThread(item.id, `${item.brand} ${item.model}`)}
|
||||||
|
className="bg-white text-gray-700 border border-gray-200 rounded-lg px-5 py-2.5 text-sm font-medium hover:bg-gray-50 transition-colors"
|
||||||
|
>
|
||||||
|
Add to Thread
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Description */}
|
{/* Description */}
|
||||||
|
|||||||
Reference in New Issue
Block a user