fix: shared setup items link to catalog instead of requiring auth
Items with a globalItemId now link to /global-items/:id (public) in shared and public setup views. Items without a catalog link are not clickable. Owner view behavior unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,7 @@ interface ItemCardProps {
|
|||||||
onRemove?: () => void;
|
onRemove?: () => void;
|
||||||
classification?: string;
|
classification?: string;
|
||||||
onClassificationCycle?: () => void;
|
onClassificationCycle?: () => void;
|
||||||
|
linkTo?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ItemCard({
|
export function ItemCard({
|
||||||
@@ -46,19 +47,29 @@ export function ItemCard({
|
|||||||
onRemove,
|
onRemove,
|
||||||
classification,
|
classification,
|
||||||
onClassificationCycle,
|
onClassificationCycle,
|
||||||
|
linkTo,
|
||||||
}: ItemCardProps) {
|
}: ItemCardProps) {
|
||||||
const { weight, price } = useFormatters();
|
const { weight, price } = useFormatters();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const openExternalLink = useUIStore((s) => s.openExternalLink);
|
const openExternalLink = useUIStore((s) => s.openExternalLink);
|
||||||
const duplicateItem = useDuplicateItem();
|
const duplicateItem = useDuplicateItem();
|
||||||
|
|
||||||
|
const handleClick =
|
||||||
|
linkTo === null
|
||||||
|
? undefined
|
||||||
|
: () => {
|
||||||
|
if (linkTo) {
|
||||||
|
navigate({ to: linkTo });
|
||||||
|
} else {
|
||||||
|
navigate({ to: "/items/$itemId", params: { itemId: String(id) } });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={handleClick}
|
||||||
navigate({ to: "/items/$itemId", params: { itemId: String(id) } })
|
className={`relative w-full text-left bg-white rounded-xl border border-gray-100 transition-all overflow-hidden group ${linkTo === null ? "cursor-default" : "hover:border-gray-200 hover:shadow-sm"}`}
|
||||||
}
|
|
||||||
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 && (
|
{!onRemove && (
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -381,6 +381,13 @@ function SetupDetailPage() {
|
|||||||
})
|
})
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
linkTo={
|
||||||
|
!showOwnerControls
|
||||||
|
? item.globalItemId
|
||||||
|
? `/global-items/${item.globalItemId}`
|
||||||
|
: null
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user