DeleteProject component
This commit is contained in:
parent
3ed4393c77
commit
b50d88f670
1 changed files with 33 additions and 0 deletions
33
frontend/src/Components/DeleteProject.tsx
Normal file
33
frontend/src/Components/DeleteProject.tsx
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import { api, APIResponse } from "../API/API";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to delete a project from the system
|
||||||
|
* @param {string} props.projectToDelete - The projectname of project to delete
|
||||||
|
* @returns {void} Nothing
|
||||||
|
* @example
|
||||||
|
* const exampleProjectName = "project";
|
||||||
|
* DeleteProject({ projectToDelete: exampleProjectName });
|
||||||
|
*/
|
||||||
|
|
||||||
|
function DeleteProject(props: { projectToDelete: string }): void {
|
||||||
|
api
|
||||||
|
.removeProject(
|
||||||
|
props.projectToDelete,
|
||||||
|
localStorage.getItem("accessToken") ?? "",
|
||||||
|
)
|
||||||
|
.then((response: APIResponse<string>) => {
|
||||||
|
if (response.success) {
|
||||||
|
alert("Project has been deleted!");
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
|
alert("Project has not been deleted");
|
||||||
|
console.error(response.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
alert("project has not been deleted");
|
||||||
|
console.error("An error occurred during deletion:", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DeleteProject;
|
Loading…
Add table
Reference in a new issue