mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 11:45:24 +02:00
feat: restrict description column filters to Present/Missing only
Long DE, Long EN, Short DE, and Short EN columns now only show Present/Missing filter options instead of all unique values Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
co-authored by
Qwen-Coder
parent
976f38eef8
commit
20a0c2d786
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import React, { useState, useMemo, useCallback } from 'react';
|
||||
import { ExcelRow, COLUMNS } from '../types';
|
||||
import { Search, Filter, Edit2, ChevronDown, ChevronUp, X } from 'lucide-react';
|
||||
import { cn } from '../lib/utils';
|
||||
@@ -11,6 +11,9 @@ interface ProductDescriptionsProps {
|
||||
|
||||
type TabType = 'all' | 'missingLongDE' | 'missingLongEN' | 'missingLongAny' | 'missingShortDE' | 'missingShortEN' | 'missingShortAny' | '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];
|
||||
|
||||
export function ProductDescriptions({ data, onEdit }: ProductDescriptionsProps) {
|
||||
const [activeTab, setActiveTab] = useState<TabType>('all');
|
||||
const [search, setSearch] = useState('');
|
||||
@@ -61,9 +64,20 @@ export function ProductDescriptions({ data, onEdit }: ProductDescriptionsProps)
|
||||
|
||||
// Column-specific filters (Excel-like)
|
||||
Object.entries(columnFilters).forEach(([colIdx, selectedValues]) => {
|
||||
const col = Number(colIdx);
|
||||
const vals = selectedValues as string[];
|
||||
if (vals.length > 0) {
|
||||
result = result.filter(r => vals.includes(String(r.row[Number(colIdx)] || '')));
|
||||
// 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
|
||||
result = result.filter(r => vals.includes(String(r.row[col] || '')));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -96,6 +110,11 @@ export function ProductDescriptions({ data, onEdit }: ProductDescriptionsProps)
|
||||
};
|
||||
|
||||
const getUniqueValues = (col: number) => {
|
||||
// For description columns, return only 'Present' and 'Missing'
|
||||
if (DESCRIPTION_COLUMNS.includes(col)) {
|
||||
return ['Present', 'Missing'];
|
||||
}
|
||||
// For other columns, return actual unique values
|
||||
const values = data.map(r => String(r[col] || ''));
|
||||
return Array.from(new Set(values)).sort();
|
||||
};
|
||||
@@ -143,7 +162,7 @@ export function ProductDescriptions({ data, onEdit }: ProductDescriptionsProps)
|
||||
const stock = Number(row[COLUMNS.ITEM_AVAILABLE] || 0);
|
||||
|
||||
if (classification === 'OOC' && stock <= 0) {
|
||||
return <span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-500/20 text-yellow-400 border border-yellow-500/30">EOL not neccessary</span>;
|
||||
return <span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-500/20 text-yellow-400 border border-yellow-500/30">EOL not neccessary</span>;
|
||||
}
|
||||
|
||||
return <span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-500/20 text-red-400 border border-red-500/30">✗ Missing</span>;
|
||||
|
||||
Reference in New Issue
Block a user