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() }) }