diff --git a/src/components/LocationResult.js b/src/components/LocationResult.js index f15029fa..50a1bb1f 100644 --- a/src/components/LocationResult.js +++ b/src/components/LocationResult.js @@ -1,7 +1,7 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; -import { useHistory, useLocation } from 'react-router-dom'; +import { useHistory } from 'react-router-dom'; import { Form, Header, Message } from 'semantic-ui-react'; // eslint-disable-next-line import/no-unresolved import { info } from 'lib/src'; @@ -27,10 +27,9 @@ function LocationResult() { })); const history = useHistory(); - const { search } = useLocation(); - const selectForestType = (forestType) => { - dispatch(setFormLocation({ forestType })); - history.push(`/projection${search}`); + const selectForestType = async (forestType) => { + await dispatch(setFormLocation({ forestType })); + history.push(`/projection${history.location.search}`); }; const hasMainGroup = !formLocation.groups || formLocation.groups.includes('main'); diff --git a/src/store/reducers.js b/src/store/reducers.js index 45ed7b62..a29d0620 100644 --- a/src/store/reducers.js +++ b/src/store/reducers.js @@ -62,7 +62,8 @@ function tree(state = initialState, action) { case SET_MAP_LAYER: return { ...state, mapLayer: action.mapLayer }; case SET_MAP_LOCATION: { - return { ...state, mapLocation: action.mapLocation, projectionMode: 'm' }; + const mapLocation = { ...state.mapLocation, ...action.mapLocation }; + return { ...state, mapLocation, projectionMode: 'm' }; } case SET_MAP_VIEW: return { ...state, mapView: action.mapView };