/* © 2026 K2B NETWORK SOLUTIONS LLC. All rights reserved. Proprietary and confidential. Unauthorized copying, distribution, or use of this file, via any medium, is strictly prohibited. Original work product. */ /* eslint-disable */ // JBREWS DMS — RouteOne (F&I credit-application gateway). // The dealership-facing RouteOne workspace: editable connection settings up // front, every submission tracked with its reference #, lender decisions // recorded per deal, and one-click submit for any working deal. The live wire // to RouteOne's network runs through the server tier (INTEGRATIONS_SPEC.md); // everything here is functional now and switches to live with zero UI changes. const r1Money = (n) => "$" + (Number(n) || 0).toLocaleString("en-US", { maximumFractionDigits: 0 }); const R1_TONE = { Submitted: { bg: "var(--jb-blue-tint,#E5EFFA)", fg: "var(--jb-blue,#1B66A8)" }, Approved: { bg: "var(--jb-green-tint,#E6F7EC)", fg: "#0E7A37" }, Conditioned: { bg: "#FBF3E0", fg: "#9A6700" }, Declined: { bg: "#FBE9E7", fg: "#B23A2E" }, }; const R1Badge = ({ s }) => { const t = R1_TONE[s] || R1_TONE.Submitted; return {s}; }; const RouteOne = ({ onClose, go }) => { const D = window.DMS; const [, force] = React.useReducer(n => n + 1, 0); React.useEffect(() => (D && D.subscribe) ? D.subscribe(force) : undefined, []); const act = (r) => { window.k2bToast && window.k2bToast(r.msg, r.ok ? "ok" : "warn", 4200); return r; }; const deals = (D && D.deals) ? D.deals() : []; const submitted = deals.filter(d => d.routeOne); const eligible = deals.filter(d => !d.routeOne && d.buyer); const [cfg, setCfg] = React.useState(() => (D && D.routeOneConfig) ? D.routeOneConfig() : {}); const [cfgOpen, setCfgOpen] = React.useState(false); // Deal in focus for the "Open RouteOne ▸" launch (the F&I hand-off pointer). const focusDealId = (() => { try { return localStorage.getItem("jb_fw_deal") || ""; } catch (e) { return ""; } })(); const focusDeal = focusDealId ? deals.find(d => d.id === focusDealId) : null; const [pickOpen, setPickOpen] = React.useState(false); const connected = !!(cfg.dealerId && cfg.user); const set = (k, v) => setCfg(c => ({ ...c, [k]: v })); const saveCfg = () => { D.setRouteOneConfig(cfg); act({ ok: true, msg: "RouteOne settings saved — Send to RouteOne is live on the Finance Worksheet and Credit App too." }); setCfgOpen(false); force(); }; const inp = { width: "100%", boxSizing: "border-box", padding: "7px 9px", border: "1px solid #C8CCD2", borderRadius: 4, fontSize: 13 }; return (
{/* connection banner + editable settings */}
RouteOne {/* Connected App launch — your own RouteOne login in a named tab the DMS reuses */} {window.AppLaunchButton && ( )} {window.K2BApps && window.K2BApps.isConnected("routeone") ? "● signed in — opens in your RouteOne tab" : "sign in once in the tab that opens; the DMS reuses it"}
{connected ? `server submit: Dealer ${cfg.dealerId}` : "server submit: not set up (optional)"}
{cfgOpen && (
Optional — only for server-side deal submission (INTEGRATIONS_SPEC.md). Day-to-day, just use Open RouteOne ▸ with your own login.
)}
{/* KPIs + submit */}
{[["Submitted", submitted.length], ["Approved", submitted.filter(d => d.routeOne.status === "Approved").length], ["Pending Decision", submitted.filter(d => d.routeOne.status === "Submitted").length], ["Declined", submitted.filter(d => d.routeOne.status === "Declined").length]].map(([lab, val], i) => (
{lab}
{val}
))}
{/* submissions */}
{submitted.length === 0 ? (
No submissions yet. {connected ? "Use “⇪ Submit Deal to RouteOne…” above, or the Send to RouteOne buttons on the Finance Worksheet / Credit App." : "Use Open RouteOne ▸ above to work deals in your own RouteOne login; server submit tracking is optional (Advanced)."}
) : ( {["Reference", "Deal", "Buyer", "Lender", "Amt Financed", "Sent", "Status", "Decision / Note", ""].map((h, i) => )} {submitted.map((d, i) => { const ro = d.routeOne; return ( ); })}
{h}
{ro.ref} {d.id} {d.buyer} {ro.lender || d.lender || "—"} {r1Money(ro.amount || d.amtFinanced)} {ro.sentAt ? new Date(ro.sentAt).toLocaleDateString() : "—"} {ro.status === "Submitted" ? ( {["Approved", "Conditioned", "Declined"].map(dec => ( ))} ) : {ro.note || (ro.decidedAt ? new Date(ro.decidedAt).toLocaleString() : "")}} {window.AppLaunchButton && }
)}
ESC-Close go && go("financews")}>Finance Worksheet go && go("creditapp")}>Credit App go && go("banks")}>Banks / Lenders
{pickOpen && ( setPickOpen(false)} buttons={ setPickOpen(false)}>Cancel}> {eligible.length === 0 ? (
Every deal with a buyer has already been submitted. Create or work a deal first (Deals / Desking).
) : (
{eligible.map(d => ( ))}
)}
)}
); }; Object.assign(window, { RouteOne });