mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:45:24 +02:00
fix: prevent CPNP_NO from being overridden by dynamic column detection
CPNP_NO must stay hardcoded at index 107. Removed it from COLUMN_PATTERNS and added guard to skip empty patterns in resolveColumnIndices. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
co-authored by
claude-flow
parent
889e98b0ca
commit
1b4918a385
@@ -45,7 +45,7 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
|
|||||||
if (!COSMETIC_LINES.some(l => lineVal === l)) return;
|
if (!COSMETIC_LINES.some(l => lineVal === l)) return;
|
||||||
|
|
||||||
columns.forEach(({ col }) => {
|
columns.forEach(({ col }) => {
|
||||||
result[col].add(String(row[col] ?? '').trim());
|
result[col].add(String(row[col] ?? '').replace(/\s+/g, ' ').trim());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,11 +82,9 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro
|
|||||||
(Object.entries(columnFilters) as [string, string[]][]).forEach(([colIdx, filterValues]) => {
|
(Object.entries(columnFilters) as [string, string[]][]).forEach(([colIdx, filterValues]) => {
|
||||||
if (!filterValues || filterValues.length === 0) return;
|
if (!filterValues || filterValues.length === 0) return;
|
||||||
const colNum = parseInt(colIdx);
|
const colNum = parseInt(colIdx);
|
||||||
const filterSet = new Set(filterValues.map(f => f.trim()));
|
const normalize = (v: any) => String(v ?? '').replace(/\s+/g, ' ').trim();
|
||||||
result = result.filter(({ row }) => {
|
const filterSet = new Set(filterValues.map(normalize));
|
||||||
const val = String(row[colNum] ?? '').trim();
|
result = result.filter(({ row }) => filterSet.has(normalize(row[colNum])));
|
||||||
return filterSet.has(val);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
|
|||||||
+2
-1
@@ -82,7 +82,7 @@ export const COLUMN_PATTERNS: Record<keyof typeof COLUMNS, string[]> = {
|
|||||||
ITEM_TO_LOGISTIC: ['item', 'logistic'],
|
ITEM_TO_LOGISTIC: ['item', 'logistic'],
|
||||||
ANNA_CHECK: ['anna', 'check'],
|
ANNA_CHECK: ['anna', 'check'],
|
||||||
ANNA_NOTE: ['anna', 'note'],
|
ANNA_NOTE: ['anna', 'note'],
|
||||||
CPNP_NO: ['cpnp'],
|
CPNP_NO: [],
|
||||||
// Virtual/Extra columns stay hardcoded and are NOT auto-detected from headers
|
// Virtual/Extra columns stay hardcoded and are NOT auto-detected from headers
|
||||||
// to prevent internal data from being shifted or overwritten by Excel column shifts.
|
// to prevent internal data from being shifted or overwritten by Excel column shifts.
|
||||||
};
|
};
|
||||||
@@ -92,6 +92,7 @@ export function resolveColumnIndices(headers: string[]): typeof COLUMNS {
|
|||||||
const h = headers.map(val => String(val || '').toLowerCase());
|
const h = headers.map(val => String(val || '').toLowerCase());
|
||||||
|
|
||||||
Object.entries(COLUMN_PATTERNS).forEach(([key, patterns]) => {
|
Object.entries(COLUMN_PATTERNS).forEach(([key, patterns]) => {
|
||||||
|
if (patterns.length === 0) return;
|
||||||
const idx = h.findIndex(headerText =>
|
const idx = h.findIndex(headerText =>
|
||||||
patterns.every(p => headerText.includes(p.toLowerCase()))
|
patterns.every(p => headerText.includes(p.toLowerCase()))
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user