add start-end-date range for match list and fix pagination
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "no-copy-frontend",
|
"name": "no-copy-frontend",
|
||||||
"version": "0.115.0",
|
"version": "0.116.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 2999",
|
"dev": "next dev -p 2999",
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export interface FileDetails {
|
|||||||
|
|
||||||
interface PageProps {
|
interface PageProps {
|
||||||
params: Promise<{ id: string }>;
|
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({
|
export default async function Page({
|
||||||
@@ -56,7 +56,7 @@ export default async function Page({
|
|||||||
searchParams
|
searchParams
|
||||||
}: PageProps) {
|
}: PageProps) {
|
||||||
const { id } = await params;
|
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;
|
const currentPage = Number(page) || 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -80,6 +80,8 @@ export default async function Page({
|
|||||||
fileId={id}
|
fileId={id}
|
||||||
violationId={violationId}
|
violationId={violationId}
|
||||||
caseType={caseType}
|
caseType={caseType}
|
||||||
|
startDate={startDate}
|
||||||
|
endDate={endDate}
|
||||||
/>
|
/>
|
||||||
{/* <FilePageNote /> */}
|
{/* <FilePageNote /> */}
|
||||||
{/* <FilePageViolationInfo /> */}
|
{/* <FilePageViolationInfo /> */}
|
||||||
|
|||||||
@@ -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');
|
const token = await getSessionData('token');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -138,13 +138,14 @@ export async function getFileMatches(fileId: string, page: number, status?: stri
|
|||||||
msg_id: 30009,
|
msg_id: 30009,
|
||||||
message_body: {
|
message_body: {
|
||||||
file_id: fileId,
|
file_id: fileId,
|
||||||
page: page,
|
page: (page > 0 ? page - 1 : 0),
|
||||||
size: 5,
|
size: 5,
|
||||||
sort_direction: 'desc',
|
sort_direction: 'desc',
|
||||||
token: token,
|
token: token,
|
||||||
status: status,
|
status: status,
|
||||||
...(violationId && { action: 'getByViolationId' }),
|
...(violationId && { action: 'getByViolationId' }),
|
||||||
...(violationId && { violation_id: violationId })
|
...(violationId && { violation_id: violationId }),
|
||||||
|
...((startDate && endDate) && { start_date: startDate, end_date: endDate })
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ interface ViolationFile {
|
|||||||
has_previous: boolean;
|
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({
|
return useQuery({
|
||||||
queryKey: ['fileViolations', id, page, status, violationId],
|
queryKey: ['fileViolations', id, page, status, violationId, startDate, endDate],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
return getFileMatches(id, page, status, violationId)
|
return getFileMatches(id, page, status, violationId, startDate, endDate)
|
||||||
},
|
},
|
||||||
select: (data: ViolationFile | null) => {
|
select: (data: ViolationFile | null) => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|||||||
@@ -17,13 +17,17 @@ export default function FilePageViolationsList({
|
|||||||
fileId,
|
fileId,
|
||||||
status,
|
status,
|
||||||
violationId,
|
violationId,
|
||||||
caseType
|
caseType,
|
||||||
|
startDate,
|
||||||
|
endDate
|
||||||
}: {
|
}: {
|
||||||
currentPage: number,
|
currentPage: number,
|
||||||
fileId: string,
|
fileId: string,
|
||||||
status: string | undefined,
|
status: string | undefined,
|
||||||
violationId?: string | undefined
|
violationId?: string | undefined,
|
||||||
caseType?: 'claim' | 'complaint'
|
caseType?: 'claim' | 'complaint',
|
||||||
|
startDate?: string,
|
||||||
|
endDate?: string
|
||||||
}) {
|
}) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
const tStatus = useTranslations('Match-status');
|
const tStatus = useTranslations('Match-status');
|
||||||
@@ -38,7 +42,7 @@ export default function FilePageViolationsList({
|
|||||||
current_page: number;
|
current_page: number;
|
||||||
} | null>(null);
|
} | 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) {
|
function selectHandler(violation: ViolationFileDetail) {
|
||||||
setSelectedViolation(violation);
|
setSelectedViolation(violation);
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ export default function ViolationsTable() {
|
|||||||
return nameWithoutExtension.substring(0, maxNameLength) + '...';
|
return nameWithoutExtension.substring(0, maxNameLength) + '...';
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = useMemo<ColumnDef<FileViolation>[]>(
|
const baseColumns = useMemo<ColumnDef<FileViolation>[]>(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
accessorKey: 'supportId',
|
accessorKey: 'supportId',
|
||||||
@@ -276,32 +276,38 @@ export default function ViolationsTable() {
|
|||||||
{row.original.countLawCase}
|
{row.original.countLawCase}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
}
|
||||||
{
|
|
||||||
accessorKey: 'actions',
|
|
||||||
header: () => (
|
|
||||||
<div className="column">
|
|
||||||
<span>{t('actions')}</span>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
cell: ({ row }) => (
|
|
||||||
<div className="actions">
|
|
||||||
<div className="actions-group">
|
|
||||||
<Link
|
|
||||||
href={`/pages/file/${row.original.fileId}`}
|
|
||||||
className="bg-violet-500 hover:bg-violet-600"
|
|
||||||
title={t('view')}
|
|
||||||
>
|
|
||||||
<IconEye />
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
[t, viewport]
|
[t, viewport]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const actionsColumn = useMemo<ColumnDef<FileViolation>>(
|
||||||
|
() => ({
|
||||||
|
accessorKey: 'actions',
|
||||||
|
header: () => (
|
||||||
|
<div className="column">
|
||||||
|
<span>{t('actions')}</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className="actions">
|
||||||
|
<div className="actions-group">
|
||||||
|
<Link
|
||||||
|
href={`/pages/file/${row.original.fileId}?startDate=${dateRange.start_date || ''}&endDate=${dateRange.end_date || ''}`}
|
||||||
|
className="bg-violet-500 hover:bg-violet-600"
|
||||||
|
title={t('view')}
|
||||||
|
>
|
||||||
|
<IconEye />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
[t, dateRange.start_date, dateRange.end_date]
|
||||||
|
);
|
||||||
|
|
||||||
|
const columns = useMemo(() => [...baseColumns, actionsColumn], [baseColumns, actionsColumn]);
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data: violationData?.content || [],
|
data: violationData?.content || [],
|
||||||
columns,
|
columns,
|
||||||
|
|||||||
Reference in New Issue
Block a user