2026-02-13 12:50:58 +07:00
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
import { getUserFilesInfo } from '@/app/actions/action';
|
|
|
|
|
|
|
|
|
|
export interface FilesInfo {
|
|
|
|
|
total: {
|
|
|
|
|
size: number;
|
|
|
|
|
quantity: number;
|
|
|
|
|
check: number;
|
|
|
|
|
violation: number;
|
|
|
|
|
protected: number;
|
|
|
|
|
};
|
|
|
|
|
images: {
|
|
|
|
|
quantity: number;
|
|
|
|
|
size: number;
|
|
|
|
|
check: number;
|
|
|
|
|
violation: number;
|
|
|
|
|
protected: number;
|
|
|
|
|
};
|
|
|
|
|
videos: {
|
|
|
|
|
quantity: number;
|
|
|
|
|
size: number;
|
|
|
|
|
check: number;
|
|
|
|
|
violation: number;
|
|
|
|
|
protected: number;
|
|
|
|
|
};
|
|
|
|
|
audios: {
|
|
|
|
|
quantity: number;
|
|
|
|
|
size: number;
|
|
|
|
|
check: number;
|
|
|
|
|
violation: number;
|
|
|
|
|
protected: number;
|
|
|
|
|
};
|
|
|
|
|
documents: {
|
|
|
|
|
quantity: number;
|
|
|
|
|
size: number;
|
|
|
|
|
check: number;
|
|
|
|
|
violation: number;
|
|
|
|
|
protected: number;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const useUserFilesInfo = () => {
|
|
|
|
|
return useQuery({
|
|
|
|
|
queryKey: ['userFilesInfo'],
|
|
|
|
|
queryFn: getUserFilesInfo,
|
2026-02-13 13:44:03 +07:00
|
|
|
select: (data): FilesInfo | null => {
|
2026-02-13 12:50:58 +07:00
|
|
|
if (!data) {
|
|
|
|
|
return {
|
|
|
|
|
total: { size: 0, quantity: 0, check: 0, violation: 0, protected: 0 },
|
|
|
|
|
images: { quantity: 0, size: 0, check: 0, violation: 0, protected: 0 },
|
|
|
|
|
videos: { quantity: 0, size: 0, check: 0, violation: 0, protected: 0 },
|
|
|
|
|
audios: { quantity: 0, size: 0, check: 0, violation: 0, protected: 0 },
|
|
|
|
|
documents: { quantity: 0, size: 0, check: 0, violation: 0, protected: 0 },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
total: {
|
|
|
|
|
size: data.all_files_size,
|
|
|
|
|
quantity: data.all_files_quantity,
|
|
|
|
|
check: data.all_files_check,
|
|
|
|
|
violation: data.all_files_violation,
|
|
|
|
|
protected: data.protected_files_count,
|
|
|
|
|
},
|
|
|
|
|
images: {
|
|
|
|
|
quantity: data.images_quantity,
|
|
|
|
|
size: data.images_size,
|
|
|
|
|
check: data.images_check,
|
|
|
|
|
violation: data.images_violations,
|
|
|
|
|
protected: data.protected_image_files_count,
|
|
|
|
|
},
|
|
|
|
|
videos: {
|
|
|
|
|
quantity: data.videos_quantity,
|
|
|
|
|
size: data.videos_size,
|
|
|
|
|
check: data.videos_check,
|
|
|
|
|
violation: data.videos_violations,
|
|
|
|
|
protected: data.protected_video_files_count,
|
|
|
|
|
},
|
|
|
|
|
audios: {
|
|
|
|
|
quantity: data.audios_quantity,
|
|
|
|
|
size: data.audios_size,
|
|
|
|
|
check: data.audios_check,
|
|
|
|
|
violation: data.audios_violations,
|
|
|
|
|
protected: data.protected_audio_files_count,
|
|
|
|
|
},
|
|
|
|
|
documents: {
|
|
|
|
|
quantity: data.document_quantity,
|
|
|
|
|
size: data.document_size,
|
|
|
|
|
check: data.document_check,
|
|
|
|
|
violation: data.document_violations,
|
|
|
|
|
protected: data.protected_document_files_count,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|