diff --git a/src/pages/TableView.jsx b/src/pages/TableView.jsx
index 66ef77f..f04129d 100644
--- a/src/pages/TableView.jsx
+++ b/src/pages/TableView.jsx
@@ -1,9 +1,9 @@
-import { useEffect, useState, useMemo } from 'react';
+import { useEffect, useState, useMemo, useCallback } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import Layout from '../components/Layout';
import RecordModal from '../components/RecordModal';
import CreateModal, { hasCreateForm } from '../components/CreateModal';
-import { fetchAll } from '../lib/api';
+import { fetchAll, apiDelete } from '../lib/api';
import { TABLES, STATUS_COLORS } from '../lib/tables';
function truncate(str, n = 60) {
@@ -88,6 +88,8 @@ export default function TableView() {
const [highlightId, setHighlightId] = useState(null);
const [modalRecord, setModalRecord] = useState(null);
const [showCreate, setShowCreate] = useState(false);
+ const [confirmDeleteId, setConfirmDeleteId] = useState(null);
+ const [deleting, setDeleting] = useState(false);
useEffect(() => {
const params = new URLSearchParams(window.location.search);
@@ -130,6 +132,21 @@ export default function TableView() {
setRows(prev => [newRecord, ...prev]);
}
+ const handleDelete = useCallback(async (id, e) => {
+ e.stopPropagation();
+ setDeleting(true);
+ try {
+ await apiDelete(meta.endpoint, id);
+ setRows(prev => prev.filter(r => r.id !== id));
+ setConfirmDeleteId(null);
+ if (modalRecord?.id === id) setModalRecord(null);
+ } catch (err) {
+ alert('Fehler beim Löschen: ' + err.message);
+ } finally {
+ setDeleting(false);
+ }
+ }, [meta, modalRecord]);
+
if (!meta) return Unbekannte Tabelle: {tableKey}