Skip to content

Commit

Permalink
Fix preselection of robot
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Dec 4, 2024
1 parent 4583b47 commit 6dd8eda
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => {
const { setLoadingRobotMissionSet } = useMissionsContext()
const { setAlert, setListAlert } = useAlertContext()
const [isLocalizationVerificationDialogOpen, setIsLocalizationVerificationDialog] = useState<boolean>(false)
const [selectedRobot, setSelectedRobot] = useState<Robot>()
const [missionsToSchedule, setMissionsToSchedule] = useState<MissionDefinition[]>()
const filteredRobots = enabledRobots.filter(
(r) =>
Expand All @@ -65,6 +64,9 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => {
r.status === RobotStatus.Recharging) &&
r.isarConnected
)
const [selectedRobot, setSelectedRobot] = useState<Robot | undefined>(
filteredRobots.length === 1 ? filteredRobots[0] : undefined
)

const onSelectedRobot = (selectedRobot: Robot) => {
if (filteredRobots) setSelectedRobot(selectedRobot)
Expand Down Expand Up @@ -152,7 +154,7 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => {
)}
<StyledAutoComplete>
<Autocomplete
initialSelectedOptions={filteredRobots.length === 1 ? [filteredRobots[0]] : []}
initialSelectedOptions={selectedRobot ? [selectedRobot] : []}
dropdownHeight={200}
optionLabel={(r) => r.name + ' (' + r.model.type + ')'}
options={filteredRobots}
Expand Down

0 comments on commit 6dd8eda

Please sign in to comment.