fix: ensure saved changes persist across app refreshes by updating status logic and merge check

This commit is contained in:
Christian Vidal Wolf
2026-05-11 11:48:11 +02:00
parent b182ef6037
commit 311d74b783
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -248,7 +248,7 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
// 2. For Master Data (indices < 100, like UVP/SRP), only restore if it's an active edit (pending) // 2. For Master Data (indices < 100, like UVP/SRP), only restore if it's an active edit (pending)
// This protects against the "Column Shift" bug where old saved indices might be wrong. // This protects against the "Column Shift" bug where old saved indices might be wrong.
if (synced?.status === 'pending') { if (synced?.status === 'pending' || synced?.status === 'edited') {
editableColumns.forEach(idx => { editableColumns.forEach(idx => {
if (idx < 100 && sourceForInternal[idx] !== undefined && sourceForInternal[idx] !== null) { if (idx < 100 && sourceForInternal[idx] !== undefined && sourceForInternal[idx] !== null) {
finalRow[idx] = sourceForInternal[idx]; finalRow[idx] = sourceForInternal[idx];
@@ -551,7 +551,10 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
if (result.success) { if (result.success) {
// Also save to history // Also save to history
await saveHistoryEntry(articleNo, articleName, originalData, newData, session?.user?.email || 'unknown'); const histRes = await saveHistoryEntry(articleNo, articleName, originalData, newData, session?.user?.email || 'unknown');
if (!histRes.success) {
console.warn(`[handleSaveAll] History save failed for ${articleNo}:`, histRes.error);
}
setRowStatuses(prev => ({ ...prev, [articleNo]: 'saved' })); setRowStatuses(prev => ({ ...prev, [articleNo]: 'saved' }));
setPendingRows(prev => { setPendingRows(prev => {
+1 -1
View File
@@ -85,7 +85,7 @@ export async function saveRowToSupabase(articleNo: string, rowData: ExcelRow): P
body: JSON.stringify({ body: JSON.stringify({
product_id: articleNo, product_id: articleNo,
data: rowData, data: rowData,
status: 'edited', status: 'pending',
updated_at: new Date().toISOString() updated_at: new Date().toISOString()
}) })
} }