Skip to content

Commit dfb7d0f

Browse files
committed
feat: add error routing
1 parent 604720e commit dfb7d0f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frontend/app/location-modal/location-modal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import { type PostCodeLocation } from "../model/location";
2121
import { type UserRequest } from "../model/user";
2222
import { useAtom } from "jotai";
2323
import { useTranslation } from 'node_modules/react-i18next';
24+
import { useNavigate } from 'react-router';
2425

2526
const 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

Comments
 (0)