Merge branch 'main' into CEC-5443
This commit is contained in:
@@ -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" };
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user