mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 13:55:23 +02:00
fix: always use fresh Dropbox Excel values on load
This commit is contained in:
+4
-37
@@ -158,46 +158,13 @@ export default function App() {
|
||||
}
|
||||
});
|
||||
|
||||
const articleNoIdx = resolvedCols.ARTICLE_NO;
|
||||
const articleNoIdx = resolvedCols.ARTICLE_NO;
|
||||
const processedRows = rows.map(row => {
|
||||
const articleNo = String(row[articleNoIdx]);
|
||||
const synced = syncedData[articleNo];
|
||||
|
||||
// Start with Dropbox values (default) - fresh from Excel
|
||||
// Simply use Dropbox values - no merge logic
|
||||
// Manual edits are preserved in Supabase and shown in Change History
|
||||
// but fresh Excel data takes precedence on reload
|
||||
let finalRow = [...row];
|
||||
|
||||
// Only preserve Supabase value if it's DIFFERENT from Dropbox (meaning someone edited it intentionally)
|
||||
// This keeps the TYPE = "Surprise Bath bomb" edits while avoiding stale SRP/UVP values
|
||||
if (synced) {
|
||||
const oldData = synced.data;
|
||||
const valAt12 = oldData[12];
|
||||
const needsShift = typeof valAt12 === 'number' || (typeof valAt12 === 'string' && /^[0-9.]+$/.test(valAt12));
|
||||
|
||||
editableColumns.forEach(idx => {
|
||||
let mergeIdx = idx;
|
||||
if (needsShift && idx >= 12) {
|
||||
mergeIdx = idx - 1;
|
||||
}
|
||||
|
||||
const dbxValue = row[idx];
|
||||
const supabaseValue = oldData[mergeIdx];
|
||||
|
||||
// Only use Supabase value if it's different from Dropbox (edited intentionally)
|
||||
if (supabaseValue !== undefined && supabaseValue !== null) {
|
||||
// Compare as strings to handle numeric formatting differences
|
||||
const dbxStr = String(dbxValue ?? '');
|
||||
const supabaseStr = String(supabaseValue);
|
||||
|
||||
// Keep Supabase value only if it was actually edited (different from Excel)
|
||||
if (dbxStr !== supabaseStr) {
|
||||
finalRow[idx] = supabaseValue;
|
||||
}
|
||||
}
|
||||
});
|
||||
setRowStatuses(prev => ({ ...prev, [articleNo]: synced.status || 'synced' }));
|
||||
}
|
||||
// Otherwise use Dropbox values (don't merge, just process formatting)
|
||||
|
||||
return finalRow.map((val: any, idx: number) => {
|
||||
if (val === undefined || val === null || val === '') return val;
|
||||
const header = (headers[idx] || '').toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user