Fix new services implementation 10
This commit is contained in:
@@ -90,31 +90,7 @@ export const useDashboard = () => {
|
||||
|
||||
try {
|
||||
// 1. Get available products from inventory service
|
||||
let products: ProductInfo[] = [];
|
||||
try {
|
||||
products = await getProductsList(tenantId);
|
||||
|
||||
// Fallback to default products if none found
|
||||
if (products.length === 0) {
|
||||
products = [
|
||||
{ inventory_product_id: 'fallback-croissants', name: 'Croissants' },
|
||||
{ inventory_product_id: 'fallback-pan', name: 'Pan de molde' },
|
||||
{ inventory_product_id: 'fallback-baguettes', name: 'Baguettes' },
|
||||
{ inventory_product_id: 'fallback-cafe', name: 'Café' },
|
||||
{ inventory_product_id: 'fallback-napolitanas', name: 'Napolitanas' }
|
||||
];
|
||||
console.warn('No products found from inventory API, using default products');
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to fetch products from inventory:', error);
|
||||
products = [
|
||||
{ inventory_product_id: 'fallback-croissants', name: 'Croissants' },
|
||||
{ inventory_product_id: 'fallback-pan', name: 'Pan de molde' },
|
||||
{ inventory_product_id: 'fallback-baguettes', name: 'Baguettes' },
|
||||
{ inventory_product_id: 'fallback-cafe', name: 'Café' },
|
||||
{ inventory_product_id: 'fallback-napolitanas', name: 'Napolitanas' }
|
||||
];
|
||||
}
|
||||
const products = await getProductsList(tenantId);
|
||||
// 2. Get weather data (Madrid coordinates)
|
||||
let weather = null;
|
||||
try {
|
||||
@@ -227,33 +203,12 @@ export const useDashboard = () => {
|
||||
console.error('Error loading dashboard data:', error);
|
||||
setError(error instanceof Error ? error.message : 'Failed to load dashboard data');
|
||||
|
||||
// Set fallback data
|
||||
// Set empty fallback data on error
|
||||
setDashboardData({
|
||||
weather: {
|
||||
temperature: 18,
|
||||
description: 'Parcialmente nublado',
|
||||
precipitation: 0
|
||||
},
|
||||
todayForecasts: [
|
||||
{ product: 'Croissants', inventory_product_id: 'fallback-croissants', predicted: 48, confidence: 'high', change: 8 },
|
||||
{ product: 'Pan de molde', inventory_product_id: 'fallback-pan', predicted: 35, confidence: 'high', change: 3 },
|
||||
{ product: 'Baguettes', inventory_product_id: 'fallback-baguettes', predicted: 25, confidence: 'medium', change: -3 },
|
||||
{ product: 'Café', inventory_product_id: 'fallback-cafe', predicted: 72, confidence: 'high', change: 5 },
|
||||
{ product: 'Napolitanas', inventory_product_id: 'fallback-napolitanas', predicted: 26, confidence: 'medium', change: 3 }
|
||||
],
|
||||
metrics: {
|
||||
totalSales: 1247,
|
||||
wasteReduction: 15.3,
|
||||
accuracy: 87.2,
|
||||
stockouts: 2
|
||||
},
|
||||
products: [
|
||||
{ inventory_product_id: 'fallback-croissants', name: 'Croissants' },
|
||||
{ inventory_product_id: 'fallback-pan', name: 'Pan de molde' },
|
||||
{ inventory_product_id: 'fallback-baguettes', name: 'Baguettes' },
|
||||
{ inventory_product_id: 'fallback-cafe', name: 'Café' },
|
||||
{ inventory_product_id: 'fallback-napolitanas', name: 'Napolitanas' }
|
||||
]
|
||||
weather: null,
|
||||
todayForecasts: [],
|
||||
metrics: null,
|
||||
products: []
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user