diff --git a/src/components/PricingView.tsx b/src/components/PricingView.tsx index c49e8ab..673ddbf 100644 --- a/src/components/PricingView.tsx +++ b/src/components/PricingView.tsx @@ -70,6 +70,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, line: 100, classification: 130, productType: 140, + empco: 110, itemToLogistic: 160, unitsOuter: 100, outerW: 80, @@ -244,7 +245,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, }, [resizingColumn, resizeStartX, resizeStartWidth]); // ── Dynamic column detection ────────────────────────────────────────────── - const { uvpIdx, srpCols, containerCols, nwIdx, gwIdx, unitsOuterIdx, units40fIdx } = useMemo(() => { + const { uvpIdx, srpCols, containerCols, nwIdx, gwIdx, unitsOuterIdx, units40fIdx, empcoIdx } = useMemo(() => { const uvpIdx = findCol(headers, 'uvp'); // All SRP columns, sorted: INT first, UK second, then alphabetically @@ -273,7 +274,10 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, const units40fIdx = findCol(headers, '40f'); - return { uvpIdx, srpCols: srp, containerCols: container, nwIdx, gwIdx, unitsOuterIdx, units40fIdx }; + // EmpCO_Compliant column from the matrix file (empty until the new layout is live) + const empcoIdx = findCol(headers, 'empco'); + + return { uvpIdx, srpCols: srp, containerCols: container, nwIdx, gwIdx, unitsOuterIdx, units40fIdx, empcoIdx }; }, [headers, COLUMNS]); useEffect(() => { @@ -616,6 +620,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, case 'line': colIndex = COLUMNS.LINE; break; case 'classification': colIndex = COLUMNS.CLASSIFICATION; break; case 'productType': colIndex = COLUMNS.CATEGORIZATION_CODE; break; + case 'empco': colIndex = empcoIdx; break; case 'unitsOuter': colIndex = unitsOuterIdx; break; case 'outerW': colIndex = COLUMNS.OUTER_W; break; case 'outerL': colIndex = COLUMNS.OUTER_L; break; @@ -761,6 +766,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, { key: 'line', label: 'Line', index: COLUMNS.LINE }, { key: 'classification', label: 'Classification', index: COLUMNS.CLASSIFICATION }, { key: 'productType', label: 'CategorizationCode', index: COLUMNS.CATEGORIZATION_CODE }, + { key: 'empco', label: 'EMCO Compliant', index: empcoIdx }, { key: 'itemToLogistic', label: 'Item to Logistic', index: COLUMNS.ITEM_TO_LOGISTIC }, { key: 'unitsOuter', label: 'Units/Outer', index: unitsOuterIdx }, { key: 'outerW', label: 'Outer W', index: COLUMNS.OUTER_W }, @@ -775,7 +781,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, cols.push({ key: `con_${col.index}`, label: col.name, index: col.index }); }); return cols; - }, [COLUMNS, unitsOuterIdx, pricingEditableCols, containerCols]); + }, [COLUMNS, unitsOuterIdx, empcoIdx, pricingEditableCols, containerCols]); const togglePinnedColumn = (key: string) => { setPinnedColumns(prev => { @@ -791,7 +797,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, // Calculate sticky left position for each pinned column const getStickyLeft = useMemo(() => { - const baseOrder = ['articleNo', 'articleName', 'line', 'classification', 'productType', 'itemToLogistic', 'unitsOuter', 'outerW', 'outerL', 'outerH', 'moq']; + const baseOrder = ['articleNo', 'articleName', 'line', 'classification', 'productType', 'empco', 'itemToLogistic', 'unitsOuter', 'outerW', 'outerL', 'outerH', 'moq']; const dynamicOrder: string[] = []; pricingEditableCols.forEach(col => dynamicOrder.push(`prc_${col.index}`)); containerCols.forEach(col => dynamicOrder.push(`con_${col.index}`)); @@ -816,7 +822,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, // Calculate z-index for sticky columns (so they stack correctly) const getStickyRank = useMemo(() => { - const baseOrder = ['articleNo', 'articleName', 'line', 'classification', 'productType', 'itemToLogistic', 'unitsOuter', 'outerW', 'outerL', 'outerH', 'moq']; + const baseOrder = ['articleNo', 'articleName', 'line', 'classification', 'productType', 'empco', 'itemToLogistic', 'unitsOuter', 'outerW', 'outerL', 'outerH', 'moq']; const dynamicOrder: string[] = []; pricingEditableCols.forEach(col => dynamicOrder.push(`prc_${col.index}`)); containerCols.forEach(col => dynamicOrder.push(`con_${col.index}`)); @@ -1545,8 +1551,19 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, { e.stopPropagation(); handleResizeStart(e, 'productType', columnWidths.productType); }} /> - handleSort('empco')}> + + {isPinned('empco') && } + EMCO Compliant + + { e.stopPropagation(); handleResizeStart(e, 'empco', columnWidths.empco); }} /> + + + + {/* EMCO Compliant cell (read-only, from matrix file) */} + + {(() => { + const raw = empcoIdx >= 0 ? String(row[empcoIdx] ?? '').trim().toLowerCase() : ''; + if (raw === 'true' || raw === 'yes') { + return Yes; + } + if (raw === 'false' || raw === 'no') { + return No; + } + return -; + })()} + + {/* ITEM TO LOGISTIC cell */} {editingLogistic?.rowIndex === dataIndex ? (