diff --git a/src/components/Contexts/VehicleContext.jsx b/src/components/Contexts/VehicleContext.jsx index ef6b781..9ef9827 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([{ "value": "", "label": "None" }]) 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": osVersion, "ecu_versions": carFlashpackVersions, } @@ -424,6 +426,30 @@ 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}`); + } + + var data = [{ "value": "", "label": "None" }] + + for (let i = 0; i < result.data.length; i++) { + data.push({ + "value": result.data[i], + "label": result.data[i] + }); + } + + setOSVersions(data); + } finally { + setBusy(false); + } } return ( @@ -466,6 +492,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..52b7415 100644 --- a/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap +++ b/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap @@ -91,11 +91,6 @@ exports[`FlashpackAdd Render 1`] = ` class="MuiSelect-root MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input" required="" > -