From 36b4a3b48112fcf9f6a847eb1e7a519ed7ddcda1 Mon Sep 17 00:00:00 2001 From: smanylov Date: Thu, 21 May 2026 18:20:50 +0700 Subject: [PATCH] add start-end-date range for match list and fix pagination --- package.json | 2 +- src/app/[locale]/pages/file/[id]/page.tsx | 6 ++- src/app/actions/violationActions.ts | 7 +-- .../hooks/react-query/useFileViolations.ts | 6 +-- .../file-page-violations-list.tsx | 12 +++-- src/app/ui/violations/violations-table.tsx | 52 +++++++++++-------- 6 files changed, 49 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 9b636cd..8ae5339 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "no-copy-frontend", - "version": "0.115.0", + "version": "0.116.0", "private": true, "scripts": { "dev": "next dev -p 2999", diff --git a/src/app/[locale]/pages/file/[id]/page.tsx b/src/app/[locale]/pages/file/[id]/page.tsx index 416adc5..8dff4f9 100644 --- a/src/app/[locale]/pages/file/[id]/page.tsx +++ b/src/app/[locale]/pages/file/[id]/page.tsx @@ -48,7 +48,7 @@ export interface FileDetails { interface PageProps { params: Promise<{ id: string }>; - searchParams: Promise<{ page?: string, status?: string , violationId?: string, caseType?: 'complaint' | 'claim'}>; + searchParams: Promise<{ page?: string, status?: string, violationId?: string, caseType?: 'complaint' | 'claim', startDate: string, endDate: string }>; } export default async function Page({ @@ -56,7 +56,7 @@ export default async function Page({ searchParams }: PageProps) { const { id } = await params; - const { page, status, violationId, caseType } = await searchParams; + const { page, status, violationId, caseType, startDate, endDate } = await searchParams; const currentPage = Number(page) || 1; try { @@ -80,6 +80,8 @@ export default async function Page({ fileId={id} violationId={violationId} caseType={caseType} + startDate={startDate} + endDate={endDate} /> {/* */} {/* */} diff --git a/src/app/actions/violationActions.ts b/src/app/actions/violationActions.ts index b3bbb6e..006b492 100644 --- a/src/app/actions/violationActions.ts +++ b/src/app/actions/violationActions.ts @@ -127,7 +127,7 @@ export async function getViolationFilesArray(props: { } } -export async function getFileMatches(fileId: string, page: number, status?: string, violationId?: string) { +export async function getFileMatches(fileId: string, page: number, status?: string, violationId?: string, startDate?: string, endDate?: string) { const token = await getSessionData('token'); try { @@ -138,13 +138,14 @@ export async function getFileMatches(fileId: string, page: number, status?: stri msg_id: 30009, message_body: { file_id: fileId, - page: page, + page: (page > 0 ? page - 1 : 0), size: 5, sort_direction: 'desc', token: token, status: status, ...(violationId && { action: 'getByViolationId' }), - ...(violationId && { violation_id: violationId }) + ...(violationId && { violation_id: violationId }), + ...((startDate && endDate) && { start_date: startDate, end_date: endDate }) } }), headers: { diff --git a/src/app/hooks/react-query/useFileViolations.ts b/src/app/hooks/react-query/useFileViolations.ts index 9c8242e..22584c5 100644 --- a/src/app/hooks/react-query/useFileViolations.ts +++ b/src/app/hooks/react-query/useFileViolations.ts @@ -24,11 +24,11 @@ interface ViolationFile { has_previous: boolean; } -export const useFileViolations = (id: string, page: number, status?: string, violationId?: string) => { +export const useFileViolations = (id: string, page: number, status?: string, violationId?: string, startDate?: string, endDate?: string,) => { return useQuery({ - queryKey: ['fileViolations', id, page, status, violationId], + queryKey: ['fileViolations', id, page, status, violationId, startDate, endDate], queryFn: () => { - return getFileMatches(id, page, status, violationId) + return getFileMatches(id, page, status, violationId, startDate, endDate) }, select: (data: ViolationFile | null) => { if (!data) { diff --git a/src/app/ui/file-page/violation-table/file-page-violations-list.tsx b/src/app/ui/file-page/violation-table/file-page-violations-list.tsx index dfd9cb7..ae93058 100644 --- a/src/app/ui/file-page/violation-table/file-page-violations-list.tsx +++ b/src/app/ui/file-page/violation-table/file-page-violations-list.tsx @@ -17,13 +17,17 @@ export default function FilePageViolationsList({ fileId, status, violationId, - caseType + caseType, + startDate, + endDate }: { currentPage: number, fileId: string, status: string | undefined, - violationId?: string | undefined - caseType?: 'claim' | 'complaint' + violationId?: string | undefined, + caseType?: 'claim' | 'complaint', + startDate?: string, + endDate?: string }) { const t = useTranslations('Global'); const tStatus = useTranslations('Match-status'); @@ -38,7 +42,7 @@ export default function FilePageViolationsList({ current_page: number; } | null>(null); - const { data: fileViolations, error, isPending } = useFileViolations(fileId, currentPage, status, violationId); + const { data: fileViolations, error, isPending } = useFileViolations(fileId, currentPage, status, violationId, startDate, endDate); function selectHandler(violation: ViolationFileDetail) { setSelectedViolation(violation); diff --git a/src/app/ui/violations/violations-table.tsx b/src/app/ui/violations/violations-table.tsx index 32a2612..4bd41eb 100644 --- a/src/app/ui/violations/violations-table.tsx +++ b/src/app/ui/violations/violations-table.tsx @@ -147,7 +147,7 @@ export default function ViolationsTable() { return nameWithoutExtension.substring(0, maxNameLength) + '...'; }; - const columns = useMemo[]>( + const baseColumns = useMemo[]>( () => [ { accessorKey: 'supportId', @@ -276,32 +276,38 @@ export default function ViolationsTable() { {row.original.countLawCase} ), - }, - { - accessorKey: 'actions', - header: () => ( -
- {t('actions')} -
- ), - cell: ({ row }) => ( -
-
- - - -
-
- ), - }, + } ], [t, viewport] ); + const actionsColumn = useMemo>( + () => ({ + accessorKey: 'actions', + header: () => ( +
+ {t('actions')} +
+ ), + cell: ({ row }) => ( +
+
+ + + +
+
+ ), + }), + [t, dateRange.start_date, dateRange.end_date] + ); + + const columns = useMemo(() => [...baseColumns, actionsColumn], [baseColumns, actionsColumn]); + const table = useReactTable({ data: violationData?.content || [], columns,