From c5a3529205d1cc06032cd33045935809ee17a31c Mon Sep 17 00:00:00 2001 From: Friedjoff Trautwein Date: Mon, 23 Mar 2020 15:49:01 +0100 Subject: [PATCH] fix: select first forest type if only one is provided --- src/components/ForestTypeModal.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/ForestTypeModal.js b/src/components/ForestTypeModal.js index 675b5979..2cb96095 100644 --- a/src/components/ForestTypeModal.js +++ b/src/components/ForestTypeModal.js @@ -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 ( - 0}> + 1}> {t('forestType.select')} - {forestTypes.map(f => ( + {forestTypes.map((f) => (