Fix pick list product search and category display
This commit is contained in:
@@ -114,6 +114,8 @@ export const ActivePickListScreen = () => {
|
||||
const packagingTypeCount = Number(hasCartonItems) + Number(hasUnitItems);
|
||||
const singlePackagingType = packagingTypeCount === 1;
|
||||
|
||||
const categoryFilteredProducts = useMemo(() => sortedProducts, [sortedProducts]);
|
||||
|
||||
const filteredProducts = useMemo(() => {
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
if (!normalizedQuery) return categoryFilteredProducts;
|
||||
|
||||
@@ -25,12 +25,22 @@ export const StartPickListScreen = () => {
|
||||
const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
|
||||
const [autoAddNewProducts, setAutoAddNewProducts] = useState(true);
|
||||
|
||||
const uniqueCategories = useMemo(() => {
|
||||
const seen = new Set<string>();
|
||||
return categories.filter((category) => {
|
||||
const key = category.name.trim().toLowerCase();
|
||||
if (seen.has(key)) return false;
|
||||
seen.add(key);
|
||||
return true;
|
||||
});
|
||||
}, [categories]);
|
||||
|
||||
const sortedCategories = useMemo(
|
||||
() =>
|
||||
[...categories].sort((a, b) =>
|
||||
[...uniqueCategories].sort((a, b) =>
|
||||
a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }),
|
||||
),
|
||||
[categories],
|
||||
[uniqueCategories],
|
||||
);
|
||||
|
||||
const handleToggleCategory = (categoryId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user