diff --git a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx index 6fdfeeee5..89fcf724b 100644 --- a/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/BatteryView/BatteryView.tsx @@ -36,12 +36,22 @@ function BatteryView(props: BatteryViewProps) { } const currentLocation = useLocation(); const navigate = useNavigate(); - const numOfBatteries = props.values.batteryView.length; + const sortedBatteryView = [...props.values.batteryView].sort( + (a, b) => b.BatteryId - a.BatteryId + ); const handleMainStatsButton = () => { navigate(routes.mainstats); }; + const findBatteryData = (batteryId: number) => { + for (let i = 0; i < props.values.batteryView.length; i++) { + if (props.values.batteryView[i].BatteryId == batteryId) { + return props.values.batteryView[i]; + } + } + }; + return ( <> @@ -97,14 +107,14 @@ function BatteryView(props: BatteryViewProps) { } /> - {Array.from({ length: numOfBatteries }).map((_, i) => ( + {props.values.batteryView.map((battery) => ( } /> @@ -138,7 +148,7 @@ function BatteryView(props: BatteryViewProps) { - {props.values.batteryView.map((battery) => ( + {sortedBatteryView.map((battery) => ( - {'Battery ' + battery.BatteryId} + {'Node ' + battery.BatteryId}