Skip to content

Commit

Permalink
Include pressure/battery checks for 0 values
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Oct 28, 2024
1 parent 7804581 commit 5ea6039
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,25 @@ export const ScheduleMissionWithConfirmDialogs = ({
const { enabledRobots } = useRobotContext()
const [robot, setRobot] = useState<Robot>()

const isBatteryInsufficient = (currentRobot: Robot) =>
currentRobot.batteryLevel &&
currentRobot.model.batteryWarningThreshold &&
currentRobot.batteryLevel < currentRobot.model.batteryWarningThreshold
const isBatteryInsufficient = (currentRobot: Robot) => {
const hasBatteryValue = currentRobot.batteryLevel !== null && currentRobot.batteryLevel !== undefined
return (
hasBatteryValue &&
currentRobot.model.batteryWarningThreshold &&
currentRobot.batteryLevel! < currentRobot.model.batteryWarningThreshold
)
}

const isPressureInsufficient = (currentRobot: Robot) =>
currentRobot.pressureLevel &&
((currentRobot.model.lowerPressureWarningThreshold &&
currentRobot.pressureLevel < currentRobot.model.lowerPressureWarningThreshold) ||
const isPressureInsufficient = (currentRobot: Robot) => {
const hasPressureValue = currentRobot.pressureLevel !== null && currentRobot.pressureLevel !== undefined
return (
(hasPressureValue &&
currentRobot.model.lowerPressureWarningThreshold &&
currentRobot.pressureLevel! < currentRobot.model.lowerPressureWarningThreshold) ||
(currentRobot.model.upperPressureWarningThreshold &&
currentRobot.pressureLevel > currentRobot.model.upperPressureWarningThreshold))
currentRobot.pressureLevel! > currentRobot.model.upperPressureWarningThreshold)
)
}

useEffect(() => {
setRobot(enabledRobots.find((robot) => robot.id === robotId))
Expand Down

0 comments on commit 5ea6039

Please sign in to comment.