From 77ed7507d4a974cff16e95b19094191e987055e0 Mon Sep 17 00:00:00 2001 From: padamsen_fisker Date: Fri, 26 Apr 2024 17:29:19 -0400 Subject: [PATCH] CEC-6008 - Map flashpack numbers to OS numbers, and display in the UI --- src/components/Contexts/VehicleContext.jsx | 21 ++++++++- .../Add/__snapshots__/index.test.jsx.snap | 44 +++++++++++++++++++ src/components/Flashpack/Add/index.jsx | 23 +++++++++- .../__snapshots__/index.test.jsx.snap | 23 ++++++++++ src/components/Flashpack/index.jsx | 9 +++- src/services/vehiclesAPI.js | 11 +++++ 6 files changed, 128 insertions(+), 3 deletions(-) diff --git a/src/components/Contexts/VehicleContext.jsx b/src/components/Contexts/VehicleContext.jsx index ef6b781..4f7d004 100644 --- a/src/components/Contexts/VehicleContext.jsx +++ b/src/components/Contexts/VehicleContext.jsx @@ -34,6 +34,7 @@ export const VehicleProvider = ({ children }) => { const [totalFlashpacks, setTotalFlashpacks] = useState(0); const [flashpackECUMappings, setFlashpackECUMappings] = useState([]) const [totalFlashpackECUMappings, setTotalFlashpackECUMappings] = useState(0) + const [osVersions, setOSVersions] = useState([]) const addConnections = async (cars, token) => { try { @@ -331,7 +332,7 @@ export const VehicleProvider = ({ children }) => { } }; - const addFlashpackVersion = async (model, trim, year, flashpack, carFlashpackVersions, token) => { + const addFlashpackVersion = async (model, trim, year, flashpack, osVersion, carFlashpackVersions, token) => { try { setBusy(true); @@ -340,6 +341,7 @@ export const VehicleProvider = ({ children }) => { "car_trim": trim, "car_year": year, "flashpack": flashpack, + "os_version": osVersions, "ecu_versions": carFlashpackVersions, } @@ -424,6 +426,21 @@ export const VehicleProvider = ({ children }) => { } finally { setBusy(false); } + }; + + const getOSVersions = async (token) => { + try { + setBusy(true); + + const result = await api.getOSVersions(token); + if (result.error) { + throw new Error(`Get OS versions error. ${result.message}`); + } + + setOSVersions(result.data); + } finally { + setBusy(false); + } } return ( @@ -466,6 +483,8 @@ export const VehicleProvider = ({ children }) => { deleteFlashpackVersion, deleteFlashpackVersionECUMapping, getCarFlashpackVersionInfo, + osVersions, + getOSVersions, }} > {children} diff --git a/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap b/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap index c704ada..c2930c8 100644 --- a/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap +++ b/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap @@ -244,6 +244,50 @@ exports[`FlashpackAdd Render 1`] = ` +
+ +
+