'use client' import { useQuery } from '@tanstack/react-query'; import { getUserFilesData } from '@/app/actions/fileEntity'; import { useEffect, useState, useRef } from 'react'; import { FileTypeIcon } from '@/app/components/FileTypeIcon'; import { convertBytes } from '@/app/lib/convertBytes'; import { useTranslations } from 'next-intl'; import { useClickOutside } from '@/app/hooks/useClickOutside'; import Link from 'next/link'; import { getViolationFilesArray } from '@/app/actions/violationActions'; import { IconEye } from '@/app/ui/icons/icons'; interface ViolationFile { createdAt: string; fileId: string; fileName: string; fileSize: number; latestViolationDate: string; mimeType: string; status: string; supportId: number; violationCount: number; } export default function DashboardUserViolations() { const { data: violationData, isLoading, isError, error, } = useQuery({ queryKey: ['violationData'], queryFn: () => getViolationFilesArray(), select: (data) => { return data?.slice(0, 5) || []; }, /* refetchInterval: 30000 */ }); const t = useTranslations('Global'); const formatDate = (timestamp: number | string) => { const date = new Date(timestamp); const day = date.getDate().toString().padStart(2, '0'); const month = (date.getMonth() + 1).toString().padStart(2, '0'); const year = date.getFullYear(); return `${day}.${month}.${year}`; }; return (

{t('violation')}

{t('all')}
{violationData?.length ? ( violationData?.map((file) => { return (
{file.fileName}
{file.createdAt ? formatDate(file.createdAt) : 0} • {t('violations-found')}: {file.violationCount ? file.violationCount : 0}
) }) ) : (
{t('there-are-no-files-yet')}
)}
) }