Skip to content

Commit a6629af

Browse files
committed
fix: postcode
1 parent aa00483 commit a6629af

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

frontend/src/components/Main.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ export default function Main() {
152152
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
153153
body: JSON.stringify({ Longitude: globalUserDataState.Longitude, Latitude: globalUserDataState.Latitude, Radius: globalUserDataState.SearchRadius }),
154154
signal: controller?.signal
155-
}
156-
let postcode = ''
155+
}
157156
fetch('/gasstation/search/location', requestOptions2).then(myResult => myResult.json() as Promise<GasStation[]>).then(myJson => {
158157
const myResult = myJson.filter(value => value?.GasPrices?.length > 0).map(value => {
159-
postcode = value.PostCode;
160158
return value;
161159
}).map(value => ({
162160
location: value.Place + ' ' + value.Brand + ' ' + value.Street + ' ' + value.HouseNumber, e5: value.GasPrices[0].E5,
@@ -167,7 +165,8 @@ export default function Main() {
167165
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${jwtToken}` },
168166
signal: controller?.signal
169167
}
170-
fetch(`/gasprice/avgs/${postcode}`, requestOptions3).then(myResult => myResult.json() as Promise<GasPriceAvgs>).then(myJson => {
168+
const myPostcode = formatPostCode(globalUserDataState.PostCode);
169+
fetch(`/gasprice/avgs/${myPostcode}`, requestOptions3).then(myResult => myResult.json() as Promise<GasPriceAvgs>).then(myJson => {
171170
const rowCounty = ({
172171
location: myJson.County, e5: Math.round(myJson.CountyAvgE5), e10: Math.round(myJson.CountyAvgE10), diesel: Math.round(myJson.CountyAvgDiesel), date: new Date(), longitude: 0, latitude: 0
173172
} as TableDataRow);

0 commit comments

Comments
 (0)