diff --git a/src/pages/Registrations.tsx b/src/pages/Registrations.tsx
index 063d795..e728f58 100644
--- a/src/pages/Registrations.tsx
+++ b/src/pages/Registrations.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Link, useSearchParams } from 'react-router-dom';
-import { ClipboardList, CloudDownload, Loader2, Package, Pencil, RefreshCw, Ruler, Save, Tags, Trash2, Upload } from 'lucide-react';
+import { ChevronDown, ClipboardList, CloudDownload, Loader2, Package, Pencil, RefreshCw, Ruler, Save, Search, Tags, Trash2, Upload } from 'lucide-react';
import {
deleteCatalogCategory,
deleteCatalogProduct,
@@ -101,6 +101,84 @@ const getAverageYield = (reference: ConsumptionReference) => {
return reference.generalYield;
};
+const CatalogProductPicker = ({
+ value,
+ products,
+ emptyLabel,
+ searchPlaceholder,
+ onChange,
+}: {
+ value: string;
+ products: CatalogProduct[];
+ emptyLabel: string;
+ searchPlaceholder: string;
+ onChange: (value: string) => void;
+}) => {
+ const [isOpen, setIsOpen] = useState(false);
+ const [query, setQuery] = useState('');
+ const selectedProduct = products.find(product => String(product.id) === value);
+ const normalizedQuery = query.trim().toLocaleLowerCase('pt-BR');
+ const visibleProducts = useMemo(() => products
+ .filter(product => !normalizedQuery || `${product.name} ${product.sku} ${product.color || ''}`.toLocaleLowerCase('pt-BR').includes(normalizedQuery))
+ .slice(0, 60), [products, normalizedQuery]);
+
+ return (
+
+
+ {isOpen && (
+
+
+
+
+
+
+ {visibleProducts.map(product => (
+
+ ))}
+ {!visibleProducts.length &&
Nenhum item encontrado.
}
+
+
+ )}
+
+ );
+};
+
const getReferenceSourceLabel = (reference: ConsumptionReference) => (
reference.source === 'tiny_op'
? 'Tiny OP'
@@ -1011,17 +1089,23 @@ const Registrations = () => {