preliminary map for vehicles

This commit is contained in:
Drew Taylor
2021-07-14 10:12:59 -07:00
parent ab37cd598f
commit c0a11de056
9 changed files with 257 additions and 180 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,18 @@ 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);
}
};
return (
<VehicleContext.Provider
value={{
@@ -139,6 +151,7 @@ export const VehicleProvider = ({ children }) => {
getYears,
sendCommand,
getConnections,
getLocations,
}}
>
{children}