REFACTOR data service
This commit is contained in:
@@ -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)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user