From 1bc3601c58d08f441be61738a30d0accffdb1867 Mon Sep 17 00:00:00 2001 From: Eddasol Date: Fri, 12 Jan 2024 10:04:46 +0100 Subject: [PATCH] Fix pressure display --- .../RobotDisplays/PressureStatusDisplay.tsx | 27 +++++++------------ .../FrontPage/RobotCards/RobotStatusCard.tsx | 12 +++++---- .../components/Pages/RobotPage/RobotPage.tsx | 22 ++++++++------- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/Displays/RobotDisplays/PressureStatusDisplay.tsx b/frontend/src/components/Displays/RobotDisplays/PressureStatusDisplay.tsx index 64f1cdb55..ba4edee1e 100644 --- a/frontend/src/components/Displays/RobotDisplays/PressureStatusDisplay.tsx +++ b/frontend/src/components/Displays/RobotDisplays/PressureStatusDisplay.tsx @@ -14,8 +14,7 @@ const StyledTypography = styled(Typography)<{ $fontSize?: 24 | 16 | 18 | 32 | 40 font-size: ${(props) => props.$fontSize}; ` interface PressureStatusDisplayProps { - pressureInBar?: number - pressureInMilliBar?: number + pressureInBar: number itemSize?: 24 | 16 | 18 | 32 | 40 | 48 | undefined upperPressureWarningThreshold?: number lowerPressureWarningThreshold?: number @@ -28,27 +27,19 @@ export const PressureStatusDisplay = ({ lowerPressureWarningThreshold, }: PressureStatusDisplayProps): JSX.Element => { const barToMillibar = 1000 + const pressureInMilliBar = `${Math.round(pressureInBar * barToMillibar)}mBar` let icon_color: string = tokens.colors.interactive.primary__resting.hex let pressureStatus: PressureStatus - let pressureInMilliBar: string = '' - if (!pressureInBar) { - pressureInMilliBar = '' - pressureStatus = PressureStatus.Default - return <> - } else if (!upperPressureWarningThreshold || !lowerPressureWarningThreshold) { + if (!upperPressureWarningThreshold || !lowerPressureWarningThreshold) { pressureStatus = PressureStatus.Normal + } else if ( + pressureInBar * barToMillibar > upperPressureWarningThreshold || + pressureInBar * barToMillibar < lowerPressureWarningThreshold + ) { + pressureStatus = PressureStatus.Critical } else { - if ( - pressureInBar * barToMillibar > upperPressureWarningThreshold || - pressureInBar * barToMillibar < lowerPressureWarningThreshold - ) { - pressureStatus = PressureStatus.Critical - pressureInMilliBar = `${Math.round(pressureInBar * barToMillibar)}mBar` - } else { - pressureStatus = PressureStatus.Normal - pressureInMilliBar = `${Math.round(pressureInBar * barToMillibar)}mBar` - } + pressureStatus = PressureStatus.Normal } switch (pressureStatus) { diff --git a/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusCard.tsx b/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusCard.tsx index 8cfa67a88..bece00740 100644 --- a/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusCard.tsx +++ b/frontend/src/components/Pages/FrontPage/RobotCards/RobotStatusCard.tsx @@ -76,11 +76,13 @@ export const RobotStatusCard = ({ robot }: RobotProps) => { {robot.status !== RobotStatus.Offline ? ( <> - + {robot.pressureLevel && ( + + )} ) : ( diff --git a/frontend/src/components/Pages/RobotPage/RobotPage.tsx b/frontend/src/components/Pages/RobotPage/RobotPage.tsx index d0edca46c..a839cedea 100644 --- a/frontend/src/components/Pages/RobotPage/RobotPage.tsx +++ b/frontend/src/components/Pages/RobotPage/RobotPage.tsx @@ -63,16 +63,18 @@ export const RobotPage = () => { {selectedRobot.status !== RobotStatus.Offline && ( <> - + {selectedRobot.pressureLevel && ( + + )} )}