Fix issues 4
This commit is contained in:
@@ -87,12 +87,10 @@ const ForecastPage: React.FC = () => {
|
||||
try {
|
||||
const products = await getProductsList(tenantId);
|
||||
|
||||
// If no finished products found, use fallback products with trained models
|
||||
// Always use real inventory products - no hardcoded fallbacks
|
||||
if (products.length === 0) {
|
||||
setInventoryItems([
|
||||
{ id: '3ae0afca-3e75-4f93-b6af-2d24c24bfcd5', name: 'Croissants' },
|
||||
{ id: 'b2341c5d-db5d-418e-a978-6d24cd9f039e', name: 'Pan de molde' }
|
||||
]);
|
||||
console.warn('⚠️ No finished products found in inventory for forecasting');
|
||||
setInventoryItems([]);
|
||||
} else {
|
||||
// Map products to the expected format
|
||||
setInventoryItems(products.map(p => ({
|
||||
@@ -102,11 +100,8 @@ const ForecastPage: React.FC = () => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load products:', error);
|
||||
// Use fallback products with trained models
|
||||
setInventoryItems([
|
||||
{ id: '3ae0afca-3e75-4f93-b6af-2d24c24bfcd5', name: 'Croissants' },
|
||||
{ id: 'b2341c5d-db5d-418e-a978-6d24cd9f039e', name: 'Pan de molde' }
|
||||
]);
|
||||
// Don't use fake fallback products - show empty state instead
|
||||
setInventoryItems([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -462,7 +457,19 @@ const ForecastPage: React.FC = () => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{forecastData.length === 0 && !isLoading && !isGenerating && (
|
||||
{inventoryItems.length === 0 && !isLoading && !isGenerating && (
|
||||
<div className="mt-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg">
|
||||
<div className="flex items-center">
|
||||
<AlertTriangle className="h-5 w-5 text-yellow-600 mr-2" />
|
||||
<span className="text-yellow-800 text-sm">
|
||||
<strong>No hay productos disponibles para predicciones.</strong>
|
||||
<br />Para usar esta funcionalidad, necesitas crear productos terminados (como pan, croissants, etc.) en tu inventario con tipo "Producto terminado".
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{inventoryItems.length > 0 && forecastData.length === 0 && !isLoading && !isGenerating && (
|
||||
<div className="mt-4 p-4 bg-blue-50 border border-blue-200 rounded-lg">
|
||||
<div className="flex items-center">
|
||||
<Info className="h-5 w-5 text-blue-600 mr-2" />
|
||||
|
||||
Reference in New Issue
Block a user