mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 18:25:24 +02:00
Fix columnUniqueValues dependency to use columns before it's defined
This commit is contained in:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user