Development (#67)

* preliminary map for vehicles

* weird zoom bug

* passing react tests

* fixing warnings and updating snapshots

* update node environment to 14

* addressing comments by changing variable types and adding styles to home page title

* adding CODEOWNERS file

* fixing token error
This commit is contained in:
Drew Taylor
2021-08-03 16:34:37 -07:00
committed by GitHub
parent df50ef79b9
commit 0f377d5467
31 changed files with 1120 additions and 508 deletions

View File

@@ -103,7 +103,7 @@ export const VehicleProvider = ({ children }) => {
const result = await api.getConnections(vins, token);
if (result.error) {
throw new Error(`Get connections error. ${result.message}`);
throw new Error(`Add connections error. ${result.message}`);
}
cars.forEach((car) => {
car.connected = result[car.vin] || false;
@@ -125,6 +125,30 @@ export const VehicleProvider = ({ children }) => {
}
};
const getLocations = async (token) => {
try {
setBusy(true);
const result = await api.getLocations(token);
if (result.error)
throw new Error(`Get locations error. ${result.message}`);
return result;
} finally {
setBusy(false);
}
};
const getState = async (token, vin) => {
try {
setBusy(true);
const result = await api.getState(token, vin);
if (result.error)
throw new Error(`Get state error. ${result.message}`);
return result;
} finally {
setBusy(false);
}
};
return (
<VehicleContext.Provider
value={{
@@ -139,6 +163,8 @@ export const VehicleProvider = ({ children }) => {
getYears,
sendCommand,
getConnections,
getLocations,
getState,
}}
>
{children}