import type { EngineStats } from "../types";
import { clsx, usd } from "../format";
interface Props {
stats: EngineStats;
connected: boolean;
}
function Stat({ label, value, tone }: { label: string; value: string; tone?: "profit" | "loss" | "warn" }): JSX.Element {
return (
{label}
{value}
);
}
function circuitTone(c: EngineStats["circuit"]): { label: string; cls: string } {
switch (c) {
case "running":
return { label: "RUNNING", cls: "bg-profit/15 text-profit border-profit/40" };
case "paused":
return { label: "PAUSED", cls: "bg-warn/15 text-warn border-warn/40" };
case "tripped":
return { label: "BREAKER TRIPPED", cls: "bg-loss/15 text-loss border-loss/40" };
default: {
const _exhaustive: never = c;
return { label: _exhaustive, cls: "" };
}
}
}
export function StatsBar({ stats, connected }: Props): JSX.Element {
const circuit = circuitTone(stats.circuit);
const pnlTone = stats.realizedPnl >= 0 ? "profit" : "loss";
return (
{stats.demoMode && (
Demo / Simulated Feed
)}
{circuit.label}
{connected ? "LIVE" : "OFFLINE"}
);
}