From f3ed3cf1474c8758b2f1e4aa2a11746b1e88ef38 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Thu, 23 Apr 2026 16:22:35 +0200 Subject: [PATCH] fix: preserve edited changes after export and on Dropbox reload resetAllPendingRows was setting status to 'synced' instead of 'edited', causing the merge logic on reload to skip those rows. Also keep 'edited' and 'saved' statuses locally after export instead of clearing all. Co-Authored-By: Claude Sonnet 4.6 --- src/App.tsx | 11 +++++++++-- src/lib/supabase.ts | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 58e08a5..3adb236 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -325,12 +325,19 @@ const articleNoIdx = resolvedCols.ARTICLE_NO; const dateStr = new Date().toISOString().split('T')[0]; XLSX.writeFile(wb, `CRAZE_Products_Updated_${dateStr}.xlsx`); - // 3. Post-export: Reset pending statuses in Supabase + // 3. Post-export: Reset pending statuses in Supabase (pending → edited to preserve on reload) console.log('Resetting pending statuses in Supabase...'); resetAllPendingRows().then(success => { if (success) { console.log('Successfully reset all pending statuses'); - setRowStatuses({}); // Clear local statuses + // Only clear 'pending' statuses locally; keep 'edited'/'saved' so they remain visible + setRowStatuses((prev: Record) => { + const next: Record = {}; + for (const [id, status] of Object.entries(prev)) { + if (status !== 'pending') next[id] = status as string; + } + return next; + }); } }); diff --git a/src/lib/supabase.ts b/src/lib/supabase.ts index 058d540..ef37ec0 100644 --- a/src/lib/supabase.ts +++ b/src/lib/supabase.ts @@ -37,7 +37,7 @@ export interface ExcelRow extends Array {} export interface SyncedRow { data: ExcelRow; - status?: 'pending' | 'synced'; + status?: 'pending' | 'edited' | 'synced' | 'excel'; } export async function getAllSyncedRows(): Promise> { @@ -208,7 +208,7 @@ export async function resetAllPendingRows(): Promise { 'Content-Type': 'application/json', 'Prefer': 'return=minimal', }, - body: JSON.stringify({ status: 'synced' }) + body: JSON.stringify({ status: 'edited' }) } );