Files
no-copy-admin-panel-frontend/src/app/lib/prefetch-queries.ts
T

45 lines
1.6 KiB
TypeScript

import { QueryClient } from '@tanstack/react-query';
import { fetchTokensGeneralStatistic, fetchProtectedContentGeneralStatistic, fetchTariffStatistic, fetchUserFilesTopStatistic, fetchUserGeneralStatistic, fetchViolationGeneralStatistic } from '@/app/actions/statisticActions';
import { useSubscribeGeneralStatistic } from '@/app/hooks/react-query/dashboard/useSubscribeGeneralStatistic';
import { fetchEmployeInfo } from '@/app/actions/stuffActions';
export async function prefetchLayoutQueries(queryClient: QueryClient) {
await Promise.all([
queryClient.prefetchQuery({
queryKey: ['fetchEmployeInfo'],
queryFn: () => fetchEmployeInfo()
}),
queryClient.prefetchQuery({
queryKey: ['incomeGeneralStatistic'],
queryFn: () => fetchTokensGeneralStatistic()
}),
queryClient.prefetchQuery({
queryKey: ['protectedContentGeneralStatistic'],
queryFn: () => fetchProtectedContentGeneralStatistic()
}),
queryClient.prefetchQuery({
queryKey: ['subscribeGeneralStatistic'],
queryFn: () => useSubscribeGeneralStatistic()
}),
queryClient.prefetchQuery({
queryKey: ['tariffStatistic'],
queryFn: () => fetchTariffStatistic()
}),
queryClient.prefetchQuery({
queryKey: ['tokensGeneralStatistic'],
queryFn: () => fetchTokensGeneralStatistic()
}),
queryClient.prefetchQuery({
queryKey: ['userFilesTopStatistic'],
queryFn: () => fetchUserFilesTopStatistic()
}),
queryClient.prefetchQuery({
queryKey: ['userGeneralStatistic'],
queryFn: () => fetchUserGeneralStatistic()
}),
queryClient.prefetchQuery({
queryKey: ['violationGeneralStatistic'],
queryFn: () => fetchViolationGeneralStatistic()
}),
]);
}