mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 16:25:24 +02:00
Fix: Implement dynamic column detection to handle Excel structure changes (insertion of PM Classification). This fixes the Missing data error in Pricing Units and other views.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React, { useState, useMemo, useRef, useCallback, useEffect } from 'react';
|
||||
import { ExcelRow, COLUMNS } from '../types';
|
||||
import { ExcelRow } from '../types';
|
||||
import { useColumns } from '../contexts/ColumnsContext';
|
||||
import {
|
||||
AlertTriangle,
|
||||
AlertCircle,
|
||||
@@ -48,6 +49,7 @@ function findCol(headers: string[], ...keywords: string[]): number {
|
||||
}
|
||||
|
||||
export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, rowStatuses }: PricingViewProps) {
|
||||
const COLUMNS = useColumns();
|
||||
const [filterMode, setFilterMode] = useState<FilterMode>('all_errors');
|
||||
const [search, setSearch] = useState('');
|
||||
const [searchMode, setSearchMode] = useState<'all' | 'selected'>('all');
|
||||
@@ -193,15 +195,10 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit,
|
||||
const nwIdx = findCol(headers, 'nw');
|
||||
const gwIdx = findCol(headers, 'gw');
|
||||
|
||||
// Units/Outer column — try dynamic detection first, fall back to hardcoded index
|
||||
const unitsOuterIdx = findCol(headers, 'units', 'outer') >= 0
|
||||
? findCol(headers, 'units', 'outer')
|
||||
: findCol(headers, 'vpe') >= 0
|
||||
? findCol(headers, 'vpe')
|
||||
: COLUMNS.UNITS_OUTER;
|
||||
const unitsOuterIdx = COLUMNS.UNITS_OUTER;
|
||||
|
||||
return { uvpIdx, srpCols: srp, containerCols: container, nwIdx, gwIdx, unitsOuterIdx };
|
||||
}, [headers]);
|
||||
}, [headers, COLUMNS]);
|
||||
|
||||
// ── Error analysis per row ────────────────────────────────────────────────
|
||||
const analyzedRows = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user