Co-authored-by: al8763be <al8763be@users.noreply.github.com>

This commit is contained in:
Alexander Ek 2024-03-27 21:18:44 +01:00
parent e1b410c850
commit d4cc556366
8 changed files with 155 additions and 4 deletions

View file

@ -133,6 +133,11 @@ interface API {
projectName: string,
token: string,
): Promise<APIResponse<UserProjectMember[]>>;
removeProject(
projectName: string,
token: string,
): Promise<APIResponse<string>>;
}
/** An instance of the API */
@ -484,4 +489,34 @@ export const api: API = {
});
}
},
async removeProject(
projectName: string,
token: string,
): Promise<APIResponse<string>> {
try {
const response = await fetch(`/api/projectdelete/${projectName}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
},
});
if (!response.ok) {
return Promise.resolve({
success: false,
message: "Failed to remove project",
});
} else {
const data = await response.text();
return Promise.resolve({ success: true, message: data });
}
} catch (e) {
return Promise.resolve({
success: false,
message: "Failed to remove project",
});
}
},
};