Slight refactor of redirect logic code
This commit is contained in:
parent
caedec0a16
commit
e99cf44312
1 changed files with 4 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue