Skip to content

Commit

Permalink
fix: select first forest type if only one is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
friedjoff committed Mar 26, 2020
1 parent 59763b3 commit c5a3529
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/ForestTypeModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ function ForestTypeModal() {
const { search } = useLocation();
const { t } = useTranslation();
const dispatch = useDispatch();
const forestTypes = useSelector(state => state.forestTypes);
const selectForestType = forestType => {
const forestTypes = useSelector((state) => state.forestTypes);
const selectForestType = (forestType) => {
dispatch(setForestTypes([]));
dispatch(setFormLocation({ forestType }));
history.push(`/projection${search}`);
};

if (forestTypes.length === 1) {
selectForestType(forestTypes[0]);
}

return (
<Modal open={forestTypes.length > 0}>
<Modal open={forestTypes.length > 1}>
<Modal.Header>{t('forestType.select')}</Modal.Header>
<Modal.Content>
<Modal.Description>
{forestTypes.map(f => (
{forestTypes.map((f) => (
<Button active onClick={() => selectForestType(f)}>
{f}
</Button>
Expand Down

0 comments on commit c5a3529

Please sign in to comment.