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