Files
lcbp3/frontend/hooks/use-dashboard.ts
T
admin d4f0d02c62
CI / CD Pipeline / build (push) Failing after 4m18s
CI / CD Pipeline / deploy (push) Has been skipped
690402:2240 fix dashboard
2026-04-02 22:40:11 +07:00

34 lines
1.2 KiB
TypeScript

import { useQuery } from '@tanstack/react-query';
import { dashboardService } from '@/lib/services/dashboard.service';
export const dashboardKeys = {
all: ['dashboard'] as const,
stats: (projectId?: string | null) => [...dashboardKeys.all, 'stats', projectId] as const,
activity: (projectId?: string | null) => [...dashboardKeys.all, 'activity', projectId] as const,
pending: (projectId?: string | null) => [...dashboardKeys.all, 'pending', projectId] as const,
};
export function useDashboardStats(projectId?: string | null) {
return useQuery({
queryKey: dashboardKeys.stats(projectId),
queryFn: () => dashboardService.getStats(projectId),
staleTime: 5 * 60 * 1000, // 5 minutes
});
}
export function useRecentActivity(projectId?: string | null) {
return useQuery({
queryKey: dashboardKeys.activity(projectId),
queryFn: () => dashboardService.getRecentActivity(projectId),
staleTime: 1 * 60 * 1000,
});
}
export function usePendingTasks(projectId?: string | null) {
return useQuery({
queryKey: dashboardKeys.pending(projectId),
queryFn: () => dashboardService.getPendingTasks(projectId),
staleTime: 2 * 60 * 1000,
});
}