Fix new Frontend 17

This commit is contained in:
Urtzi Alfaro
2025-08-04 22:46:05 +02:00
parent 8b6e1ae339
commit 0154365bfc
6 changed files with 183 additions and 29 deletions

View File

@@ -93,11 +93,10 @@ export const useDashboard = () => {
console.warn('Failed to fetch products:', error);
products = ['Croissants', 'Pan de molde', 'Baguettes', 'Café', 'Napolitanas'];
}
// 2. Get weather data (Madrid coordinates)
let weather = null;
try {
weather = await getCurrentWeather(40.4168, -3.7038);
weather = await getCurrentWeather(tenantId, 40.4168, -3.7038);
} catch (error) {
console.warn('Failed to fetch weather:', error);
// Fallback weather
@@ -113,9 +112,12 @@ export const useDashboard = () => {
try {
const forecastRequest = {
product_name: product,
forecast_date: new Date().toISOString().split('T')[0], // Today's date as YYYY-MM-DD
forecast_days: 1,
location: 'madrid_centro', // Default location for Madrid bakery
include_external_factors: true,
confidence_intervals: true
// confidence_level is handled by backend internally (default 0.8)
};
const forecastResults = await createSingleForecast(tenantId, forecastRequest);
@@ -124,7 +126,7 @@ export const useDashboard = () => {
const forecast = forecastResults[0];
// Map API response to dashboard format
const confidenceScore = forecast.model_accuracy || 0.8;
const confidenceScore = forecast.confidence_level || 0.8;
const confidence = confidenceScore > 0.8 ? 'high' as const :
confidenceScore > 0.6 ? 'medium' as const : 'low' as const;
@@ -133,7 +135,7 @@ export const useDashboard = () => {
return {
product,
predicted: Math.round(forecast.predicted_quantity || 0),
predicted: Math.round(forecast.predicted_demand || 0),
confidence,
change
};