mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 14:15:24 +02:00
fix: guard against undefined headers in MissingDataView and MatrixView
Extended headers array can have empty strings that get passed as header values; guard all .toLowerCase().includes() calls with (h || ''). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0165793b3e
commit
596b779e01
@@ -121,8 +121,7 @@ export function MatrixView({ data, headers, rowStatuses }: MatrixViewProps) {
|
||||
const formatCellValue = (val: any, header: string = '') => {
|
||||
if (val === undefined || val === null || val === '') return '';
|
||||
|
||||
// Convert header to lowercase for checks
|
||||
const h = header.toLowerCase();
|
||||
const h = (header || '').toLowerCase();
|
||||
|
||||
// Handle date columns - Excel serial dates are numbers >= 25569 (Jan 1, 1970)
|
||||
if (h.includes('date') || h.includes('launch') || h.includes('ready')) {
|
||||
|
||||
@@ -80,14 +80,14 @@ export function MissingDataView({ data, headers, onSaveRow, onCaptureState }: Mi
|
||||
const pageSize = 100;
|
||||
|
||||
const launchDateCol = useMemo(() => {
|
||||
const idx = headers.findIndex(h => h.toLowerCase().includes('launch'));
|
||||
const idx = headers.findIndex(h => (h || '').toLowerCase().includes('launch'));
|
||||
if (idx >= 0) return idx;
|
||||
return headers.findIndex(h => h.toLowerCase().includes('date'));
|
||||
return headers.findIndex(h => (h || '').toLowerCase().includes('date'));
|
||||
}, [headers]);
|
||||
const readyToOrderCol = useMemo(() => {
|
||||
const idx = headers.findIndex(h => h.toLowerCase().includes('ready'));
|
||||
const idx = headers.findIndex(h => (h || '').toLowerCase().includes('ready'));
|
||||
if (idx >= 0) return idx;
|
||||
return headers.findIndex(h => h.toLowerCase().includes('order'));
|
||||
return headers.findIndex(h => (h || '').toLowerCase().includes('order'));
|
||||
}, [headers]);
|
||||
|
||||
const launchHeader = launchDateCol >= 0 ? headers[launchDateCol] : 'Launch Date';
|
||||
|
||||
Reference in New Issue
Block a user