changed delete confirmation
This commit is contained in:
@@ -73,6 +73,7 @@
|
|||||||
},
|
},
|
||||||
"loading": "Lade Verträge…",
|
"loading": "Lade Verträge…",
|
||||||
"empty": "Keine Verträge gefunden.",
|
"empty": "Keine Verträge gefunden.",
|
||||||
|
"deleteTitle": "Vertrag löschen",
|
||||||
"deleteConfirm": "Vertrag \"{{title}}\" wirklich löschen?",
|
"deleteConfirm": "Vertrag \"{{title}}\" wirklich löschen?",
|
||||||
"details": "Details anzeigen",
|
"details": "Details anzeigen",
|
||||||
"edit": "Bearbeiten",
|
"edit": "Bearbeiten",
|
||||||
|
|||||||
@@ -73,6 +73,7 @@
|
|||||||
},
|
},
|
||||||
"loading": "Loading contracts…",
|
"loading": "Loading contracts…",
|
||||||
"empty": "No contracts found.",
|
"empty": "No contracts found.",
|
||||||
|
"deleteTitle": "Delete contract",
|
||||||
"deleteConfirm": "Do you really want to delete \"{{title}}\"?",
|
"deleteConfirm": "Do you really want to delete \"{{title}}\"?",
|
||||||
"details": "Show details",
|
"details": "Show details",
|
||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Chip,
|
Chip,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogContentText,
|
||||||
|
DialogTitle,
|
||||||
IconButton,
|
IconButton,
|
||||||
InputAdornment,
|
InputAdornment,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
@@ -35,6 +40,7 @@ export default function ContractsList() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { showMessage } = useSnackbar();
|
const { showMessage } = useSnackbar();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [contractToDelete, setContractToDelete] = useState<Contract | null>(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: contracts,
|
data: contracts,
|
||||||
@@ -87,10 +93,10 @@ export default function ContractsList() {
|
|||||||
onError: (error: Error) => showMessage(error.message ?? t("contracts.deleteError"), "error")
|
onError: (error: Error) => showMessage(error.message ?? t("contracts.deleteError"), "error")
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleDelete = (contract: Contract) => {
|
const handleDeleteConfirm = () => {
|
||||||
if (window.confirm(t("contracts.deleteConfirm", { title: contract.title }))) {
|
if (!contractToDelete) return;
|
||||||
deleteMutation.mutate(contract.id);
|
deleteMutation.mutate(contractToDelete.id);
|
||||||
}
|
setContractToDelete(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -204,7 +210,7 @@ export default function ContractsList() {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip title={t("actions.delete")}>
|
<Tooltip title={t("actions.delete")}>
|
||||||
<IconButton color="error" onClick={() => handleDelete(contract)}>
|
<IconButton color="error" onClick={() => setContractToDelete(contract)}>
|
||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -214,6 +220,30 @@ export default function ContractsList() {
|
|||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
open={Boolean(contractToDelete)}
|
||||||
|
onClose={() => setContractToDelete(null)}
|
||||||
|
aria-labelledby="delete-contract-title"
|
||||||
|
>
|
||||||
|
<DialogTitle id="delete-contract-title">{t("contracts.deleteTitle")}</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText>
|
||||||
|
{t("contracts.deleteConfirm", { title: contractToDelete?.title ?? "" })}
|
||||||
|
</DialogContentText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={() => setContractToDelete(null)}>{t("actions.cancel")}</Button>
|
||||||
|
<Button
|
||||||
|
color="error"
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleDeleteConfirm}
|
||||||
|
disabled={deleteMutation.isPending}
|
||||||
|
>
|
||||||
|
{t("actions.delete")}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user