2026-03-26 17:30:30 +07:00
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
import { getFileViolations } from '@/app/actions/violationActions';
|
|
|
|
|
|
|
|
|
|
export interface ViolationFileDetail {
|
|
|
|
|
id: number;
|
|
|
|
|
url: string;
|
|
|
|
|
page_url: string;
|
|
|
|
|
page_title: string;
|
|
|
|
|
host: string;
|
|
|
|
|
status: string;
|
|
|
|
|
created_date: string;
|
|
|
|
|
file_id: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ViolationFile {
|
|
|
|
|
violations: ViolationFileDetail[],
|
|
|
|
|
total_elements: number,
|
|
|
|
|
total_pages: number,
|
|
|
|
|
current_page: number,
|
|
|
|
|
page_size: number,
|
|
|
|
|
has_next: boolean,
|
|
|
|
|
has_previous: boolean
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-27 16:45:58 +07:00
|
|
|
export const useFileViolations = (id: string, page: number, status?: string) => {
|
2026-03-26 17:30:30 +07:00
|
|
|
return useQuery({
|
2026-03-27 16:45:58 +07:00
|
|
|
queryKey: ['fileViolations', id, page, status],
|
2026-03-26 17:30:30 +07:00
|
|
|
queryFn: () => {
|
2026-03-27 16:45:58 +07:00
|
|
|
return getFileViolations(id, page, status)
|
2026-03-26 17:30:30 +07:00
|
|
|
},
|
|
|
|
|
select: (data: ViolationFile | null) => {
|
|
|
|
|
if (!data) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
},
|
|
|
|
|
retry: false
|
|
|
|
|
});
|
|
|
|
|
};
|