CEC-3796 - UI for creating and managing RxSWIN

This commit is contained in:
pauladamseniii
2023-10-13 17:18:36 -04:00
parent 0f1886463e
commit 66706b9c3c
8 changed files with 171 additions and 3 deletions

View File

@@ -36,6 +36,7 @@ export const CarUpdatesProvider = ({ children }) => {
const [busy, setBusy] = useState(false);
const [carUpdates, setCarUpdates] = useState([]);
const [versions, setVersions] = useState([SELECT_VERSION_OBJ]);
const [versionRxSwins, setVersionRxSwins] = useState([]);
const [totalCarUpdates, setTotalCarUpdates] = useState(0);
const [delayCount, setDelayCount] = useState(0);
let progressTimer = 0;
@@ -307,6 +308,24 @@ export const CarUpdatesProvider = ({ children }) => {
return result;
};
const getSUMSVersionRxSwins = async (sums_version, token) => {
let result;
try {
setBusy(true);
result = await api.getSUMSVersionRxSwins(sums_version, token);
if (result.error)
throw new Error(`Get software version rxswins error. ${result.message}`);
setVersionRxSwins(result.data);
} finally {
setBusy(false);
}
return result;
};
return (
<CarUpdatesContext.Provider
value={{
@@ -325,6 +344,7 @@ export const CarUpdatesProvider = ({ children }) => {
startMonitor,
stopMonitor,
updateSUMSVersion,
getSUMSVersionRxSwins,
}}
>
{children}

View File

@@ -122,6 +122,19 @@ let sumsVersions = {
"data": ["2023.02.01.0.0.A", "2023.02.01.0.0.B"]
}
let sumsVersionRxSwins = {
data: [
{
version: "2023.02.01.0.0.A",
rxswin: "testrxswin1",
},
{
version: "2023.02.01.0.0.A",
rxswin: "testrxswin2",
},
]
}
export const CarUpdatesProvider = ({ children }) => {
return <div data-testid="mocked-carupdatesprovider">{children}</div>;
};
@@ -140,5 +153,6 @@ export const useCarUpdatesContext = () => ({
stopMonitor: jest.fn(),
approveUpdate: jest.fn(),
getSUMSVersions: jest.fn(() => sumsVersions),
getSUMSVersionRxSwins: jest.fn(() => sumsVersionRxSwins),
updateSUMSVersion: jest.fn(),
});