// Optimal Trade — Home (bento), Orders feed, Finance, Profile, Counterparties const { useState: useStateH, useEffect: useEffectH } = React; /* status vocab for orders (colour + icon + text — always all three) */ const ORDER_STATUS = { offers: { kind: "transit", icon: "sparkles", label: "offers ready" }, waiting: { kind: "pending", dot: true, label: "Awaiting offers" }, topay: { kind: "locked", icon: "wallet", label: "Awaiting payment" }, transit: { kind: "transit", icon: "ship", label: "In transit" }, delivered: { kind: "paid", icon: "check-check", label: "Delivered" }, declined: { kind: "error", icon: "x", label: "Declined" }, }; function OrderChip({ status, text }) { const m = ORDER_STATUS[status] || ORDER_STATUS.waiting; return {text || m.label}; } /* ============================== HOME (bento) ==================================== */ function Home({ app }) { const a = app.account, w = app.world; const [glow, setGlow] = useStateH(false); useEffectH(() => { if (w.justPaid) { setGlow(true); const t = setTimeout(() => { setGlow(false); app.clearJustPaid(); }, 1400); return () => clearTimeout(t); } }, [w.justPaid]); const rate = RATE_PAIRS[0]; const active = w.orders.filter(o => o.kind === "order" && o.status !== "delivered"); return (
{/* greeting */}
Welcome back {a.company}
{/* BENTO 1 — balance + rate (large, door to Finance) */}
app.setTab("finance")} style={{ background: "var(--ot-grad-hero)", borderRadius: "var(--ot-r-xl)", padding: 20, color: "#fff", boxShadow: "var(--ot-shadow-orange)", position: "relative", overflow: "hidden", cursor: "pointer" }}>
Balance · {a.ccy} {rate.pair} {fmt(rate.rate, 2)}
{/* BENTO 2 — To-pay (money finds the user) */} {w.toPay && (
app.navigate("payconfirm", { invoice: w.toPay })}>
To pay · {w.toPay.supplier}
{w.toPay.id} · {w.toPay.due}
{money(w.toPay.sym, w.toPay.amount)}
Pay now ›
)} {/* BENTO 3 — active orders lane */}
Active orders app.setTab("orders")} style={{ fontSize: 12.5, color: "var(--ot-orange-deep)", fontWeight: 700, cursor: "pointer" }}>See all
{active.map(o => (
app.openOrder(o)}>
{o.id}
{o.title} {o.supplier}
{o.next}
))}
{/* primary intent — the single accent button */}

Request a price from verified suppliers in 4 steps.

); } /* ============================== ORDERS FEED ==================================== */ function Orders({ app }) { const w = app.world; const [f, setF] = useStateH("all"); const chips = [["all", "All"], ["quote", "Quotes"], ["topay", "To pay"], ["transit", "In transit"], ["delivered", "Delivered"]]; const list = w.orders.filter(o => f === "all" || o.status === f || (f === "quote" && o.kind === "quote")); return (
} />
{chips.map(([id, label]) => )}
{list.map(o => (
app.openOrder(o)}>
{o.title} {o.id} · {o.kind === "quote" ? "Quote" : o.supplier}
{o.amount && {money(o.sym, o.amount)}}
{o.sub}
))}
); } /* ============================== FINANCE ======================================== */ function Finance({ app }) { const a = app.account, w = app.world; const pockets = [{ ccy: "USD", sym: "$", flag: "us", bal: w.usdBalance }, { ccy: "CNY", sym: "\u00A5", flag: "cn", bal: w.cnyBalance }]; return (
} />
Balance · {a.ccy}
Currency pockets
{pockets.map(c => } title={`${c.ccy} pocket`} sub="For supplier payments" right={{money(c.sym, c.bal, c.ccy === "USD" ? 2 : 0)}} />)}
Recent operations app.setTab("orders")} style={{ fontSize: 12.5, color: "var(--ot-orange-deep)", fontWeight: 700, cursor: "pointer" }}>All
{w.txs.slice(0, 4).map(t => { const ic = { invoice: "ship", topup: "arrow-down-left", convert: "arrow-right-left" }[t.type]; return {t.amount < 0 ? "−" : "+"}{money(t.sym, Math.abs(t.amount))}} />; })}
); } /* ============================== PROFILE & COUNTERPARTIES ======================= */ function Profile({ app }) { const a = app.account; return (
{a.company} {a.name} · {a.country}
Verified business
{PROFILE_MENU.map(m => ( m.to && app.navigate(m.to)} right={m.badge ? {m.badge} : null} /> ))}

Optimal Trade · Demo prototype · v3.0

); } function Counterparties({ app }) { const [q, setQ] = useStateH(""); const list = SUPPLIERS.filter(s => s.name.toLowerCase().includes(q.toLowerCase()) || s.cat.toLowerCase().includes(q.toLowerCase())); return (
setQ(e.target.value)} />
{list.map(s => (
app.navigate("supplier", { supplier: s })}>
{s.authorized && }
{s.name} {s.country} · {s.cat}
{s.rating}
))}
); } Object.assign(window, { Home, Orders, Finance, Profile, Counterparties, OrderChip, ORDER_STATUS });