mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:25:23 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7de903a184
commit
f3ed3cf147
+9
-2
@@ -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<string, string>) => {
|
||||
const next: Record<string, string> = {};
|
||||
for (const [id, status] of Object.entries(prev)) {
|
||||
if (status !== 'pending') next[id] = status as string;
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ export interface ExcelRow extends Array<any> {}
|
||||
|
||||
export interface SyncedRow {
|
||||
data: ExcelRow;
|
||||
status?: 'pending' | 'synced';
|
||||
status?: 'pending' | 'edited' | 'synced' | 'excel';
|
||||
}
|
||||
|
||||
export async function getAllSyncedRows(): Promise<Record<string, SyncedRow>> {
|
||||
@@ -208,7 +208,7 @@ export async function resetAllPendingRows(): Promise<boolean> {
|
||||
'Content-Type': 'application/json',
|
||||
'Prefer': 'return=minimal',
|
||||
},
|
||||
body: JSON.stringify({ status: 'synced' })
|
||||
body: JSON.stringify({ status: 'edited' })
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user