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

@@ -155,6 +155,73 @@ export const useData = () => {
}
}, []);
/**
* Get Products List
* Add this method to the useData hook
*/
const getProductsList = useCallback(async (tenantId: string): Promise<string[]> => {
try {
setIsLoading(true);
setError(null);
const products = await dataService.getProductsList(tenantId);
return products;
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to get products list';
setError(message);
throw error;
} finally {
setIsLoading(false);
}
}, []);
/**
* Get Current Weather
* Add this method to the useData hook
*/
const getCurrentWeather = useCallback(async (lat: number, lon: number) => {
try {
setIsLoading(true);
setError(null);
const weather = await dataService.getCurrentWeather(lat, lon);
return weather;
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to get weather data';
setError(message);
throw error;
} finally {
setIsLoading(false);
}
}, []);
/**
* Get Sales Analytics
* Add this method to the useData hook
*/
const getSalesAnalytics = useCallback(async (
tenantId: string,
startDate?: string,
endDate?: string
) => {
try {
setIsLoading(true);
setError(null);
const analytics = await dataService.getSalesAnalytics(tenantId, startDate, endDate);
return analytics;
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to get sales analytics';
setError(message);
throw error;
} finally {
setIsLoading(false);
}
}, []);
return {
salesData,
dashboardStats,
@@ -168,6 +235,9 @@ export const useData = () => {
getDashboardStats,
getRecentActivity,
exportSalesData,
getProductsList,
getCurrentWeather,
getSalesAnalytics,
clearError: () => setError(null),
};
};