Created the Delete.jsx settings component

This commit is contained in:
Mathias Wagner 2023-08-01 22:35:15 +02:00
parent 7074bc0238
commit e32a432b7a
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -0,0 +1,29 @@
import {Box, Button, Typography} from "@mui/material";
import {Delete as DeleteIcon} from "@mui/icons-material";
import {deleteRequest} from "@/common/utils/RequestUtil.js";
import {useContext} from "react";
import {ProjectContext} from "@/states/Dashboard/contexts/Project";
export const Delete = () => {
const {currentProject, updateProjects} = useContext(ProjectContext);
const deleteProject = async () => {
try {
await deleteRequest(`/project/${currentProject.id}`);
await updateProjects();
} catch (e) {
console.error(e);
}
}
return (
<Box sx={{border: 1.5, borderColor: 'red', borderRadius: 1.5, p: 2.5, width: {xs: "100%", lg: "33%"}}}>
<Typography variant="h5" fontWeight={700}>Projekt löschen</Typography>
<Typography variant="body1" color="text.secondary" fontWeight={500}>
Diese Aktion kann nicht Rückgängig gemacht
werden. Ich hoffe du weißt, was du tust.
</Typography>
<Button variant="contained" sx={{mt: 2}} color="error" startIcon={<DeleteIcon/>} onClick={deleteProject}>Löschen</Button>
</Box>
)
}