type Props = { modeName: string activatedAt: string | null nextReplanIn: number | null onReplan: () => void onModeChange: () => void } const MODE_DOT: Record = { AUTO: '#1D9E75', SELF_SUSTAIN: '#E24B4A', CHARGE_CHEAP: '#EF9F27', PRESERVE: '#378ADD', MANUAL: '#888780', } function fmtActivatedPrague(iso: string | null): string | null { if (!iso) return null return new Intl.DateTimeFormat('cs-CZ', { timeZone: 'Europe/Prague', hour: '2-digit', minute: '2-digit', hour12: false, }).format(new Date(iso)) } export function ModeBar({ modeName, activatedAt, nextReplanIn, onReplan, onModeChange }: Props) { const code = (modeName || 'AUTO').toUpperCase().replace(/-/g, '_') const dot = MODE_DOT[code] ?? MODE_DOT.MANUAL! const tAct = fmtActivatedPrague(activatedAt) const subParts: string[] = [] if (tAct) subParts.push(`aktivní od ${tAct}`) if (nextReplanIn != null) subParts.push(`příští replan za ${nextReplanIn} min`) return ( <>
{code} {subParts.length > 0 ? ( {subParts.join(' · ')} ) : null}
) }