@@ -21,8 +21,10 @@ import { type PostCodeLocation } from "../model/location";
2121import { type UserRequest } from "../model/user" ;
2222import { useAtom } from "jotai" ;
2323import { useTranslation } from 'node_modules/react-i18next' ;
24+ import { useNavigate } from 'react-router' ;
2425
2526const LocationModal = ( ) => {
27+ const navigate = useNavigate ( ) ;
2628 let controller : AbortController | null = null ;
2729 const { t } = useTranslation ( ) ;
2830 const [ open , setOpen ] = useState ( false ) ;
@@ -50,7 +52,7 @@ const LocationModal = () => {
5052 controller = new AbortController ( ) ;
5153 //console.log("Submit: ",event);
5254 const requestString = JSON . stringify ( { Username : globalUserNameState , Password : '' , Latitude : latitude , Longitude : longitude , SearchRadius : searchRadius , PostCode : parseInt ( postCode ) } as UserRequest ) ;
53- const userResponse = await postLocationRadius ( globalJwtTokenState , controller , requestString ) ;
55+ const userResponse = await postLocationRadius ( navigate , globalJwtTokenState , controller , requestString ) ;
5456 controller = null ;
5557 setGlobalUserDataState ( { Latitude : userResponse . Latitude , Longitude : userResponse . Longitude , SearchRadius : userResponse . SearchRadius , PostCode : postCode . toString ( ) || 0 ,
5658 TargetDiesel : globalUserDataState . TargetDiesel , TargetE10 : globalUserDataState . TargetE10 , TargetE5 : globalUserDataState . TargetE5 } as UserDataState ) ;
@@ -71,7 +73,7 @@ const LocationModal = () => {
7173 controller . abort ( ) ;
7274 }
7375 controller = new AbortController ( ) ;
74- const locations = await fetchLocation ( globalJwtTokenState , controller , event . currentTarget . value ) ;
76+ const locations = await fetchLocation ( navigate , globalJwtTokenState , controller , event . currentTarget . value ) ;
7577 setOptions ( ! locations ? [ ] : locations ) ;
7678 controller = null ;
7779 //console.log(locations);
0 commit comments