Fix new Frontend 15
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user