CEC-1058 fleet forms (#123)

* working fleets page

* unit tests

* snapshots

* updating messages and snapshots

* updating extraneous snaps
This commit is contained in:
Drew Taylor
2022-03-11 15:48:30 -08:00
committed by GitHub
parent a9c154c472
commit 34d670c101
28 changed files with 2695 additions and 50 deletions

49
src/services/fleetsAPI.js Normal file
View File

@@ -0,0 +1,49 @@
import {
getAuthHeaderOptions,
fetchRespHandler,
addQueryParams,
} from "../utils/http";
const API_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL;
const fleetsAPI = {
addFleet: async (fleet, token) =>
fetch(`${API_ENDPOINT}/fleet`, {
method: "POST",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
body: JSON.stringify(fleet)
}).then(fetchRespHandler),
getFleets: async (search, token) =>
fetch(addQueryParams(`${API_ENDPOINT}/fleets`, search), {
method: "GET",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
}).then(fetchRespHandler),
updateFleet: async (name, fleet, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}`, {
method: "PUT",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
body: JSON.stringify(fleet)
}).then(fetchRespHandler),
deleteFleet: async (name, token) =>
fetch(`${API_ENDPOINT}/fleet/${name}`, {
method: "DELETE",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
)
}).then(fetchRespHandler),
};
export default fleetsAPI;