Debugging
This commit is contained in:
@@ -19,9 +19,15 @@ interface ApiError {
|
||||
|
||||
export const useVehicles = () => {
|
||||
const { isAuthenticated, isLoading } = useAuth0();
|
||||
|
||||
console.log('[useVehicles] Hook called - isAuthenticated:', isAuthenticated, 'isLoading:', isLoading);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['vehicles'],
|
||||
queryFn: vehiclesApi.getAll,
|
||||
queryFn: () => {
|
||||
console.log('[useVehicles] Query function called - fetching vehicles');
|
||||
return vehiclesApi.getAll();
|
||||
},
|
||||
enabled: isAuthenticated && !isLoading,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes - prevent unnecessary refetches
|
||||
gcTime: 10 * 60 * 1000, // 10 minutes cache time
|
||||
@@ -36,6 +42,12 @@ export const useVehicles = () => {
|
||||
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000),
|
||||
refetchOnWindowFocus: false, // Prevent refetch on window focus
|
||||
refetchOnMount: false, // Only fetch on mount if data is stale
|
||||
onSuccess: (data) => {
|
||||
console.log('[useVehicles] Query success - vehicles loaded:', data?.length);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log('[useVehicles] Query error:', error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user