From 6dd8edadbf3e8e6d4586a2af02131278df08d467 Mon Sep 17 00:00:00 2001 From: Eddasol Date: Wed, 4 Dec 2024 09:08:55 +0100 Subject: [PATCH] Fix preselection of robot --- .../Pages/InspectionPage/ScheduleMissionDialogs.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx index ba27fc2b8..b7cf56fe1 100644 --- a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx +++ b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx @@ -56,7 +56,6 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { const { setLoadingRobotMissionSet } = useMissionsContext() const { setAlert, setListAlert } = useAlertContext() const [isLocalizationVerificationDialogOpen, setIsLocalizationVerificationDialog] = useState(false) - const [selectedRobot, setSelectedRobot] = useState() const [missionsToSchedule, setMissionsToSchedule] = useState() const filteredRobots = enabledRobots.filter( (r) => @@ -65,6 +64,9 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { r.status === RobotStatus.Recharging) && r.isarConnected ) + const [selectedRobot, setSelectedRobot] = useState( + filteredRobots.length === 1 ? filteredRobots[0] : undefined + ) const onSelectedRobot = (selectedRobot: Robot) => { if (filteredRobots) setSelectedRobot(selectedRobot) @@ -152,7 +154,7 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { )} r.name + ' (' + r.model.type + ')'} options={filteredRobots}