This commit is contained in:
John Wu
2022-09-27 10:29:09 -07:00
committed by GitHub
parent 39ccee54be
commit b622e42286
8 changed files with 140 additions and 33 deletions

View File

@@ -22,6 +22,10 @@ const updatesAPI = {
getCarUpdateProgress: async (carupdateids, token) => {
return { statuses: [] };
},
cancelCarUpdate: async (id, token) => {
return { message: "OK" };
},
};
export default updatesAPI;

View File

@@ -8,17 +8,18 @@ import {
const API_ENDPOINT = process.env.REACT_APP_UPLOAD_SERVICE_URL;
const createDeployUpdatesClosure = (suffix) => {
return async (data, token) => fetch(`${API_ENDPOINT}/${suffix}`, {
method: "POST",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
body: JSON.stringify(data),
})
.then(fetchRespHandler)
.catch(errorHandler)
}
return async (data, token) =>
fetch(`${API_ENDPOINT}/${suffix}`, {
method: "POST",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
body: JSON.stringify(data),
})
.then(fetchRespHandler)
.catch(errorHandler);
};
const updatesAPI = {
createFleetUpdates: createDeployUpdatesClosure("fleetupdate"),
@@ -76,6 +77,18 @@ const updatesAPI = {
.then(fetchRespHandler)
.catch(errorHandler);
},
cancelCarUpdate: async (id, token) => {
return fetch(`${API_ENDPOINT}/carupdate/${id}/cancel`, {
method: "POST",
headers: Object.assign(
{ "Content-Type": "application/json" },
getAuthHeaderOptions(token)
),
})
.then(fetchRespHandler)
.catch(errorHandler);
},
};
export default updatesAPI;