CEC-5443 - Ability to add Flashpack/ECU mappings

This commit is contained in:
padamsen_fisker
2023-11-30 10:59:31 -05:00
parent f4652b5de7
commit 076b7ab7b5
8 changed files with 590 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ export const VehicleProvider = ({ children }) => {
const [totalFleets, setTotalFleets] = useState(0);
const [models, setModels] = useState([]);
const [years, setYears] = useState([]);
const [flashpacks, setFlashpacks] = useState([]);
const [totalFlashpacks, setTotalFlashpacks] = useState(0);
const addConnections = async (cars, token) => {
try {
@@ -287,6 +289,26 @@ export const VehicleProvider = ({ children }) => {
}
};
const getAllFlashpacks = async (options, token) => {
let result;
try {
setBusy(true);
result = await api.getAllFlashpacks(options, token);
if (result.error)
throw new Error(`Get all flashpacks error. ${result.message}`);
setFlashpacks(result.data);
if (options && options.offset === 0 && result.total) {
setTotalFlashpacks(result.total);
}
} finally {
setBusy(false);
}
return result;
};
return (
<VehicleContext.Provider
value={{
@@ -316,6 +338,12 @@ export const VehicleProvider = ({ children }) => {
getVersionLog,
uploadConfig,
addTags,
flashpacks,
totalFlashpacks,
getAllFlashpacks,
// getFlashpackECUMappings,
// addFlashpackECUMapping,
// deleteFlashpackECUMapping,
}}
>
{children}