add relocate from violations-last-combined-cases to match-list
This commit is contained in:
@@ -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 }>;
|
searchParams: Promise<{ page?: string, status?: string , violationId?: string, caseType?: 'complaint' | 'claim'}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 } = await searchParams;
|
const { page, status, violationId, caseType } = await searchParams;
|
||||||
const currentPage = Number(page) || 1;
|
const currentPage = Number(page) || 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -78,6 +78,8 @@ export default async function Page({
|
|||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
status={status}
|
status={status}
|
||||||
fileId={id}
|
fileId={id}
|
||||||
|
violationId={violationId}
|
||||||
|
caseType={caseType}
|
||||||
/>
|
/>
|
||||||
{/* <FilePageNote /> */}
|
{/* <FilePageNote /> */}
|
||||||
{/* <FilePageViolationInfo /> */}
|
{/* <FilePageViolationInfo /> */}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ export async function fetchViolationStats() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getFileViolations(fileId: string, page: number, status?: string) {
|
export async function getFileViolations(fileId: string, page: number, status?: string, violationId?: string) {
|
||||||
const token = await getSessionData('token');
|
const token = await getSessionData('token');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -159,9 +159,11 @@ export async function getFileViolations(fileId: string, page: number, status?: s
|
|||||||
file_id: fileId,
|
file_id: fileId,
|
||||||
page: page,
|
page: page,
|
||||||
size: 5,
|
size: 5,
|
||||||
sort_direction: "desc",
|
sort_direction: 'desc',
|
||||||
token: token,
|
token: token,
|
||||||
status: status
|
status: status,
|
||||||
|
...(violationId && { action: 'getByViolationId' }),
|
||||||
|
...(violationId && { violation_id: violationId })
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -362,6 +364,7 @@ export async function createComplaint(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchComplainInfo(id: number) {
|
export async function fetchComplainInfo(id: number) {
|
||||||
|
const token = await getSessionData('token');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||||
@@ -371,7 +374,8 @@ export async function fetchComplainInfo(id: number) {
|
|||||||
msg_id: 30013,
|
msg_id: 30013,
|
||||||
message_body: {
|
message_body: {
|
||||||
action: 'get_by_violation',
|
action: 'get_by_violation',
|
||||||
violation_id: id
|
violation_id: id,
|
||||||
|
token
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ interface ViolationFile {
|
|||||||
has_previous: boolean;
|
has_previous: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useFileViolations = (id: string, page: number, status?: string) => {
|
export const useFileViolations = (id: string, page: number, status?: string, violationId?: string) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['fileViolations', id, page, status],
|
queryKey: ['fileViolations', id, page, status, violationId],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
return getFileViolations(id, page, status)
|
return getFileViolations(id, page, status, violationId)
|
||||||
},
|
},
|
||||||
select: (data: ViolationFile | null) => {
|
select: (data: ViolationFile | null) => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|||||||
@@ -4,19 +4,20 @@ import { fetchLastCase, ComplaintsCaseQueryParams } from '@/app/actions/violatio
|
|||||||
interface Case {
|
interface Case {
|
||||||
amount: number;
|
amount: number;
|
||||||
content: null | string;
|
content: null | string;
|
||||||
createdAt: string;
|
created_at: string;
|
||||||
description: string;
|
description: string;
|
||||||
id: number;
|
id: number;
|
||||||
lawyer: null | string;
|
lawyer: null | string;
|
||||||
name: string;
|
name: string;
|
||||||
pageNumber: number;
|
page_number: number;
|
||||||
pageSize: number;
|
page_size: number;
|
||||||
priority: "HIGH" | "MEDIUM" | "LOW";
|
priority: "HIGH" | "MEDIUM" | "LOW";
|
||||||
totalElements: number;
|
total_elements: number;
|
||||||
totalPages: number;
|
total_pages: number;
|
||||||
type: "ACTIVE" | "INACTIVE" | string;
|
type: "ACTIVE" | "INACTIVE" | string;
|
||||||
updatedAt: string;
|
updated_at: string;
|
||||||
violationId: number;
|
violation_id: number;
|
||||||
|
file_id: string;
|
||||||
}
|
}
|
||||||
export interface useLastCase {
|
export interface useLastCase {
|
||||||
content: Case[],
|
content: Case[],
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
import { fetchLastComplaint, ComplaintsCaseQueryParams } from '@/app/actions/violationActions';
|
import { fetchLastComplaint, ComplaintsCaseQueryParams } from '@/app/actions/violationActions';
|
||||||
|
|
||||||
interface Complaint {
|
interface Complaint {
|
||||||
complaint_text: string,
|
complaint_text: string;
|
||||||
created_at: string,
|
created_at: string;
|
||||||
email: string,
|
email: string;
|
||||||
id: number,
|
id: number;
|
||||||
not_moderated: boolean,
|
not_moderated: boolean;
|
||||||
status: "CREATED" | string,
|
status: "CREATED" | string;
|
||||||
updated_at: string,
|
updated_at: string;
|
||||||
violation_id: number,
|
violation_id: number;
|
||||||
|
file_id: string;
|
||||||
}
|
}
|
||||||
export interface useLastComplaint {
|
export interface useLastComplaint {
|
||||||
content: Complaint[],
|
content: Complaint[],
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ type UpdateStatusHandler = (id: number, status: MatchStatus) => Promise<boolean>
|
|||||||
|
|
||||||
const STATUSES_IN_WORK = ['COMPLAINT_IN_WORK', 'LEGAL_IN_WORK', 'COMPLAINT_AND_LEGAL_IN_WORK'];
|
const STATUSES_IN_WORK = ['COMPLAINT_IN_WORK', 'LEGAL_IN_WORK', 'COMPLAINT_AND_LEGAL_IN_WORK'];
|
||||||
|
|
||||||
type TabType = 'complaint' | 'legal'
|
type TabType = 'complaint' | 'claim'
|
||||||
|
|
||||||
export default function FilePageViolationInfoTabs({ selectedViolation, updateStatusHandler }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler }) {
|
export default function FilePageViolationInfoTabs({ selectedViolation, updateStatusHandler, caseType }: { selectedViolation: ViolationFileDetail, updateStatusHandler: UpdateStatusHandler, caseType?: 'claim' | 'complaint' }) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
const [activeTab, setActiveTab] = useState<TabType>('complaint');
|
const [activeTab, setActiveTab] = useState<TabType>('complaint');
|
||||||
const [showTabs, setShowTabs] = useState(false);
|
const [showTabs, setShowTabs] = useState(false);
|
||||||
@@ -25,20 +25,16 @@ export default function FilePageViolationInfoTabs({ selectedViolation, updateSta
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLocalViolation(selectedViolation);
|
setLocalViolation(selectedViolation);
|
||||||
}, [selectedViolation]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
if (caseType) {
|
||||||
console.log(localViolation.status);
|
setActiveTab(caseType)
|
||||||
}, [localViolation]);
|
}
|
||||||
|
}, [selectedViolation]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setShowTabs(false);
|
setShowTabs(false);
|
||||||
}, [localViolation.id]);
|
}, [localViolation.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log(userData);
|
|
||||||
}, [userData])
|
|
||||||
|
|
||||||
if (userData?.verifiedStatus !== "VERIFIED") {
|
if (userData?.verifiedStatus !== "VERIFIED") {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -85,7 +81,7 @@ export default function FilePageViolationInfoTabs({ selectedViolation, updateSta
|
|||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowTabs(true);
|
setShowTabs(true);
|
||||||
setActiveTab('legal');
|
setActiveTab('claim');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('file-a-claim')}
|
{t('file-a-claim')}
|
||||||
@@ -105,8 +101,8 @@ export default function FilePageViolationInfoTabs({ selectedViolation, updateSta
|
|||||||
{localViolation.status === 'COMPLAINT_IN_WORK' || localViolation.status === 'COMPLAINT_AND_LEGAL_IN_WORK' ? t('complaint') : t('file-a-complaint')}
|
{localViolation.status === 'COMPLAINT_IN_WORK' || localViolation.status === 'COMPLAINT_AND_LEGAL_IN_WORK' ? t('complaint') : t('file-a-complaint')}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`btn-s btn-primary ${activeTab === 'legal' ? 'active' : ''} ${localViolation.status === 'LEGAL_IN_WORK' || localViolation.status === 'COMPLAINT_AND_LEGAL_IN_WORK' ? '' : 'action'}`}
|
className={`btn-s btn-primary ${activeTab === 'claim' ? 'active' : ''} ${localViolation.status === 'LEGAL_IN_WORK' || localViolation.status === 'COMPLAINT_AND_LEGAL_IN_WORK' ? '' : 'action'}`}
|
||||||
onClick={() => setActiveTab('legal')}
|
onClick={() => setActiveTab('claim')}
|
||||||
>
|
>
|
||||||
{localViolation.status === 'LEGAL_IN_WORK' || localViolation.status === 'COMPLAINT_AND_LEGAL_IN_WORK' ? t('case') : t('file-a-claim')}
|
{localViolation.status === 'LEGAL_IN_WORK' || localViolation.status === 'COMPLAINT_AND_LEGAL_IN_WORK' ? t('case') : t('file-a-claim')}
|
||||||
</button>
|
</button>
|
||||||
@@ -119,7 +115,7 @@ export default function FilePageViolationInfoTabs({ selectedViolation, updateSta
|
|||||||
updateStatusHandler={updateStatusHandler}
|
updateStatusHandler={updateStatusHandler}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{activeTab === 'legal' && (
|
{activeTab === 'claim' && (
|
||||||
<CaseLegal
|
<CaseLegal
|
||||||
key={"legal_" + localViolation.id}
|
key={"legal_" + localViolation.id}
|
||||||
selectedViolation={localViolation}
|
selectedViolation={localViolation}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { createPortal } from 'react-dom';
|
|||||||
import { IconContentCopy, IconFollowToLink, IconFullScreen } from '@/app/ui/icons/icons';
|
import { IconContentCopy, IconFollowToLink, IconFullScreen } from '@/app/ui/icons/icons';
|
||||||
import { useViewport } from '@/app/hooks/useViewport';
|
import { useViewport } from '@/app/hooks/useViewport';
|
||||||
|
|
||||||
export default function FilePageViolationInfo({ selectedViolation }: { selectedViolation: ViolationFileDetail | null }) {
|
export default function FilePageViolationInfo({ selectedViolation, caseType }: { selectedViolation: ViolationFileDetail | null, caseType?: 'claim' | 'complaint' }) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
const tStatus = useTranslations('Match-status');
|
const tStatus = useTranslations('Match-status');
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -329,6 +329,7 @@ export default function FilePageViolationInfo({ selectedViolation }: { selectedV
|
|||||||
<FilePageViolationInfoTabs
|
<FilePageViolationInfoTabs
|
||||||
selectedViolation={selectedViolation}
|
selectedViolation={selectedViolation}
|
||||||
updateStatusHandler={updateStatusHandler}
|
updateStatusHandler={updateStatusHandler}
|
||||||
|
caseType={caseType}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,11 +15,15 @@ import Image from 'next/image';
|
|||||||
export default function FilePageViolationsList({
|
export default function FilePageViolationsList({
|
||||||
currentPage,
|
currentPage,
|
||||||
fileId,
|
fileId,
|
||||||
status
|
status,
|
||||||
|
violationId,
|
||||||
|
caseType
|
||||||
}: {
|
}: {
|
||||||
currentPage: number,
|
currentPage: number,
|
||||||
fileId: string,
|
fileId: string,
|
||||||
status: string | undefined
|
status: string | undefined,
|
||||||
|
violationId?: string | undefined
|
||||||
|
caseType?: 'claim' | 'complaint'
|
||||||
}) {
|
}) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
const tStatus = useTranslations('Match-status');
|
const tStatus = useTranslations('Match-status');
|
||||||
@@ -34,10 +38,13 @@ export default function FilePageViolationsList({
|
|||||||
current_page: number;
|
current_page: number;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
|
||||||
const { data: fileViolations, error, isPending } = useFileViolations(fileId, currentPage, status);
|
const { data: fileViolations, error, isPending } = useFileViolations(fileId, currentPage, status, violationId);
|
||||||
|
|
||||||
|
function selectHandler(violation: ViolationFileDetail) {
|
||||||
|
setSelectedViolation(violation);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(fileViolations);
|
|
||||||
if (fileViolations?.violations) {
|
if (fileViolations?.violations) {
|
||||||
setCachedPagination({
|
setCachedPagination({
|
||||||
total_pages: fileViolations.total_pages,
|
total_pages: fileViolations.total_pages,
|
||||||
@@ -45,6 +52,10 @@ export default function FilePageViolationsList({
|
|||||||
current_page: fileViolations.current_page
|
current_page: fileViolations.current_page
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (violationId && fileViolations?.violations.length) {
|
||||||
|
setSelectedViolation(fileViolations?.violations[0]);
|
||||||
|
}
|
||||||
}, [fileViolations]);
|
}, [fileViolations]);
|
||||||
|
|
||||||
const paginationData = fileViolations?.violations ? fileViolations : cachedPagination;
|
const paginationData = fileViolations?.violations ? fileViolations : cachedPagination;
|
||||||
@@ -59,9 +70,12 @@ export default function FilePageViolationsList({
|
|||||||
cachedCurrentPage={paginationData?.current_page}
|
cachedCurrentPage={paginationData?.current_page}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlePageChange = (page: number) => {
|
const handlePageChange = (page: number) => {
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
params.set('page', page.toString());
|
params.set('page', page.toString());
|
||||||
|
params.delete('violationId');
|
||||||
|
params.delete('caseType');
|
||||||
router.push(`${pathname}?${params.toString()}`, { scroll: false });
|
router.push(`${pathname}?${params.toString()}`, { scroll: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,6 +88,8 @@ export default function FilePageViolationsList({
|
|||||||
}
|
}
|
||||||
setSelectedViolation(null);
|
setSelectedViolation(null);
|
||||||
params.set('page', '1');
|
params.set('page', '1');
|
||||||
|
params.delete('violationId');
|
||||||
|
params.delete('caseType');
|
||||||
router.push(`${pathname}?${params.toString()}`, { scroll: false });
|
router.push(`${pathname}?${params.toString()}`, { scroll: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -97,10 +113,6 @@ export default function FilePageViolationsList({
|
|||||||
return pages;
|
return pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
function selectHandler(violation: ViolationFileDetail) {
|
|
||||||
setSelectedViolation(violation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="block-wrapper">
|
<div className="block-wrapper">
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
@@ -208,9 +220,10 @@ export default function FilePageViolationsList({
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{/* general info for match */}
|
{/* general info for match */}
|
||||||
<FilePageViolationInfo selectedViolation={selectedViolation} />
|
<FilePageViolationInfo selectedViolation={selectedViolation} caseType={caseType} />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{/* pagination */}
|
||||||
<div
|
<div
|
||||||
className="sources-list-pagination"
|
className="sources-list-pagination"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -37,11 +37,6 @@ export default function ViolationsLastCombinedCases() {
|
|||||||
sort_direction: 'desc'
|
sort_direction: 'desc'
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log(dataCases);
|
|
||||||
console.log(dataComplaint);
|
|
||||||
}, [dataComplaint, dataCases])
|
|
||||||
|
|
||||||
const getCombinedItems = () => {
|
const getCombinedItems = () => {
|
||||||
const complaints = (dataComplaint?.content || []).map(item => ({
|
const complaints = (dataComplaint?.content || []).map(item => ({
|
||||||
...item,
|
...item,
|
||||||
@@ -60,8 +55,8 @@ export default function ViolationsLastCombinedCases() {
|
|||||||
displayId: item.name,
|
displayId: item.name,
|
||||||
title: item.description,
|
title: item.description,
|
||||||
status: item.type,
|
status: item.type,
|
||||||
createdAt: item.createdAt,
|
createdAt: item.created_at,
|
||||||
updatedAt: item.updatedAt,
|
updatedAt: item.updated_at,
|
||||||
lawyer: item.lawyer,
|
lawyer: item.lawyer,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -219,12 +214,9 @@ export default function ViolationsLastCombinedCases() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Link
|
<Link
|
||||||
href={`/pages/file/${item.displayId}`}
|
href={`/pages/file/${item.file_id}?violationId=${item.violation_id}&caseType=${item.type}`}
|
||||||
className="mt-auto"
|
className="mt-auto"
|
||||||
title={t('view')}
|
title={t('view')}
|
||||||
onClick={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<IconEye />
|
<IconEye />
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
Reference in New Issue
Block a user