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:
Christian Vidal Wolf
2026-04-23 16:51:16 +02:00
co-authored by Claude Sonnet 4.6
parent 0165793b3e
commit 596b779e01
2 changed files with 5 additions and 6 deletions
+1 -2
View File
@@ -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')) {
+4 -4
View File
@@ -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';