feat(21-03): rewire card click handlers to navigate to detail pages
- ItemCard navigates to /items/$itemId instead of opening edit panel - CandidateCard navigates to /threads/$threadId/candidates/$candidateId - CandidateListItem navigates to candidate detail page - CatalogSearchOverlay cards navigate to /global-items/$globalItemId - Add button on catalog cards uses stopPropagation to prevent navigation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { useFormatters } from "../hooks/useFormatters";
|
||||
import { useDuplicateItem } from "../hooks/useItems";
|
||||
import { LucideIcon } from "../lib/iconData";
|
||||
@@ -36,14 +37,16 @@ export function ItemCard({
|
||||
onClassificationCycle,
|
||||
}: ItemCardProps) {
|
||||
const { weight, price } = useFormatters();
|
||||
const openEditPanel = useUIStore((s) => s.openEditPanel);
|
||||
const navigate = useNavigate();
|
||||
const openExternalLink = useUIStore((s) => s.openExternalLink);
|
||||
const duplicateItem = useDuplicateItem();
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => openEditPanel(id)}
|
||||
onClick={() =>
|
||||
navigate({ to: "/items/$itemId", params: { itemId: String(id) } })
|
||||
}
|
||||
className="relative w-full text-left bg-white rounded-xl border border-gray-100 hover:border-gray-200 hover:shadow-sm transition-all overflow-hidden group"
|
||||
>
|
||||
{!onRemove && (
|
||||
@@ -54,7 +57,10 @@ export function ItemCard({
|
||||
e.stopPropagation();
|
||||
duplicateItem.mutate(id, {
|
||||
onSuccess: (newItem) => {
|
||||
openEditPanel(newItem.id);
|
||||
navigate({
|
||||
to: "/items/$itemId",
|
||||
params: { itemId: String(newItem.id) },
|
||||
});
|
||||
},
|
||||
});
|
||||
}}
|
||||
@@ -63,7 +69,10 @@ export function ItemCard({
|
||||
e.stopPropagation();
|
||||
duplicateItem.mutate(id, {
|
||||
onSuccess: (newItem) => {
|
||||
openEditPanel(newItem.id);
|
||||
navigate({
|
||||
to: "/items/$itemId",
|
||||
params: { itemId: String(newItem.id) },
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user