/* global window, React */ // ============================================================ // Trip detail — Tab 1: Load composition // ============================================================ function StatBox({ label, value, unit, sub, kind }) { return (
{label}
{value}{unit && {unit}}
{sub &&
{sub}
}
); } function UtilBar({ pct }) { const state = pct > 97 ? 'red' : pct >= 80 ? 'green' : 'amber'; const capped = Math.min(pct, 110); return (
{pct}%
80%
97%
0%25%50%75%100%
); } function OrdersTable({ orders }) { return (
Order ID Customer / SKU Pallets Weight Cube Invoice $ Ship by
{orders.map(o => (
⋮⋮ {o.id} {o.held && HELD}
{o.customer}
{o.sku}
{o.pallets} {o.lbs.toLocaleString()} {o.cuft.toLocaleString()} ft³ ${o.invoiceValue ? o.invoiceValue.toLocaleString() : '—'} {o.invoiceRate && ( ${o.invoiceRate.toFixed(2)}/lb )} {o.ship}
))}
Add order from pool
); } function OptCards({ items }) { return (
{items.map((o, i) => (
{o.label}
{o.title}
))}
); } function LoadCompositionTab({ trip }) { const totalPallets = trip.orders.reduce((a, o) => a + o.pallets, 0); const totalLbs = trip.orders.reduce((a, o) => a + o.lbs, 0); const totalCuft = trip.orders.reduce((a, o) => a + o.cuft, 0); const cubePct = Math.round((totalCuft / 3500) * 100); const invoice = trip.loadInvoice || trip.orders.reduce((a, o) => a + (o.invoiceValue || 0), 0); const recOption = trip.fleetOptions.find(o => o.recommended) || trip.fleetOptions[0]; const recCost = recOption && recOption.costToServeDollar ? recOption.costToServeDollar : null; const c2s = trip.costToServePct; // benchmark — lane-typical c2s in this fixture const c2sBench = 7.5; const c2sKind = !c2s ? '' : c2s > c2sBench * 1.2 ? 'red' : c2s < c2sBench * 0.8 ? 'green' : 'amber'; return (
Utilisation & load economics
53 ft trailer · max 45,000 lbs · 32 pallet positions · lane benchmark cost-to-serve {c2sBench}%
97 ? 'red' : trip.util < 80 ? 'amber' : 'green'} />
Orders on this load · {trip.orders.length}
Drag to reorder · × removes back to pool · Σ invoice ${invoice.toLocaleString()}
Optimisation options · agent
{trip.opt.length} suggestion{trip.opt.length === 1 ? '' : 's'}
); } Object.assign(window, { LoadCompositionTab });