import { useParams, Link } from '@tanstack/react-router' import { ArrowLeft, ExternalLink, Package, Loader2, AlertCircle } from 'lucide-react' import { AppShell } from '@/components/layout/AppShell' import { StatusBadge } from '@/components/inventory/StatusBadge' import { Button } from '@/components/ui/button' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { useInventoryItem } from '@/hooks/useInventory' function FieldRow({ label, value }: { label: string; value?: string }) { if (!value) return null return (
{label} {value}
) } export function ItemDetailPage() { const { id } = useParams({ from: '/item/$id' }) const numericId = parseInt(id, 10) const { data: item, isLoading, error } = useInventoryItem(numericId) if (isLoading) { return (
Loading item…
) } if (error || !item) { return (
{(error as Error)?.message ?? 'Item not found'}
) } const netboxUrl = `http://netbox.local/dcim/devices/${item.id}/` return ( {/* Back nav */}
{/* Header */}

{item.hw_id || item.asset_tag}

{item.name}

{/* Two-column layout: photos (left on lg+) / fields (right or below) */}
{/* Photos */} Photos {item.photo_urls.length > 0 ? (
{item.photo_urls.map((url, i) => ( {`${item.name} ))}
) : (

No photos

)}
{/* Fields */}
Details {item.ai_notes && ( AI Notes

{item.ai_notes}

)} {item.test_data && ( Test Data
                  {(() => {
                    try { return JSON.stringify(JSON.parse(item.test_data!), null, 2) }
                    catch { return item.test_data }
                  })()}
                
)}
) }