From fc7c1ea514df9e66ab0a749212351f0d0e039993 Mon Sep 17 00:00:00 2001 From: Eduard Voronkin <116690094+eduardvoronkin@users.noreply.github.com> Date: Fri, 23 Jun 2023 12:38:09 -0700 Subject: [PATCH] CEC-4517 reset TBOX remote command (#369) * CEC-4517 Diagnostic Commands tab * snapshot --- .../App/__snapshots__/App.test.js.snap | 27 +++- .../Cars/Status/RemoteDiagnosticCommands.jsx | 30 +++++ .../Status/__snapshots__/index.test.jsx.snap | 27 +++- src/components/Cars/Status/index.jsx | 6 + src/components/Contexts/VehicleContext.jsx | 15 ++- .../Controls/SendDiagnosticCommand/index.jsx | 119 ++++++++++++++++++ src/services/vehiclesAPI.js | 15 +++ 7 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 src/components/Cars/Status/RemoteDiagnosticCommands.jsx create mode 100644 src/components/Controls/SendDiagnosticCommand/index.jsx diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index 5a5eea9..8dc8aac 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -11242,7 +11242,7 @@ exports[`App Route /vehicle-status authenticated 1`] = ` - Fleets + Remote Diagnostic Commands + + Fleets + + + + + +
+ + {carState && carState.online ? "ONLINE" : "OFFLINE"} + +
+ + ); +}; + +export default SendDiagnosticCommand; diff --git a/src/services/vehiclesAPI.js b/src/services/vehiclesAPI.js index 3f2a5c2..17736d9 100644 --- a/src/services/vehiclesAPI.js +++ b/src/services/vehiclesAPI.js @@ -173,6 +173,21 @@ const vehiclesAPI = { .then(fetchRespHandler) .catch(errorHandler), + sendDiagnosticCommand: async (vins, command, token) => + fetch(`${API_ENDPOINT}/vehiclediagnosticcommand`, { + method: "POST", + headers: Object.assign( + { "Content-Type": "application/json" }, + getAuthHeaderOptions(token) + ), + body: JSON.stringify({ + vins, + ...command, + }), + }) + .then(fetchRespHandler) + .catch(errorHandler), + updateVehicle: async (vin, vehicle, token) => fetch(`${API_ENDPOINT}/vehicle/${vin}`, { method: "PUT",