// app/ui/violations/file-page/violation-page-violations-list.tsx 'use client' import { useTranslations } from 'next-intl'; import { useRouter, usePathname } from 'next/navigation'; import { useEffect } from 'react'; 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 } export default function ViolationPageViolationsList({ fileViolations, currentPage, fileId }: { fileViolations: ViolationFile, currentPage: number, fileId: string }) { const t = useTranslations('Global'); const router = useRouter(); const pathname = usePathname(); if (!fileViolations?.violations) { return null; } const handlePageChange = (page: number) => { router.push(`${pathname}?page=${page}`); }; const getPageNumbers = () => { const pages = []; const maxVisible = 5; const total = fileViolations.total_pages; let start = Math.max(1, currentPage - Math.floor(maxVisible / 2)); let end = Math.min(total, start + maxVisible - 1); if (end - start + 1 < maxVisible) { start = Math.max(1, end - maxVisible + 1); } for (let i = start; i <= end; i++) { pages.push(i); } return pages; }; return (

Все нарушения этого файла

Всего: {fileViolations.total_elements} | Страница {fileViolations.current_page} из {fileViolations.total_pages}
{fileViolations.violations.map(item => { return (
{item.page_title} {item.status}
{item.host}
{t('open')}
); })}
{fileViolations.total_pages > 1 && (
{fileViolations.has_previous && ( )} {getPageNumbers().map(pageNum => ( ))} {fileViolations.has_next && ( )}
)}
); }