From 0cf4f599374498922eaec75edd43e2522156f8d9 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Fri, 10 Apr 2026 09:42:04 +0200 Subject: [PATCH] Warn when reverting to original state (no actual changes) --- src/App.tsx | 1 + src/components/HistoryView.tsx | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 653b311..0bbadb7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -473,6 +473,7 @@ export default function App() { {activeModule === 'history' && ( { // Find the row in appState.data and update it const rowIndex = appState.data.findIndex(r => String(r[COLUMNS.ARTICLE_NO]) === articleNo); diff --git a/src/components/HistoryView.tsx b/src/components/HistoryView.tsx index 9f9294f..6342582 100644 --- a/src/components/HistoryView.tsx +++ b/src/components/HistoryView.tsx @@ -6,10 +6,11 @@ import { cn } from '../lib/utils'; interface HistoryViewProps { headers: string[]; + data: ExcelRow[]; onRevert: (articleNo: string, oldData: ExcelRow) => void; } -export function HistoryView({ headers, onRevert }: HistoryViewProps) { +export function HistoryView({ headers, data, onRevert }: HistoryViewProps) { const [history, setHistory] = useState([]); const [loading, setLoading] = useState(true); const [expandedId, setExpandedId] = useState(null); @@ -157,7 +158,15 @@ export function HistoryView({ headers, onRevert }: HistoryViewProps) { onClick={(e) => { e.stopPropagation(); if (window.confirm(`Are you sure you want to revert changes for ${entry.article_name}?`)) { - onRevert(entry.product_id, entry.old_data); + // Check if old_data equals current data in appState + const currentRow = data.find(r => String(r[0]) === entry.product_id); + if (currentRow && JSON.stringify(currentRow) === JSON.stringify(entry.old_data)) { + if (window.confirm("Reverting will restore original data. No actual changes will be made. Continue?")) { + onRevert(entry.product_id, entry.old_data); + } + } else { + onRevert(entry.product_id, entry.old_data); + } } }} className="flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-orange-500/10 text-orange-400 hover:bg-orange-500/20 transition-colors border border-orange-500/20"