From 404f60d278c944ad47a63f733cb4accadb0f8ca2 Mon Sep 17 00:00:00 2001 From: das31 <31259710+das31@users.noreply.github.com> Date: Thu, 12 Jan 2023 21:02:48 -0500 Subject: [PATCH] CEC-1711-fix-digital-twin (#257) * first commit * remove comments * resolve comments: * update snapshot --- .../DigitalTwinTab.test.jsx.snap | 35 ++++++++++++++++ src/components/DigitalTwin/index.js | 40 ++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap b/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap index 7340395..a22fa67 100644 --- a/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap +++ b/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap @@ -91,6 +91,41 @@ exports[`DigitalTwinTab Render 1`] = ` closed

+
+

+ Door Locks +

+

+ + driver + + : + Closed +

+

+ + all + + : + Locked +

+
+
+

+ Sunroof +

+

+ + sunroof + + : + closed +

+
diff --git a/src/components/DigitalTwin/index.js b/src/components/DigitalTwin/index.js index 8129ce9..20acbfe 100644 --- a/src/components/DigitalTwin/index.js +++ b/src/components/DigitalTwin/index.js @@ -14,7 +14,7 @@ const mapOpenCloseState = (value) => const DigitalTwin = (props) => { const classes = useStyles(); - const { battery, doors, location, trex_version, ip, updated, windows } = props; + const { battery, doors, location, trex_version, ip, updated, windows, sunroof, dbc, door_locks } = props; return (
@@ -28,10 +28,41 @@ const DigitalTwin = (props) => { {Object.entries(doors).map(mapOpenCloseState)}
)} + {door_locks != null && ( +
+

Door Locks

+ {Object.entries(door_locks).map((value) => { + if (value[0] === "driver") { + return keyValueTemplate(value[0], value[1] ? "Open" : "Closed"); + } else { + return keyValueTemplate(value[0], value[1] ?"Unlocked" : "Locked" ); + } + })} +
+ )} {windows != null && (

Windows

- {Object.entries(windows).map(mapOpenCloseState)} + {Object.entries(windows).map((value) => { + if (value[1] === 0) { + return keyValueTemplate(value[0], "closed"); + } else { + return keyValueTemplate(value[0], `${value[1]}% open`); + } + })} +
+ )} + {sunroof != null && ( +
+

Sunroof

+ {/* {Object.entries(sunroof).map(mapOpenCloseState)} */} + {Object.entries(sunroof).map((value) => { + if (value[1] === 0) { + return keyValueTemplate(value[0], "closed"); + } else { + return keyValueTemplate(value[0], `${value[1]}% open`); + } + })}
)} {location != null && ( @@ -61,6 +92,11 @@ const DigitalTwin = (props) => { {keyValueTemplate("Updated at", LocalDateTimeString(updated))}
)} + {dbc != null && ( +
+ {keyValueTemplate("DBC version", dbc)} +
+ )} ); };