mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 13:55:23 +02:00
fix: apply Supabase edits by diff vs Excel, not by editable column index
Instead of relying on resolvedCols.PRODUCT_TYPE (which can resolve to the wrong index if the column header doesn't match the pattern), compare the saved Supabase row against the fresh Excel row: any index where they differ is a user edit and gets applied. This fixes TYPE / 'Surprise Bath bomb' not appearing after reload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
63242d8852
commit
ebef518f11
+13
-4
@@ -168,11 +168,20 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
|
||||
|
||||
// Load manual edits: status 'edited' = saved edits, 'pending' = unsaved edits
|
||||
if (synced && (synced.status === 'edited' || synced.status === 'pending')) {
|
||||
editableColumns.forEach(idx => {
|
||||
if (synced.data[idx] !== undefined && synced.data[idx] !== null) {
|
||||
finalRow[idx] = synced.data[idx];
|
||||
// Compare saved row vs fresh Excel row: wherever Supabase differs from Excel,
|
||||
// that means the user edited that column — apply it regardless of editableColumns
|
||||
// index resolution, which can vary across sessions.
|
||||
const savedLen = Array.isArray(synced.data) ? synced.data.length : 0;
|
||||
for (let idx = 0; idx < savedLen; idx++) {
|
||||
const savedVal = synced.data[idx];
|
||||
const excelVal = row[idx];
|
||||
const savedStr = savedVal == null ? '' : String(savedVal);
|
||||
const excelStr = excelVal == null ? '' : String(excelVal);
|
||||
if (savedStr !== excelStr) {
|
||||
// Value differs from Excel → user edited it, apply the saved value
|
||||
finalRow[idx] = savedVal;
|
||||
}
|
||||
});
|
||||
}
|
||||
setRowStatuses(prev => ({ ...prev, [articleNo]: synced.status }));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user