From d9ae1d7b94c3edc5e28b25fcc6b1424559ea5f1c Mon Sep 17 00:00:00 2001 From: Noe Date: Mon, 11 Mar 2024 16:08:20 +0100 Subject: [PATCH] update battery view --- .../dashboards/BatteryView/BatteryView.tsx | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) 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}