Skip to content

Commit

Permalink
Update active plant list when opening list
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Sep 6, 2023
1 parent c9b92b8 commit 1543895
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ function InstallationPicker(page: string) {
const { installationCode, switchInstallation } = useInstallationContext()
const [showActivePlants, setShowActivePlants] = useState<boolean>(true)
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false)
const [updateListOfActivePlants, setUpdateListOfActivePlants] = useState<boolean>(false)

useEffect(() => {
const plantPromise = showActivePlants ? BackendAPICaller.getActivePlants() : BackendAPICaller.getEchoPlantInfo()
plantPromise.then(async (response: EchoPlantInfo[]) => {
const mapping = mapInstallationCodeToName(response)
setAllPlantsMap(mapping)
})
}, [showActivePlants])
}, [showActivePlants, updateListOfActivePlants])

const mappedOptions = allPlantsMap ? allPlantsMap : new Map<string, string>()
return (
Expand All @@ -102,7 +103,10 @@ function InstallationPicker(page: string) {
else switchInstallation('')
}}
autoWidth={true}
onFocus={(e) => e.preventDefault()}
onFocus={(e) => {
e.preventDefault()
setUpdateListOfActivePlants(!updateListOfActivePlants)
}}
/>
<Button variant="ghost_icon" onClick={() => setIsDialogOpen(true)}>
{' '}
Expand Down

0 comments on commit 1543895

Please sign in to comment.