Fix columnUniqueValues dependency to use columns before it's defined

This commit is contained in:
Christian Vidal Wolf
2026-04-12 18:38:47 +02:00
parent dce4588d0c
commit a5d4305006
3 changed files with 10 additions and 18 deletions
+10 -10
View File
@@ -65,6 +65,14 @@ export function MissingDataView({ data, headers, onSaveRow, onCaptureState }: Mi
const launchHeader = launchDateCol >= 0 ? headers[launchDateCol] : 'Launch Date';
const readyHeader = readyToOrderCol >= 0 ? headers[readyToOrderCol] : 'Ready to Order';
const columns = [
{ col: COLUMNS.ARTICLE_NO, label: 'SKU', width: 100 },
{ col: COLUMNS.ARTICLE_NAME, label: 'Name', width: 220 },
{ col: COLUMNS.CLASSIFICATION, label: 'Classification', width: 130 },
...(launchDateCol >= 0 ? [{ col: launchDateCol, label: launchHeader, width: 130 }] : []),
...(readyToOrderCol >= 0 ? [{ col: readyToOrderCol, label: readyHeader, width: 130 }] : []),
];
const columnUniqueValues = useMemo(() => {
const cols = columns.map(c => c.col);
const result: Record<number, Set<string>> = {};
@@ -82,14 +90,14 @@ export function MissingDataView({ data, headers, onSaveRow, onCaptureState }: Mi
});
});
return result;
}, [data, launchDateCol, readyToOrderCol]);
}, [data, columns, launchDateCol, readyToOrderCol]);
const getDisplayValues = (col: number) => {
const values = columnUniqueValues[col];
if (!values) return [];
const searchVal = filterSearch[col]?.toLowerCase() || '';
const arr = Array.from(values).sort();
return searchVal ? arr.filter(v => v.toLowerCase().includes(searchVal)) : arr;
return searchVal ? arr.filter((v: string) => v.toLowerCase().includes(searchVal)) : arr;
};
const filteredData = useMemo(() => {
@@ -184,14 +192,6 @@ export function MissingDataView({ data, headers, onSaveRow, onCaptureState }: Mi
{ id: 'missingLaunch', label: 'Missing Launch Date' },
];
const columns = [
{ col: COLUMNS.ARTICLE_NO, label: 'SKU', width: 100 },
{ col: COLUMNS.ARTICLE_NAME, label: 'Name', width: 220 },
{ col: COLUMNS.CLASSIFICATION, label: 'Classification', width: 130 },
...(launchDateCol >= 0 ? [{ col: launchDateCol, label: launchHeader, width: 130 }] : []),
...(readyToOrderCol >= 0 ? [{ col: readyToOrderCol, label: readyHeader, width: 130 }] : []),
];
const editingRow = editing ? data[editing.rowIndex] : null;
return (