Fix new Frontend 15

This commit is contained in:
Urtzi Alfaro
2025-08-04 21:46:12 +02:00
parent 8bb14ecc4f
commit 32a7b913d0
10 changed files with 705 additions and 217 deletions

View File

@@ -179,6 +179,85 @@ export class DataService {
params: { limit },
});
}
/**
* Get Products List from Sales Data
* This should be added to the DataService class
*/
async getProductsList(tenantId: string): Promise<string[]> {
const response = await apiClient.get(`/tenants/${tenantId}/sales/products`);
// Extract product names from the response
return response.map((product: any) =>
product.name || product.product_name || product
).filter(Boolean);
}
/**
* Get Current Weather Data
* This should be added to the DataService class
*/
async getCurrentWeather(lat: number, lon: number): Promise<{
temperature: number;
description: string;
precipitation: number;
humidity?: number;
wind_speed?: number;
}> {
return apiClient.get(`/data/weather/current`, {
params: { lat, lon }
});
}
/**
* Get Weather Forecast
* This should be added to the DataService class
*/
async getWeatherForecast(
lat: number,
lon: number,
days: number = 7
): Promise<any[]> {
return apiClient.get(`/data/weather/forecast`, {
params: { lat, lon, days }
});
}
/**
* Get Sales Summary by Period
* This should be added to the DataService class
*/
async getSalesSummary(
tenantId: string,
period: 'daily' | 'weekly' | 'monthly' = 'daily'
): Promise<any> {
return apiClient.get(`/tenants/${tenantId}/sales/summary`, {
params: { period }
});
}
/**
* Get Sales Analytics
* This should be added to the DataService class
*/
async getSalesAnalytics(
tenantId: string,
startDate?: string,
endDate?: string
): Promise<{
total_revenue: number;
waste_reduction_percentage?: number;
forecast_accuracy?: number;
stockout_events?: number;
}> {
return apiClient.get(`/tenants/${tenantId}/sales/analytics`, {
params: {
start_date: startDate,
end_date: endDate
}
});
}
}
export const dataService = new DataService();