Delete history entry after revert

This commit is contained in:
Christian Vidal Wolf
2026-04-10 09:47:35 +02:00
parent 0cf4f59937
commit 23f4b508c8
3 changed files with 135 additions and 131 deletions
+6 -2
View File
@@ -6,7 +6,7 @@ import { TopBar } from './components/TopBar';
import { ProductDescriptions } from './components/ProductDescriptions';
import { MatrixView } from './components/MatrixView';
import { EditPanel } from './components/EditPanel';
import { getAllSyncedRows, saveRowToSupabase, resetAllPendingRows, saveHistoryEntry } from './lib/supabase';
import { getAllSyncedRows, saveRowToSupabase, resetAllPendingRows, saveHistoryEntry, deleteHistoryEntry } from './lib/supabase';
import { getStoredSession, signOut, type AuthSession } from './lib/auth';
import { LoginPage } from './components/LoginPage';
import { DimensionsView } from './components/DimensionsView';
@@ -474,7 +474,7 @@ export default function App() {
<HistoryView
headers={appState.headers}
data={appState.data}
onRevert={(articleNo, revertedData) => {
onRevert={async (articleNo, revertedData, historyId) => {
// Find the row in appState.data and update it
const rowIndex = appState.data.findIndex(r => String(r[COLUMNS.ARTICLE_NO]) === articleNo);
if (rowIndex !== -1) {
@@ -494,6 +494,10 @@ export default function App() {
articleName: String(revertedData[COLUMNS.ARTICLE_NAME] || articleNo),
}
}));
// Delete the history entry after revert
if (historyId) {
await deleteHistoryEntry(String(historyId));
}
}
}}
/>