update useFileViolations
This commit is contained in:
@@ -8,7 +8,6 @@ import FilePageFileInfo from '@/app/ui/file-page/file-page-file-info';
|
||||
import FilePageActions from '@/app/ui/file-page/file-page-actions';
|
||||
import FilePageViolationsList from '@/app/ui/file-page/violation-table/file-page-violations-list';
|
||||
import FilePageNote from '@/app/ui/file-page/file-page-note';
|
||||
import { getFileViolations } from '@/app/actions/violationActions';
|
||||
import { viewFileInfo } from '@/app/actions/fileEntity';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import FilePageNotFound from '@/app/ui/file-page/file-page-file-not-found';
|
||||
@@ -56,7 +55,6 @@ export default async function Page({
|
||||
params,
|
||||
searchParams
|
||||
}: PageProps) {
|
||||
/* const t = useTranslations('Global'); */
|
||||
const { id } = await params;
|
||||
const { page } = await searchParams;
|
||||
const currentPage = Number(page) || 1;
|
||||
|
||||
@@ -147,7 +147,7 @@ export async function fetchViolationStats() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getFileViolations(fileId: string, page: number) {
|
||||
export async function getFileViolations(fileId: string, page: number, status?: string) {
|
||||
const token = await getSessionData('token');
|
||||
|
||||
try {
|
||||
@@ -161,7 +161,8 @@ export async function getFileViolations(fileId: string, page: number) {
|
||||
page: page,
|
||||
size: 5,
|
||||
sort_direction: "desc",
|
||||
token: token
|
||||
token: token,
|
||||
status: status
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
|
||||
@@ -22,11 +22,11 @@ interface ViolationFile {
|
||||
has_previous: boolean
|
||||
}
|
||||
|
||||
export const useFileViolations = (id: string, page: number) => {
|
||||
export const useFileViolations = (id: string, page: number, status?: string) => {
|
||||
return useQuery({
|
||||
queryKey: ['fileViolations', id, page],
|
||||
queryKey: ['fileViolations', id, page, status],
|
||||
queryFn: () => {
|
||||
return getFileViolations(id, page)
|
||||
return getFileViolations(id, page, status)
|
||||
},
|
||||
select: (data: ViolationFile | null) => {
|
||||
if (!data) {
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function FilePageViolationsList({
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const [selectedViolation, setSelectedViolation] = useState<ViolationFileDetail | null>(null);
|
||||
const { data: fileViolations } = useFileViolations(fileId, currentPage);
|
||||
const { data: fileViolations } = useFileViolations(fileId, currentPage, '');
|
||||
|
||||
if (!fileViolations?.violations) {
|
||||
return null;
|
||||
@@ -78,12 +78,6 @@ export default function FilePageViolationsList({
|
||||
selectHandler(item);
|
||||
}}
|
||||
>
|
||||
{/* <div className="source-header">
|
||||
<div className="source-image">
|
||||
<img src={item.url} alt="" />
|
||||
</div>
|
||||
|
||||
</div> */}
|
||||
<div
|
||||
className="source-header-left"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user