CEC-4498 update fleetsAPI.addFleetVehicle to send vehicle in an array (#351)

* CEC-4498 update fleet-vehicle-add api to take an array of vehicles
This commit is contained in:
Tristan Timblin
2023-06-12 22:41:55 -04:00
committed by GitHub
parent a5f32151b2
commit f74c717377
11 changed files with 1078 additions and 646 deletions

View File

@@ -122,14 +122,17 @@ export const FleetProvider = ({ children }) => {
}
};
const addFleetVehicle = async (name, vehicle, token) => {
const addFleetVehicles = async (name, vehicles, token) => {
try {
setBusy(true);
validateFleetName(name);
validateVIN(vehicle.vin);
const result = await api.addFleetVehicle(name, vehicle, token);
for (const vin of vehicles.vins) {
validateVIN(vin);
}
const result = await api.addFleetVehicles(name, vehicles, token);
if (result.error) {
throw new Error(`Add fleet vehicle error. ${result.message}`);
}
@@ -250,7 +253,7 @@ export const FleetProvider = ({ children }) => {
fleetVehicles,
totalFleetVehicles,
getFleetVehicles,
addFleetVehicle,
addFleetVehicles,
deleteFleetVehicle,
fleetCANFilters,