CEC-5432: add additional options (#486)

* CEC-5432: add additional options

* fix missing dep
This commit is contained in:
Tristan Timblin
2023-11-29 16:36:18 -08:00
committed by GitHub
parent f4652b5de7
commit 5ad467b116
6 changed files with 256 additions and 40 deletions

View File

@@ -82,20 +82,36 @@ const fleetsAPI = {
return { data: vehicles };
},
addFleetVehicles: async (_name, payload) => {
payload.vins && vehicles.push(...payload.vins.map((vin => ({
const index = fleets.findIndex((fleet) => fleet.name === _name);
if (!payload.vins || index === -1) {
return;
}
vehicles.push(...payload.vins.map((vin => ({
vin,
connected: false,
connectedHMI: false,
trex_version: "",
}))));
fleets[index].vehicles.push(...payload.vins);
return payload;
},
deleteFleetVehicles: async (_name, vins) => {
const index = fleets.findIndex((fleet) => fleet.name === _name);
if (!vins || index === -1) {
return;
}
for (let i = 0; i < vins; i++) {
const vin = vins[i];
const index = vehicles.findIndex(element => element.vin === vin);
if (index >= 0) vehicles.splice(index, 1);
fleets[index].vehicles = fleets[index].vehicles.filter((vin) => !vins.includes(vin))
}
return { message: "Deleted" };
},