import { useState, useEffect } from "react"; const STATIC_ASSETS = "https://warframe.market/static/assets"; function median(arr) { if (arr.length === 0) return null; const sorted = [...arr].sort((a, b) => a - b); const mid = Math.floor(sorted.length / 2); return sorted.length % 2 !== 0 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2; } export default function ItemDetail({ slug, onBack }) { const [orders, setOrders] = useState(null); const [item, setItem] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { let cancelled = false; async function load() { setLoading(true); setError(null); try { const [ordersRes, catalogRes] = await Promise.all([ fetch(`/api/orders/${encodeURIComponent(slug)}`), fetch("/api/items"), ]); if (!ordersRes.ok) throw new Error(`Orders HTTP ${ordersRes.status}`); const ordersData = await ordersRes.json(); if (!cancelled) setOrders(ordersData); if (catalogRes.ok) { const catalogData = await catalogRes.json(); const found = catalogData.find((i) => i.slug === slug); if (!cancelled) setItem(found); } } catch (err) { if (!cancelled) setError(err.message); } finally { if (!cancelled) setLoading(false); } } load(); return () => { cancelled = true; }; }, [slug]); if (loading) { return
Failed to load orders: {error}
| Price | Qty | User | Rep | Status |
|---|---|---|---|---|
| {o.platinum}p | {o.quantity} | {o.user?.ingameName || "?"} | {o.user?.reputation ?? "?"} | {o.user?.status} |
| Price | Qty | User | Rep | Status |
|---|---|---|---|---|
| {o.platinum}p | {o.quantity} | {o.user?.ingameName || "?"} | {o.user?.reputation ?? "?"} | {o.user?.status} |