CEC-5432: expand bulk-action to add, remove, and move vehicles between fleets (#484)

* battery indicator

* optimistic response remove from fleet

* update api to use params

* expand add to fleet to also remove

* typo

* update to post request

* CEC-5432: remove unused deps

* update mocks for delete
This commit is contained in:
Tristan Timblin
2023-11-17 10:44:56 -08:00
committed by GitHub
parent 94ba59ea77
commit f4652b5de7
15 changed files with 239 additions and 189 deletions

View File

@@ -74,25 +74,26 @@ const fleetsAPI = {
.then(fetchRespHandler)
.catch(errorHandler),
addFleetVehicles: async (name, vehicles, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}/vehicle`, {
addFleetVehicles: async (name, payload, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}/vehicles/add`, {
method: "POST",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
body: JSON.stringify(vehicles),
body: JSON.stringify(payload),
})
.then(fetchRespHandler)
.catch(errorHandler),
deleteFleetVehicle: async (name, vehicle, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}/vehicle/${vehicle.vin}`, {
method: "DELETE",
deleteFleetVehicles: async (name, vins, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}/vehicles/delete`, {
method: "POST",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
body: JSON.stringify({ vins }),
})
.then(fetchRespHandler)
.catch(errorHandler),