mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-14 10:42:45 -05:00
18 lines
808 B
JavaScript
18 lines
808 B
JavaScript
// utils
|
|
// Purpose: Defines the utils module and the local helpers/components used in this file.
|
|
// Scope: Keeps behavior unchanged while isolating this concern into a clear, single-responsibility unit.
|
|
import { buildBatteryVisual } from '../../lib/battery.js';
|
|
|
|
export function formatDriverLabel({ roverId, session }) {
|
|
const turn = session?.roster?.find((rover) => String(rover.id) === String(roverId))?.turn;
|
|
const driver = turn?.queue?.find((entry) => entry.socketId === turn.currentId);
|
|
const label = driver?.name || 'No driver';
|
|
return label;
|
|
}
|
|
|
|
export function getBatteryVisual({ rover, frame }) {
|
|
const charge = frame?.sensors?.batteryChargeMah ?? null;
|
|
const config = rover?.battery ?? null;
|
|
return buildBatteryVisual({ batteryState: rover?.batteryState ?? null, charge, config });
|
|
}
|