Skip to content

Commit b97e635

Browse files
committed
fix: worker
1 parent 296a2e6 commit b97e635

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

frontend/app/login/login.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ export function Login() {
6464
const [password2, setPassword2] = useState('');
6565
const [responseMsg, setResponseMsg] = useState('');
6666
const [activeTab, setActiveTab] = useState(0);
67-
68-
const navToApp = () => {
69-
navigate("/app/app");
70-
}
7167

7268
const handleChangeUsername: ChangeEventHandler<HTMLInputElement> = (event) => {
7369
setUserName(event.currentTarget.value as string);
@@ -249,8 +245,7 @@ export function Login() {
249245
)}
250246
</div>
251247
</Box>
252-
</TabPanel>
253-
<Button onClick={navToApp}>Test</Button>
248+
</TabPanel>
254249
</DialogContent>
255250
</Dialog>);
256251
}

frontend/app/service/http-client.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ import { type TimeSlotResponse } from "../model/time-slot-response";
1818
import { type UserRequest, type UserResponse } from "../model/user";
1919
import { type Notification } from "../model/notification";
2020

21+
const apiPrefix = '/api';
22+
2123
const fetchGasStations = async function (jwtToken: string, controller: AbortController | null, globalUserDataState: UserDataState): Promise<GasStation[]> {
2224
const requestOptions2 = {
2325
method: 'POST',
2426
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
2527
body: JSON.stringify({ Longitude: globalUserDataState.Longitude, Latitude: globalUserDataState.Latitude, Radius: globalUserDataState.SearchRadius }),
2628
signal: controller?.signal
2729
}
28-
const result = await fetch('/api/gasstation/search/location', requestOptions2);
30+
const result = await fetch(`${apiPrefix}/gasstation/search/location`, requestOptions2);
2931
const myResult = result.json() as Promise<GasStation[]>;
3032
return myResult;
3133
};
@@ -36,7 +38,7 @@ const fetchPriceAvgs = async function (jwtToken: string, controller: AbortContro
3638
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
3739
signal: controller?.signal
3840
}
39-
const result = await fetch(`/api/gasprice/avgs/${myPostcode}`, requestOptions3);
41+
const result = await fetch(`${apiPrefix}/gasprice/avgs/${myPostcode}`, requestOptions3);
4042
return result.json() as Promise<GasPriceAvgs>;
4143
}
4244

@@ -46,7 +48,7 @@ const fetchUserNotifications = async function (jwtToken: string, controller: Abo
4648
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
4749
signal: controller?.signal
4850
}
49-
const result = await fetch(`/api/usernotification/current/${globalUserUuidState}`, requestOptions1);
51+
const result = await fetch(`${apiPrefix}/usernotification/current/${globalUserUuidState}`, requestOptions1);
5052
return result.json() as Promise<Notification[]>;
5153
}
5254

@@ -56,20 +58,20 @@ const fetchTimeSlots = async function (jwtToken: string, controller: AbortContro
5658
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
5759
signal: controller?.signal
5860
}
59-
const result = await fetch(`/api/postcode/countytimeslots/${myPostcode}`, requestOptions2);
61+
const result = await fetch(`${apiPrefix}/postcode/countytimeslots/${myPostcode}`, requestOptions2);
6062
const myResult = result.json() as Promise<TimeSlotResponse[]>;
6163
return myResult;
6264
}
6365

6466
const postLogin = async function (userName: string, password1: string, controller: AbortController | null): Promise<UserResponse> {
6567
const requestOptions = loginSigninOptions(userName, password1, controller);
66-
const result = await fetch('/api/appuser/login', requestOptions);
68+
const result = await fetch(`${apiPrefix}/appuser/login`, requestOptions);
6769
return result.json() as Promise<UserResponse>;
6870
}
6971

7072
const postSignin = async function (userName: string, password1: string, controller: AbortController | null): Promise<UserResponse> {
7173
const requestOptions = loginSigninOptions(userName, password1, controller);
72-
const result = await fetch('/api/appuser/signin', requestOptions);
74+
const result = await fetch(`${apiPrefix}/appuser/signin`, requestOptions);
7375
return result.json() as Promise<UserResponse>;
7476
}
7577

@@ -89,7 +91,7 @@ const postLocationRadius = async function (jwtToken: string, controller: AbortCo
8991
body: requestString,
9092
signal: controller?.signal
9193
};
92-
const response = await fetch('/api/appuser/locationradius', requestOptions);
94+
const response = await fetch(`${apiPrefix}/appuser/locationradius`, requestOptions);
9395
const userResponse = response.json() as UserResponse;
9496
return userResponse;
9597
}
@@ -100,7 +102,7 @@ const fetchLocation = async function (jwtToken: string, controller: AbortControl
100102
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
101103
signal: controller?.signal
102104
};
103-
const response = await fetch(`/api/appuser/location?location=${location}`, requestOptions);
105+
const response = await fetch(`${apiPrefix}/appuser/location?location=${location}`, requestOptions);
104106
const locations = response.json() as Promise<PostCodeLocation[]>;
105107
return locations;
106108
}
@@ -112,7 +114,7 @@ const postTargetPrices = async function (jwtToken: string, controller: AbortCont
112114
body: requestString,
113115
signal: controller?.signal
114116
};
115-
const response = await fetch('/api/appuser/targetprices', requestOptions);
117+
const response = await fetch(`${apiPrefix}/appuser/targetprices`, requestOptions);
116118
const result = response.json() as Promise<UserResponse>;
117119
return result;
118120
}

frontend/app/webpush/dedicated-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const refreshToken = (myToken) => {
1111
method: 'GET',
1212
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
1313
};
14-
fetch('/appuser/refreshtoken', requestOptions).then(response => response.json()).then(result => {
14+
fetch('/api/appuser/refreshtoken', requestOptions).then(response => response.json()).then(result => {
1515
if ((!result.Message && !!result.Token && result.Token.length > 10)) {
1616
//console.log('Token refreshed.');
1717
jwtToken = result.Token;

frontend/app/webpush/dedicated-worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const refreshToken = (myToken: string) => {
3838
method: 'GET',
3939
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
4040
};
41-
fetch('/appuser/refreshtoken', requestOptions).then(response => response.json() as UserResponse).then(result => {
41+
fetch('/api/appuser/refreshtoken', requestOptions).then(response => response.json() as UserResponse).then(result => {
4242
if ((!result.Message && !!result.Token && result.Token.length > 10)) {
4343
//console.log('Token refreshed.');
4444
jwtToken = result.Token;

0 commit comments

Comments
 (0)