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;
|
const redirectHabitat = zoneSegment && zoneSegment.zone && zoneSegment.zone.redirect_habitat;
|
||||||
setZoneSegment(zoneSegment);
|
setZoneSegment(zoneSegment);
|
||||||
|
|
||||||
if (redirectHabitat) {
|
// If there is a redirect habitat set then redirect otherwise set the zone as state
|
||||||
props.updateFilterState({ "habitat": { "id": redirectHabitat.id, "name": redirectHabitat.name } });
|
const newFilterState = redirectHabitat ? { "habitat": { "id": redirectHabitat.id, "name": redirectHabitat.name }} : { "zone": zoneSegment.zone };
|
||||||
props.setRedirectBack(true)
|
props.updateFilterState(newFilterState);
|
||||||
} else {
|
props.setRedirectBack(Boolean(redirectHabitat));
|
||||||
props.updateFilterState({ "zone": zoneSegment.zone });
|
|
||||||
}
|
|
||||||
|
|
||||||
props.setNextDisabled(false);
|
props.setNextDisabled(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue