CEC-1183/CEC-1201 fleet vehicles forms (#130)

* working fleet vehicles forms

* snapshots and api tests
This commit is contained in:
Drew Taylor
2022-03-22 14:15:49 -07:00
committed by GitHub
parent 4daf171b1e
commit 4af3c70ec7
24 changed files with 2112 additions and 41 deletions

View File

@@ -44,6 +44,34 @@ const fleetsAPI = {
getAuthHeaderOptions(token)
)
}).then(fetchRespHandler),
getFleetVehicles: async (name, search, token) =>
fetch(addQueryParams(`${API_ENDPOINT}/fleet/${name}/vehicles`, search), {
method: "GET",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
)
}).then(fetchRespHandler),
addFleetVehicle: async (name, vehicle, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}/vehicle`, {
method: "POST",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
body: JSON.stringify(vehicle)
}).then(fetchRespHandler),
deleteFleetVehicle: async (name, vehicle, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}/vehicle/${vehicle.vin}`, {
method: "DELETE",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
)
}).then(fetchRespHandler),
};
export default fleetsAPI;