diff --git a/src/components/ProductDescriptions.tsx b/src/components/ProductDescriptions.tsx index 7c9d9f9..e25f2ff 100644 --- a/src/components/ProductDescriptions.tsx +++ b/src/components/ProductDescriptions.tsx @@ -15,7 +15,7 @@ interface ProductDescriptionsProps { type TabType = 'all' | 'missingLongDE' | 'missingLongEN' | 'missingShortDE' | 'missingShortEN' | 'complete' | 'incomplete'; // Description columns that should only have Present/Missing filters -const DESCRIPTION_COLUMNS = [COLUMNS.LONG_DE, COLUMNS.LONG_EN, COLUMNS.SHORT_DE, COLUMNS.SHORT_EN]; +const DESCRIPTION_COLUMNS = [COLUMNS.LONG_DE, COLUMNS.LONG_EN, COLUMNS.SHORT_DE, COLUMNS.SHORT_EN, COLUMNS.DETAILS_DE, COLUMNS.DETAILS_EN]; export function ProductDescriptions({ data, headers, asinColumnIndex, onEdit, rowStatuses }: ProductDescriptionsProps) { const [activeTab, setActiveTab] = useState('all'); @@ -76,27 +76,29 @@ export function ProductDescriptions({ data, headers, asinColumnIndex, onEdit, ro if (licenseFilter) result = result.filter(r => r.row[COLUMNS.LICENSE] === licenseFilter); // Column-specific filters (Excel-like) - console.log('[Filter] applying columnFilters:', columnFilters, 'result count before:', result.length); Object.entries(columnFilters).forEach(([colIdx, selectedValues]) => { const col = Number(colIdx); const vals = selectedValues as string[]; if (vals.length > 0) { - // For description columns, filter by present/missing - if (DESCRIPTION_COLUMNS.includes(col)) { - result = result.filter(r => { - const hasValue = Boolean(r.row[col]); - const shouldInclude = (vals.includes('Present') && hasValue) || (vals.includes('Missing') && !hasValue); - return shouldInclude; - }); - } else { - // For other columns, use regular value matching - const before = result.length; - result = result.filter(r => { - const cellVal = String(r.row[col] ?? '').trim(); - return vals.some(v => v.trim() === cellVal); - }); - console.log('[Filter] col', col, 'vals', vals, 'before:', before, 'after:', result.length); - } + result = result.filter(r => { + const cellVal = r.row[col]; + + if (DESCRIPTION_COLUMNS.includes(col)) { + // For description columns, we match synthetic 'Present'/'Missing' values + const hasValue = cellVal !== undefined && cellVal !== null && String(cellVal).trim() !== ''; + const matchPresent = vals.includes('Present') && hasValue; + const matchMissing = vals.includes('Missing') && !hasValue; + return matchPresent || matchMissing; + } else { + // For other columns, use regular value matching with improved empty value handling + const cellStr = String(cellVal ?? '').trim(); + // If the cell is empty/null/undefined, it matches if 'Empty' or '' is selected + return vals.some(v => { + const filterVal = String(v ?? '').trim(); + return filterVal === cellStr; + }); + } + }); } });