fix(web): handle delete failure in confirm dialog (no unhandled rejection)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-04 01:04:58 +02:00
parent 5087e34280
commit eedeb179e3
+14
View File
@@ -20,9 +20,18 @@ export function DeleteObjectDialog({ id }: { id: string }) {
const navigate = useNavigate();
const del = useDeleteObject();
const [open, setOpen] = useState(false);
const [error, setError] = useState(false);
const onConfirm = async () => {
setError(false);
try {
await del.mutateAsync(id);
} catch {
// Keep the dialog open so the user can retry or cancel; never let the
// rejected mutation escape as an unhandled promise rejection.
setError(true);
return;
}
navigate("/objects");
};
@@ -39,6 +48,11 @@ export function DeleteObjectDialog({ id }: { id: string }) {
<AlertDialogContent>
<AlertDialogTitle>{t("actions.delete")}</AlertDialogTitle>
<AlertDialogDescription>{t("actions.confirmDelete")}</AlertDialogDescription>
{error && (
<p role="alert" className="text-sm text-red-600">
{t("form.rejected")}
</p>
)}
<AlertDialogFooter>
<AlertDialogCancel>{t("form.cancel")}</AlertDialogCancel>
<AlertDialogAction onClick={onConfirm}>