import { Trans } from "@lingui/react/macro"; import { cn } from "@rakazo/ui-web"; import { Activity } from "lucide-react"; import type { ReactNode } from "react"; import { presentTradingStatus, type TradingBotUiState, type TradingModeLabelId, type TradingModeSubtitle, } from "../lib/trading-bot-status"; export function TradingModeIndicator({ snapshot, className, }: { snapshot: TradingBotUiState; className?: string; }) { const presentation = presentTradingStatus(snapshot); return (
{presentation.subtitle ? ( ) : null}
); } function TradingModeLabel({ label }: { label: TradingModeLabelId }): ReactNode { switch (label) { case "loading": return Trading; case "unconfigured": return Not configured; case "offline": return Offline; case "unknown": return Unknown; case "live": return Live Trading; case "paper": return Paper; case "dry_run": return Dry run; default: { const exhaustive: never = label; return exhaustive; } } } function TradingModeSubtitleText({ subtitle }: { subtitle: TradingModeSubtitle }): ReactNode { switch (subtitle.type) { case "error": return subtitle.text; case "adapters": return subtitle.count === 1 ? ( 1 adapter ) : ( {subtitle.count} adapters ); default: { const exhaustive: never = subtitle; return exhaustive; } } }