From 311d74b783cf02edfbe09b2d006e09c89dfb00b3 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Mon, 11 May 2026 11:48:11 +0200 Subject: [PATCH] fix: ensure saved changes persist across app refreshes by updating status logic and merge check --- src/App.tsx | 7 +++++-- src/lib/supabase.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index b5d82ed..789b728 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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) // 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 => { if (idx < 100 && sourceForInternal[idx] !== undefined && sourceForInternal[idx] !== null) { finalRow[idx] = sourceForInternal[idx]; @@ -551,7 +551,10 @@ const articleNoIdx = resolvedCols.ARTICLE_NO; if (result.success) { // 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' })); setPendingRows(prev => { diff --git a/src/lib/supabase.ts b/src/lib/supabase.ts index a16b721..05a25ce 100644 --- a/src/lib/supabase.ts +++ b/src/lib/supabase.ts @@ -85,7 +85,7 @@ export async function saveRowToSupabase(articleNo: string, rowData: ExcelRow): P body: JSON.stringify({ product_id: articleNo, data: rowData, - status: 'edited', + status: 'pending', updated_at: new Date().toISOString() }) }