import { createFileRoute, Link } from "@tanstack/react-router"; import { useFormatters } from "../../hooks/useFormatters"; import { useGlobalItem } from "../../hooks/useGlobalItems"; 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(); 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} )}
{/* Add to Collection */}
{/* Description */} {item.description && (

{item.description}

)}
); }