add relocate from violations-last-combined-cases to match-list
This commit is contained in:
@@ -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"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user