From 7b6a2bfa11d734fb44bd13ce4eeae53739d1d73f Mon Sep 17 00:00:00 2001 From: John Wu <76966357+jwu-fisker@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:26:41 -0800 Subject: [PATCH] CEC-3751, CEC-3478 misc window status and invalid location value (#287) * CEC-3751 misc window status CEC-3478 invalid location value * Fix snapshot Update browser list --- package-lock.json | 12 ++++---- .../DigitalTwinTab.test.jsx.snap | 2 +- src/components/DigitalTwin/index.js | 28 ++++++++----------- src/utils/locations.js | 3 ++ 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index a598d52..176b24a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6941,9 +6941,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001387", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001387.tgz", - "integrity": "sha512-fKDH0F1KOJvR+mWSOvhj8lVRr/Q/mc5u5nabU2vi1/sgvlSqEsE8dOq0Hy/BqVbDkCYQPRRHB1WRjW6PGB/7PA==", + "version": "1.0.30001458", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz", + "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==", "funding": [ { "type": "opencollective", @@ -22881,9 +22881,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001387", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001387.tgz", - "integrity": "sha512-fKDH0F1KOJvR+mWSOvhj8lVRr/Q/mc5u5nabU2vi1/sgvlSqEsE8dOq0Hy/BqVbDkCYQPRRHB1WRjW6PGB/7PA==" + "version": "1.0.30001458", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz", + "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==" }, "case-sensitive-paths-webpack-plugin": { "version": "2.4.0", diff --git a/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap b/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap index 0858fd3..b3bbeb4 100644 --- a/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap +++ b/src/components/Cars/Status/__snapshots__/DigitalTwinTab.test.jsx.snap @@ -123,7 +123,7 @@ exports[`DigitalTwinTab Render 1`] = ` sunroof : - closed + closed (0)

(value ? "open" : "closed"); const mapOpenCloseState = (value) => keyValueTemplate(value[0], openCloseState(value[1])); +const windowState = (value) => { + if (value[1] === 0 || value[1] > 100) { + return keyValueTemplate(value[0], `closed (${value[1]})`); + } else { + return keyValueTemplate(value[0], `${value[1]}% open`); + } +} + const DigitalTwin = (props) => { const classes = useStyles(); const { battery, doors, location, trex_version, ip, updated, windows, misc_windows, sunroof, dbc_version, door_locks } = props; @@ -45,12 +53,7 @@ const DigitalTwin = (props) => {

Windows

{Object.entries(windows).map((value) => { - if (value[1] === 0) { - return keyValueTemplate(value[0], "closed"); - } else { - const percentOpen = Math.min(value[1], 100); - return keyValueTemplate(value[0], `${percentOpen}% open`); - } + return windowState(value); })}
)} @@ -58,11 +61,7 @@ const DigitalTwin = (props) => {

Misc Windows

{Object.entries(misc_windows).map((value) => { - if (value[1] === 0 || value[1] > 100) { - return keyValueTemplate(value[0], `closed ${value[1]}%`); - } else { - return keyValueTemplate(value[0], `${value[1]}% open`); - } + return windowState(value); })}
)} @@ -70,12 +69,7 @@ const DigitalTwin = (props) => {

Sunroof

{Object.entries(sunroof).map((value) => { - if (value[1] === 0) { - return keyValueTemplate(value[0], "closed"); - } else { - const percentOpen = Math.min(value[1], 100); - return keyValueTemplate(value[0], `${percentOpen}% open`); - } + return windowState(value); })}
)} diff --git a/src/utils/locations.js b/src/utils/locations.js index a308375..f4fdaba 100644 --- a/src/utils/locations.js +++ b/src/utils/locations.js @@ -1,3 +1,5 @@ +const invalidLocation = 99999; + export const ValidateLocationData = (location) => { if (Math.abs(location.latitude) > 90 || Math.abs(location.longitude) > 180) { return false; @@ -9,6 +11,7 @@ export const ValidateLocationData = (location) => { } export const ValidateLocationByParam = (parameter, value) => { + if (invalidLocation === value) return false; switch (parameter) { case "latitude": return Math.abs(value) <= 90;