diff --git a/frontend/src/components/steps/zone/ZoneSelector.js b/frontend/src/components/steps/zone/ZoneSelector.js index 7bacaf6..7b47b33 100644 --- a/frontend/src/components/steps/zone/ZoneSelector.js +++ b/frontend/src/components/steps/zone/ZoneSelector.js @@ -29,12 +29,10 @@ export default function ZoneSelector(props) { const redirectHabitat = zoneSegment && zoneSegment.zone && zoneSegment.zone.redirect_habitat; setZoneSegment(zoneSegment); - if (redirectHabitat) { - props.updateFilterState({ "habitat": { "id": redirectHabitat.id, "name": redirectHabitat.name } }); - props.setRedirectBack(true) - } else { - props.updateFilterState({ "zone": zoneSegment.zone }); - } + // If there is a redirect habitat set then redirect otherwise set the zone as state + const newFilterState = redirectHabitat ? { "habitat": { "id": redirectHabitat.id, "name": redirectHabitat.name }} : { "zone": zoneSegment.zone }; + props.updateFilterState(newFilterState); + props.setRedirectBack(Boolean(redirectHabitat)); props.setNextDisabled(false); }