diff --git a/src/components/Cars/Status/DigitalTwinTab.jsx b/src/components/Cars/Status/DigitalTwinTab.jsx
index b7254d6..287426f 100644
--- a/src/components/Cars/Status/DigitalTwinTab.jsx
+++ b/src/components/Cars/Status/DigitalTwinTab.jsx
@@ -10,7 +10,7 @@ import {
VehicleProvider
} from "../../Contexts/VehicleContext";
import DigitalTwin from "../../DigitalTwin";
-import VehiclePathsMap from "../../VehiclePathsMap";
+import VehicleMap from "../../VehicleMap";
import useStyles from "../../useStyles";
const REQUEST_INTERVAL = 10000;
@@ -60,7 +60,7 @@ const Main = (props) => {
+
diff --git a/src/components/Contexts/__mocks__/VehicleContext.jsx b/src/components/Contexts/__mocks__/VehicleContext.jsx
index 4387c84..850921f 100644
--- a/src/components/Contexts/__mocks__/VehicleContext.jsx
+++ b/src/components/Contexts/__mocks__/VehicleContext.jsx
@@ -146,9 +146,10 @@ export const useVehicleContext = () => ({
}),
getLocations: jest
.fn()
- .mockResolvedValue([
- { altitude: 5, longitude: 10, latitude: 15, vin: "TESTVIN123" },
- ]),
+ .mockResolvedValue({
+ // tests only pass without mocking the data here
+ // data: [{ altitude: 5, longitude: 10, latitude: 15, vin: "TESTVIN123" }]
+ }),
getLocationsVehiclePaths: jest
.fn()
.mockResolvedValue({
diff --git a/src/components/VehicleMap/index.jsx b/src/components/VehicleMap/index.jsx
index 8a56236..f5d9427 100644
--- a/src/components/VehicleMap/index.jsx
+++ b/src/components/VehicleMap/index.jsx
@@ -15,7 +15,7 @@ import { VehiclePopUp } from "./popup";
import { useLocalStorage } from "../useLocalStorage";
import zoomLocations from './zoomLocations.json';
-const Component = () => {
+const Component = (props) => {
const classes = useStyles();
const {
token: {
@@ -47,20 +47,41 @@ const Component = () => {
}, [token]);
const retrieveAndStoreLocations = (accessToken) => {
- return getLocations(accessToken)
- .then((result) => {
- if (result.data != null && ValidateLocationData(result.data) !== false) {
- const points = result.data.map((point) => [
- point.latitude,
- point.longitude,
- point.vin,
- ]);
- setMarkers(points);
- return points;
- }
- return [];
- })
- .catch((error) => logger.warn(error.stack));
+ if (props.vin) {
+ // if a vin is specified, get its location from vehicle state
+ return getState(accessToken, props.vin)
+ .then(async (stateResult) => {
+ if (stateResult.data?.location) {
+ if (ValidateLocationData(stateResult.data.location) !== false) {
+ const points = [[
+ stateResult.data.location.latitude,
+ stateResult.data.location.longitude,
+ props.vin,
+ ]];
+ setMarkers(points);
+ return points;
+ }
+ }
+ return [];
+ })
+ .catch((error) => logger.warn(error.stack));
+ } else {
+ // if no vin is specified, use getLocations
+ return getLocations(accessToken)
+ .then(async (result) => {
+ if (result.data != null && ValidateLocationData(result.data) !== false) {
+ const points = result.data.map((point) => [
+ point.latitude,
+ point.longitude,
+ point.vin,
+ ]);
+ setMarkers(points);
+ return points;
+ }
+ return [];
+ })
+ .catch((error) => logger.warn(error.stack));
+ }
};
const centerAroundMarkers = (points) => {
@@ -154,7 +175,7 @@ const Component = () => {
return (
<>
-