Backend fixes: - Updated psutil from 5.9.8 to 6.1.0 for better ARM64 support and pre-built wheels Frontend fixes: - Created missing lib/api/client.ts with axios API client - Created missing lib/hooks/useStats.ts with system statistics hooks - Created missing lib/hooks/useBots.ts with bot management hooks - Fixed .gitignore to not ignore frontend/lib/ directory These changes resolve the build errors: - Backend: psutil compilation failure on aarch64 - Frontend: Missing module @/lib/hooks/useStats
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
/**
|
|
* Hooks for fetching statistics data.
|
|
*/
|
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import apiClient from "@/lib/api/client";
|
|
import type { SystemStats, BotStats, AggregateStats } from "@/types/stats";
|
|
|
|
/**
|
|
* Hook to fetch system statistics.
|
|
*/
|
|
export function useSystemStats() {
|
|
return useQuery({
|
|
queryKey: ["stats", "system"],
|
|
queryFn: async () => {
|
|
const response = await apiClient.get<SystemStats>("/stats/system");
|
|
return response.data;
|
|
},
|
|
refetchInterval: 5000, // Refetch every 5 seconds
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Hook to fetch bot statistics by bot ID.
|
|
*/
|
|
export function useBotStats(botId: string) {
|
|
return useQuery({
|
|
queryKey: ["stats", "bot", botId],
|
|
queryFn: async () => {
|
|
const response = await apiClient.get<BotStats>(`/stats/bots/${botId}`);
|
|
return response.data;
|
|
},
|
|
refetchInterval: 5000,
|
|
enabled: !!botId,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Hook to fetch aggregate statistics for all bots.
|
|
*/
|
|
export function useAggregateStats() {
|
|
return useQuery({
|
|
queryKey: ["stats", "bots", "aggregate"],
|
|
queryFn: async () => {
|
|
const response = await apiClient.get<AggregateStats>("/stats/bots");
|
|
return response.data;
|
|
},
|
|
refetchInterval: 5000,
|
|
});
|
|
}
|