diff --git a/frontend/src/components/domain/dashboard/IncompleteIngredientsAlert.tsx b/frontend/src/components/domain/dashboard/IncompleteIngredientsAlert.tsx new file mode 100644 index 00000000..27e0147e --- /dev/null +++ b/frontend/src/components/domain/dashboard/IncompleteIngredientsAlert.tsx @@ -0,0 +1,107 @@ +import React from 'react'; +import { useNavigate } from 'react-router-dom'; +import { useIngredients } from '../../../api/hooks/inventory'; +import { useCurrentTenant } from '../../../stores/tenant.store'; +import { AlertTriangle, ExternalLink } from 'lucide-react'; + +export const IncompleteIngredientsAlert: React.FC = () => { + const navigate = useNavigate(); + const currentTenant = useCurrentTenant(); + + // Fetch all ingredients + const { data: ingredients = [], isLoading } = useIngredients(currentTenant?.id || '', {}, { + enabled: !!currentTenant?.id + }); + + // Filter ingredients that need review (created via quick add or batch with incomplete data) + const incompleteIngredients = React.useMemo(() => { + return ingredients.filter(ing => { + // Check metadata for needs_review flag + const metadata = ing.metadata as any; + return metadata?.needs_review === true; + }); + }, [ingredients]); + + // Don't show if no incomplete ingredients or still loading + if (isLoading || incompleteIngredients.length === 0) { + return null; + } + + const handleViewIncomplete = () => { + // Navigate to inventory page + // TODO: In the future, this could pass a filter parameter to show only incomplete items + navigate('/app/operations/inventory'); + }; + + return ( +
+ {incompleteIngredients.length === 1 + ? 'Hay 1 ingrediente que fue agregado rápidamente y necesita información completa.' + : `Hay ${incompleteIngredients.length} ingredientes que fueron agregados rápidamente y necesitan información completa.`} +
+ Información faltante típica: + {' '}Stock inicial, costo por unidad, vida útil, punto de reorden, requisitos de almacenamiento +
+ Agrega varios ingredientes a la vez para ahorrar tiempo +
{row.error}
+ + + + + 💡 Los campos de stock y costo son opcionales. Puedes completarlos más tarde en la gestión de inventario. + +
+ + + + {globalError} +
+ ⚠️ Ingredientes similares encontrados: +
+ Verifica que no sea un duplicado antes de continuar. +