@@ -20,6 +20,7 @@ import {
2020 setCurrentMot ,
2121 showNotification ,
2222 setIsFieldFocused ,
23+ setShowLoadingBar ,
2324} from '../../store/actions/Map' ;
2425import './RoutingMenu.css' ;
2526import {
@@ -138,6 +139,7 @@ function RoutingMenu({
138139
139140 const clickLocation = useSelector ( state => state . MapReducer . clickLocation ) ;
140141 const currentStops = useSelector ( state => state . MapReducer . currentStops ) ;
142+ const showLoadingBar = useSelector ( state => state . MapReducer . showLoadingBar ) ;
141143 const currentStopsGeoJSON = useSelector (
142144 state => state . MapReducer . currentStopsGeoJSON ,
143145 ) ;
@@ -156,7 +158,6 @@ function RoutingMenu({
156158 const [ currentSearchResults , setCurrentSearchResults ] = useState ( [ ] ) ;
157159 const [ searchMotOnly , setSearchMotOnly ] = React . useState ( true ) ;
158160 const [ focusedFieldIndex , setFocusedFieldIndex ] = useState ( 0 ) ;
159- const [ showLoadingBar , setShowLoadingBar ] = useState ( false ) ;
160161 const [ currentOtherMot , setCurrentOtherMot ] = useState ( undefined ) ;
161162
162163 useEffect ( ( ) => {
@@ -352,13 +353,13 @@ function RoutingMenu({
352353 updatedCurrentStops [ fieldIndex ] = '' ;
353354 setCurrentSearchResults ( [ ] ) ;
354355 dispatch ( setCurrentStops ( updatedCurrentStops ) ) ;
355- setShowLoadingBar ( false ) ;
356+ dispatch ( setShowLoadingBar ( false ) ) ;
356357 return ;
357358 }
358359 const updatedCurrentStops = _ . clone ( currentStops ) ;
359360 updatedCurrentStops [ fieldIndex ] = event . target . value ;
360361 dispatch ( setCurrentStops ( updatedCurrentStops ) ) ;
361- setShowLoadingBar ( true ) ;
362+ dispatch ( setShowLoadingBar ( true ) ) ;
362363
363364 abortController . abort ( ) ;
364365 abortController = new AbortController ( ) ;
@@ -381,7 +382,7 @@ function RoutingMenu({
381382 dispatch ( showNotification ( "Couldn't find stations" , 'warning' ) ) ;
382383 }
383384 setCurrentSearchResults ( response . features ) ;
384- setShowLoadingBar ( false ) ;
385+ dispatch ( setShowLoadingBar ( false ) ) ;
385386 } )
386387 . catch ( err => {
387388 if ( err . name === 'AbortError' ) {
0 commit comments