import { createFileRoute, Link } from "@tanstack/react-router"; import { useAuth } from "../../hooks/useAuth"; import { useFormatters } from "../../hooks/useFormatters"; import { useGlobalItem } from "../../hooks/useGlobalItems"; import { useUIStore } from "../../stores/uiStore"; export const Route = createFileRoute("/global-items/$globalItemId")({ component: GlobalItemDetail, }); function GlobalItemDetail() { const { globalItemId } = Route.useParams(); const { data: item, isLoading, error } = useGlobalItem(Number(globalItemId)); const { weight, price } = useFormatters(); const { data: auth } = useAuth(); const isAuthenticated = !!auth?.user; const openAddToCollection = useUIStore((s) => s.openAddToCollection); const openAddToThread = useUIStore((s) => s.openAddToThread); const openAuthPrompt = useUIStore((s) => s.openAuthPrompt); if (isLoading) { return (
); } if (error || !item) { return (
← Back to catalog

Global item not found

); } return (
← Back to catalog
{/* Image */}
{item.imageUrl ? ( {`${item.brand} ) : (
)}
{/* Header */}

{item.brand}

{item.model}

{/* Owner count badge */}
{item.ownerCount === 0 ? "Be the first to add this" : item.ownerCount === 1 ? "1 user owns this" : `${item.ownerCount} users own this`}
{/* Specs */}
{item.weightGrams != null && ( {weight(item.weightGrams)} )} {item.priceCents != null && ( {price(item.priceCents)} )} {item.category && ( {item.category} )}
{/* Action buttons */}
{/* Description */} {item.description && (

{item.description}

)}
); }