preliminary map for vehicles
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user