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
-7
View File
@@ -12,7 +12,6 @@
"@supabase/supabase-js": "^2.103.0", "@supabase/supabase-js": "^2.103.0",
"@tailwindcss/vite": "^4.1.14", "@tailwindcss/vite": "^4.1.14",
"@vitejs/plugin-react": "^5.0.4", "@vitejs/plugin-react": "^5.0.4",
"buzz": "^2.0.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"dotenv": "^17.2.3", "dotenv": "^17.2.3",
"dropbox": "^10.34.0", "dropbox": "^10.34.0",
@@ -1931,12 +1930,6 @@
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/buzz": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/buzz/-/buzz-2.0.0.tgz",
"integrity": "sha512-eYeTETPJp7hWUX7j3o8iJNR8VLaaWRuOYYPWTSQqA5pIxZ2g3ZJUdyjfNZnGvr85IDhfr4ONQQflGp8+MC034A==",
"license": "MIT"
},
"node_modules/bytes": { "node_modules/bytes": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
-1
View File
@@ -15,7 +15,6 @@
"@supabase/supabase-js": "^2.103.0", "@supabase/supabase-js": "^2.103.0",
"@tailwindcss/vite": "^4.1.14", "@tailwindcss/vite": "^4.1.14",
"@vitejs/plugin-react": "^5.0.4", "@vitejs/plugin-react": "^5.0.4",
"buzz": "^2.0.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"dotenv": "^17.2.3", "dotenv": "^17.2.3",
"dropbox": "^10.34.0", "dropbox": "^10.34.0",
+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 launchHeader = launchDateCol >= 0 ? headers[launchDateCol] : 'Launch Date';
const readyHeader = readyToOrderCol >= 0 ? headers[readyToOrderCol] : 'Ready to Order'; 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 columnUniqueValues = useMemo(() => {
const cols = columns.map(c => c.col); const cols = columns.map(c => c.col);
const result: Record<number, Set<string>> = {}; const result: Record<number, Set<string>> = {};
@@ -82,14 +90,14 @@ export function MissingDataView({ data, headers, onSaveRow, onCaptureState }: Mi
}); });
}); });
return result; return result;
}, [data, launchDateCol, readyToOrderCol]); }, [data, columns, launchDateCol, readyToOrderCol]);
const getDisplayValues = (col: number) => { const getDisplayValues = (col: number) => {
const values = columnUniqueValues[col]; const values = columnUniqueValues[col];
if (!values) return []; if (!values) return [];
const searchVal = filterSearch[col]?.toLowerCase() || ''; const searchVal = filterSearch[col]?.toLowerCase() || '';
const arr = Array.from(values).sort(); 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(() => { const filteredData = useMemo(() => {
@@ -184,14 +192,6 @@ export function MissingDataView({ data, headers, onSaveRow, onCaptureState }: Mi
{ id: 'missingLaunch', label: 'Missing Launch Date' }, { 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; const editingRow = editing ? data[editing.rowIndex] : null;
return ( return (