mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:35:25 +02:00
fix: extend headers with virtual columns so saved edits at indices >Excel length render
When the Excel shrinks (fewer columns than when an edit was saved), the saved value exists in Supabase at e.g. index 103 but headers only covers 0-76, so the column never renders. Now we pad headers up to the hardcoded virtual column indices (PRODUCT_TYPE=103, etc.) so the merge value is visible in the UI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
59e4bdeb92
commit
96c56947c0
+25
-5
@@ -135,7 +135,27 @@ export default function App() {
|
||||
console.log('Fetching synced data from Supabase...');
|
||||
const syncedData = await getAllSyncedRows();
|
||||
|
||||
const resolvedCols = resolveColumnIndices(headers);
|
||||
// Extend headers with virtual columns if the Excel is shorter than the saved data.
|
||||
// COLUMNS hardcoded indices (PRODUCT_TYPE=103, ITEM_TO_LOGISTIC=104, etc.) are used
|
||||
// by older saved rows — ensure headers covers them so the merge and render work.
|
||||
const extendedHeaders = [...headers];
|
||||
const VIRTUAL_COLS: Record<number, string> = {
|
||||
[COLUMNS.VERIFIED_DIMS]: 'Verified Dims',
|
||||
[COLUMNS.VALIDATED_CHECK]: 'Validated',
|
||||
[COLUMNS.VALIDATED_NOTE]: 'Note',
|
||||
[COLUMNS.PRODUCT_TYPE]: 'TYPE',
|
||||
[COLUMNS.ITEM_TO_LOGISTIC]: 'Item to Logistic',
|
||||
[COLUMNS.ANNA_CHECK]: 'Anna Check',
|
||||
[COLUMNS.ANNA_NOTE]: 'Anna Note',
|
||||
};
|
||||
Object.entries(VIRTUAL_COLS).forEach(([idxStr, name]) => {
|
||||
const idx = Number(idxStr);
|
||||
if (extendedHeaders[idx] === undefined) {
|
||||
extendedHeaders[idx] = name;
|
||||
}
|
||||
});
|
||||
|
||||
const resolvedCols = resolveColumnIndices(extendedHeaders);
|
||||
const editableColumns = new Set([
|
||||
resolvedCols.CLASSIFICATION,
|
||||
resolvedCols.LONG_DE, resolvedCols.LONG_EN,
|
||||
@@ -187,7 +207,7 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
|
||||
|
||||
return finalRow.map((val: any, idx: number) => {
|
||||
if (val === undefined || val === null || val === '') return val;
|
||||
const header = (headers[idx] || '').toLowerCase();
|
||||
const header = (extendedHeaders[idx] || '').toLowerCase();
|
||||
|
||||
if ((header.includes('id') || header.includes('no') || header.includes('code') ||
|
||||
header.includes('art.') || header.includes('barcode') || header.includes('article')) &&
|
||||
@@ -213,12 +233,12 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
|
||||
});
|
||||
});
|
||||
|
||||
const asinIdx = (headers as string[]).findIndex((h: string) =>
|
||||
const asinIdx = (extendedHeaders as string[]).findIndex((h: string) =>
|
||||
String(h).toLowerCase().trim() === 'asin'
|
||||
);
|
||||
|
||||
|
||||
setAppState({
|
||||
headers: headers,
|
||||
headers: extendedHeaders,
|
||||
data: processedRows,
|
||||
fileName: 'Data-Matrix.xlsx (Cloud Sync)',
|
||||
fileDate: new Date(),
|
||||
|
||||
Reference in New Issue
Block a user