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