diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index f76157a..e5d83d8 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -7484,6 +7484,24 @@ exports[`App Route /vehicle-status authenticated 1`] = ` class="MuiTouchRipple-root" /> + +
diff --git a/src/components/Cars/Status/DigitalTwinTab.jsx b/src/components/Cars/Status/DigitalTwinTab.jsx new file mode 100644 index 0000000..de84bb1 --- /dev/null +++ b/src/components/Cars/Status/DigitalTwinTab.jsx @@ -0,0 +1,64 @@ +import React, { useEffect, useState } from "react"; +import clsx from "clsx"; +import { Typography } from "@material-ui/core"; + +import useStyles from "../../useStyles"; +import DigitalTwin from "../../DigitalTwin"; +import { + useVehicleContext, + VehicleProvider, +} from "../../Contexts/VehicleContext"; +import { useStatusContext } from "../../Contexts/StatusContext"; +import { useUserContext } from "../../Contexts/UserContext"; +import { logger } from "../../../services/monitoring"; + +const Main = (props) => { + const { getState } = useVehicleContext(); + const { + token: { + idToken: { jwtToken: token }, + }, + } = useUserContext(); + const { setMessage } = useStatusContext(); + const classes = useStyles(); + const [carState, setCarState] = useState(null); + const { vin } = props; + + useEffect(() => { + if (!vin) return; + (async () => { + try { + const result = await getState(token, vin); + setCarState(result.data); + } catch (e) { + setMessage(e.message); + logger.warn(e.stack); + } + })(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [vin]); + + return ( ++ + Battery + + : + 95% +
++ + hood + + : + closed +
++ + left_front + + : + closed +
++ + left_rear + + : + closed +
++ + right_front + + : + closed +
++ + right_rear + + : + closed +
++ + trunk + + : + closed +
++ + altitude + + : + 17 +
++ + longitude + + : + -122.414° +
++ + latitude + + : + 37.764° +
++ + Trex Version + + : + 1000000 +
++ + Updated at + + : + 7/26/2022 12:26:38 AM +
++ {key}: {value} +
+); +const openCloseState = (value) => (value ? "open" : "closed"); +const mapOpenCloseState = (value) => + keyValueTemplate(value[0], openCloseState(value[1])); + +const DigitalTwin = (props) => { + const classes = useStyles(); + const { battery, doors, location, trex_version, updated, windows } = props; + + return ( +