690402:2240 fix dashboard
This commit is contained in:
@@ -30,7 +30,7 @@ describe('use-circulation hooks', () => {
|
||||
});
|
||||
|
||||
describe('useCirculationsByCorrespondence', () => {
|
||||
it('should fetch circulations for a correspondence UUID', async () => {
|
||||
it('should fetch circulations for a correspondence publicId', async () => {
|
||||
const mockData = {
|
||||
data: [
|
||||
{
|
||||
@@ -60,7 +60,7 @@ describe('use-circulation hooks', () => {
|
||||
expect(result.current.data).toEqual(mockData);
|
||||
});
|
||||
|
||||
it('should not fetch when correspondenceUuid is empty', () => {
|
||||
it('should not fetch when correspondencePublicId is empty', () => {
|
||||
const { wrapper } = createTestQueryClient();
|
||||
const { result } = renderHook(
|
||||
() => useCirculationsByCorrespondence(''),
|
||||
|
||||
@@ -6,10 +6,10 @@ export const circulationKeys = {
|
||||
byCorrespondence: (uuid: string) => ['circulations', 'byCorrespondence', uuid] as const,
|
||||
};
|
||||
|
||||
export function useCirculationsByCorrespondence(correspondenceUuid: string) {
|
||||
export function useCirculationsByCorrespondence(correspondencePublicId: string) {
|
||||
return useQuery({
|
||||
queryKey: circulationKeys.byCorrespondence(correspondenceUuid),
|
||||
queryFn: () => circulationService.getByCorrespondenceUuid(correspondenceUuid),
|
||||
enabled: !!correspondenceUuid,
|
||||
queryKey: circulationKeys.byCorrespondence(correspondencePublicId),
|
||||
queryFn: () => circulationService.getByCorrespondenceUuid(correspondencePublicId),
|
||||
enabled: !!correspondencePublicId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,31 +3,31 @@ import { dashboardService } from '@/lib/services/dashboard.service';
|
||||
|
||||
export const dashboardKeys = {
|
||||
all: ['dashboard'] as const,
|
||||
stats: () => [...dashboardKeys.all, 'stats'] as const,
|
||||
activity: () => [...dashboardKeys.all, 'activity'] as const,
|
||||
pending: () => [...dashboardKeys.all, 'pending'] 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() {
|
||||
export function useDashboardStats(projectId?: string | null) {
|
||||
return useQuery({
|
||||
queryKey: dashboardKeys.stats(),
|
||||
queryFn: dashboardService.getStats,
|
||||
queryKey: dashboardKeys.stats(projectId),
|
||||
queryFn: () => dashboardService.getStats(projectId),
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
});
|
||||
}
|
||||
|
||||
export function useRecentActivity() {
|
||||
export function useRecentActivity(projectId?: string | null) {
|
||||
return useQuery({
|
||||
queryKey: dashboardKeys.activity(),
|
||||
queryFn: dashboardService.getRecentActivity,
|
||||
queryKey: dashboardKeys.activity(projectId),
|
||||
queryFn: () => dashboardService.getRecentActivity(projectId),
|
||||
staleTime: 1 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
|
||||
export function usePendingTasks() {
|
||||
export function usePendingTasks(projectId?: string | null) {
|
||||
return useQuery({
|
||||
queryKey: dashboardKeys.pending(),
|
||||
queryFn: dashboardService.getPendingTasks,
|
||||
queryKey: dashboardKeys.pending(projectId),
|
||||
queryFn: () => dashboardService.getPendingTasks(projectId),
|
||||
staleTime: 2 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user