2025-12-26 14:03:57 +07:00
|
|
|
import { QueryClient } from '@tanstack/react-query';
|
2026-02-12 11:16:58 +07:00
|
|
|
import { getUserData, getUserFilesInfo, getBuildData } from '@/app/actions/action';
|
2025-12-26 16:10:42 +07:00
|
|
|
import { getUserFilesData } from '@/app/actions/fileEntity';
|
2026-02-11 20:47:40 +07:00
|
|
|
import { fetchReferralUserStats } from '@/app/actions/referralsActions';
|
2026-03-13 17:29:52 +07:00
|
|
|
import { getAllowedFilesExtensions } from '@/app/actions/fileUpload';
|
|
|
|
|
|
|
|
|
|
export interface allFilesExtensions {
|
|
|
|
|
videos: string[];
|
|
|
|
|
audios: string[];
|
|
|
|
|
images: string[];
|
|
|
|
|
documents: string[];
|
|
|
|
|
maxFileSize: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getAllFilesExtensions(): Promise<allFilesExtensions> {
|
|
|
|
|
const [video, audio, image, document] = await Promise.all([
|
|
|
|
|
getAllowedFilesExtensions('video'),
|
|
|
|
|
getAllowedFilesExtensions('audio'),
|
|
|
|
|
getAllowedFilesExtensions('image'),
|
|
|
|
|
getAllowedFilesExtensions('document')
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const result: allFilesExtensions = {
|
|
|
|
|
videos: video?.file_extension ? video.file_extension : [],
|
|
|
|
|
audios: audio?.file_extension ? audio.file_extension : [],
|
|
|
|
|
images: image?.file_extension ? image.file_extension : [],
|
|
|
|
|
documents: document?.file_extension ? document.file_extension : [],
|
|
|
|
|
maxFileSize: video?.max_file_size ? video.max_file_size : 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2025-12-26 14:03:57 +07:00
|
|
|
|
|
|
|
|
export async function prefetchLayoutQueries(queryClient: QueryClient) {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
queryClient.prefetchQuery({
|
|
|
|
|
queryKey: ['userData'],
|
|
|
|
|
queryFn: () => getUserData()
|
|
|
|
|
}),
|
|
|
|
|
queryClient.prefetchQuery({
|
|
|
|
|
queryKey: ['userFilesData'],
|
2025-12-29 16:08:38 +07:00
|
|
|
queryFn: () => {
|
2026-01-10 12:25:42 +07:00
|
|
|
return getUserFilesData(1, 10000);
|
2025-12-29 16:08:38 +07:00
|
|
|
},
|
2025-12-26 16:10:42 +07:00
|
|
|
staleTime: 30 * 1000
|
2025-12-26 14:03:57 +07:00
|
|
|
}),
|
2026-01-07 13:03:50 +07:00
|
|
|
queryClient.prefetchQuery({
|
|
|
|
|
queryKey: ['userFilesInfo'],
|
|
|
|
|
queryFn: () => getUserFilesInfo()
|
|
|
|
|
}),
|
2026-02-07 14:31:04 +07:00
|
|
|
queryClient.prefetchQuery({
|
|
|
|
|
queryKey: ['referralUserStats'],
|
|
|
|
|
queryFn: () => fetchReferralUserStats()
|
|
|
|
|
}),
|
2026-02-12 11:16:58 +07:00
|
|
|
queryClient.prefetchQuery({
|
|
|
|
|
queryKey: ['backendBuildDate'],
|
|
|
|
|
queryFn: async () => {
|
|
|
|
|
try {
|
|
|
|
|
const response = await getBuildData();
|
2026-02-13 12:57:45 +07:00
|
|
|
return response.buildTimeBack ?? null;
|
2026-02-12 11:16:58 +07:00
|
|
|
} catch (error) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}),
|
2026-03-13 17:29:52 +07:00
|
|
|
queryClient.prefetchQuery({
|
|
|
|
|
queryKey: ['allFilesExtensions'],
|
|
|
|
|
queryFn: () => getAllFilesExtensions(),
|
|
|
|
|
staleTime: 5 * 60 * 1000
|
|
|
|
|
}),
|
2025-12-26 14:03:57 +07:00
|
|
|
]);
|
|
|
|
|
}
|