REFACTOR data service

This commit is contained in:
Urtzi Alfaro
2025-08-12 18:17:30 +02:00
parent 7c237c0acc
commit fbe7470ad9
149 changed files with 8528 additions and 7393 deletions

View File

@@ -2,7 +2,7 @@
// Complete dashboard hook using your API infrastructure
import { useState, useEffect, useCallback } from 'react';
import { useAuth, useData, useForecast } from '../api';
import { useAuth, useSales, useExternal, useForecast } from '../api';
import { useTenantId } from './useTenantId';
@@ -31,12 +31,16 @@ export const useDashboard = () => {
const { user } = useAuth();
const {
getProductsList,
getCurrentWeather,
getSalesAnalytics,
getDashboardStats,
isLoading: dataLoading,
error: dataError
} = useData();
isLoading: salesLoading,
error: salesError
} = useSales();
const {
getCurrentWeather,
isLoading: externalLoading,
error: externalError
} = useExternal();
const {
createSingleForecast,
@@ -236,8 +240,8 @@ export const useDashboard = () => {
return {
...dashboardData,
isLoading: isLoading || dataLoading || forecastLoading,
error: error || dataError || forecastError,
isLoading: isLoading || salesLoading || externalLoading || forecastLoading,
error: error || salesError || externalError || forecastError,
reload: () => tenantId ? loadDashboardData(tenantId) : Promise.resolve(),
clearError: () => setError(null)
};