refactor for file page
This commit is contained in:
+14
-14
@@ -1,17 +1,17 @@
|
|||||||
// app/files/[id]/page.tsx
|
// app/files/[id]/page.tsx
|
||||||
'use server'
|
'use server'
|
||||||
|
|
||||||
import ViolationPageTitle from '@/app/ui/violations/file-page/violation-page-title';
|
import FilePageTitle from '@/app/ui/file-page/file-page-title';
|
||||||
import ViolationPageViolationInfo from '@/app/ui/violations/file-page/violation-page-violation-info';
|
import FilePageViolationInfo from '@/app/ui/file-page/file-page-violation-info';
|
||||||
import ViolationPpageFileStatistic from '@/app/ui/violations/file-page/violation-page-file-statistic';
|
import ViolationPpageFileStatistic from '@/app/ui/file-page/file-page-file-statistic';
|
||||||
import ViolationPageFileInfo from '@/app/ui/violations/file-page/violation-page-file-info';
|
import FilePageFileInfo from '@/app/ui/file-page/file-page-file-info';
|
||||||
import ViolationPageActions from '@/app/ui/violations/file-page/violation-page-actions';
|
import FilePageActions from '@/app/ui/file-page/file-page-actions';
|
||||||
import ViolationPageViolationsList from '@/app/ui/violations/file-page/violation-page-violations-list';
|
import FilePageViolationsList from '@/app/ui/file-page/file-page-violations-list';
|
||||||
import ViolationPageNote from '@/app/ui/violations/file-page/violation-page-note';
|
import FilePageNote from '@/app/ui/file-page/file-page-note';
|
||||||
import { getFileViolations } from '@/app/actions/violationActions';
|
import { getFileViolations } from '@/app/actions/violationActions';
|
||||||
import { viewFileInfo } from '@/app/actions/fileEntity';
|
import { viewFileInfo } from '@/app/actions/fileEntity';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import ViolationFileNotFound from '@/app/ui/violations/file-page/violation-file-not-found';
|
import ViolationFileNotFound from '@/app/ui/file-page/file-page-file-not-found';
|
||||||
|
|
||||||
type MonitoringStatus = 'NONE' | 'MONITORING_DAILY' | 'MONITORING_WEEKLY' | 'MONITORING_MONTHLY';
|
type MonitoringStatus = 'NONE' | 'MONITORING_DAILY' | 'MONITORING_WEEKLY' | 'MONITORING_MONTHLY';
|
||||||
type MimeType = 'image' | 'video' | 'audio' | 'document';
|
type MimeType = 'image' | 'video' | 'audio' | 'document';
|
||||||
@@ -67,23 +67,23 @@ export default async function Page({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="violation-details">
|
<div className="violation-details">
|
||||||
<ViolationPageTitle fileInfo={fileInfo} />
|
<FilePageTitle fileInfo={fileInfo} />
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
className="grid grid-cols-[2fr_1fr] gap-3"
|
className="grid grid-cols-[2fr_1fr] gap-3"
|
||||||
>
|
>
|
||||||
<ViolationPageFileInfo fileInfo={fileInfo} />
|
<FilePageFileInfo fileInfo={fileInfo} />
|
||||||
{/* <ViolationPageActions /> */}
|
{/* <FilePageActions /> */}
|
||||||
<ViolationPpageFileStatistic />
|
<ViolationPpageFileStatistic />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ViolationPageViolationsList
|
<FilePageViolationsList
|
||||||
fileViolations={fileViolations}
|
fileViolations={fileViolations}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
fileId={id}
|
fileId={id}
|
||||||
/>
|
/>
|
||||||
<ViolationPageNote />
|
<FilePageNote />
|
||||||
{/* <ViolationPageViolationInfo /> */}
|
{/* <FilePageViolationInfo /> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -14,9 +14,9 @@ export default function Page() {
|
|||||||
description="monitoring-copyright-infringements-description"
|
description="monitoring-copyright-infringements-description"
|
||||||
/>
|
/>
|
||||||
<ViolationsStatistic />
|
<ViolationsStatistic />
|
||||||
<ViolationsMyCases />
|
|
||||||
<ViolationsCheckAllSection />
|
<ViolationsCheckAllSection />
|
||||||
<ViolationsTable />
|
<ViolationsTable />
|
||||||
|
<ViolationsMyCases />
|
||||||
<div className="analytics-grid">
|
<div className="analytics-grid">
|
||||||
<AnalyticsCardDistribution />
|
<AnalyticsCardDistribution />
|
||||||
<AnalyticsCardGeography />
|
<AnalyticsCardGeography />
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ export async function searchUserFiles(fileId: string) {
|
|||||||
|
|
||||||
export async function searchGlobalFiles(fileId: string, currentPage: number) {
|
export async function searchGlobalFiles(fileId: string, currentPage: number) {
|
||||||
const token = await getSessionData('token');
|
const token = await getSessionData('token');
|
||||||
console.log('searchGlobalFiles');
|
|
||||||
console.log(currentPage);
|
|
||||||
|
|
||||||
//удалить когда поиск будет нормально работать
|
//удалить когда поиск будет нормально работать
|
||||||
/* return {
|
/* return {
|
||||||
@@ -114,13 +112,26 @@ export async function searchGlobalFiles(fileId: string, currentPage: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
let errorMessage: string = 'error';
|
||||||
|
if (error) {
|
||||||
|
const typedError = error as any;
|
||||||
|
switch (typedError.message_desc) {
|
||||||
|
case 'No results found':
|
||||||
|
errorMessage = 'no-similar-files-title'
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errorMessage = 'error'
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
images: [],
|
images: [],
|
||||||
page: 0,
|
page: 0,
|
||||||
pageSize: 0,
|
pageSize: 0,
|
||||||
totalPages: 0,
|
totalPages: 0,
|
||||||
totalResults: 0,
|
totalResults: 0,
|
||||||
error: 'error'
|
error: errorMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export default function DashboardUserViolations() {
|
|||||||
>
|
>
|
||||||
<div className="file-icon violent">
|
<div className="file-icon violent">
|
||||||
<Link
|
<Link
|
||||||
href={`/pages/violations/${file.fileId}`}
|
href={`/pages/file/${file.fileId}`}
|
||||||
className="bg-violet-500 hover:bg-violet-600"
|
className="bg-violet-500 hover:bg-violet-600"
|
||||||
title={t('view')}
|
title={t('view')}
|
||||||
>
|
>
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export default function ViolationPageActions() {
|
export default function FilePageActions() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="block-wrapper"
|
className="block-wrapper"
|
||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { FileDetails } from '@/app/[locale]/pages/violations/[id]/page';
|
import { FileDetails } from '@/app/[locale]/pages/file/[id]/page';
|
||||||
import { convertBytes } from '@/app/lib/convertBytes';
|
import { convertBytes } from '@/app/lib/convertBytes';
|
||||||
import { formatDate } from '@/app/lib/formatDate';
|
import { formatDate } from '@/app/lib/formatDate';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export default function ViolationPageFileInfo({ fileInfo }: { fileInfo: FileDetails }) {
|
export default function FilenPageFileInfo({ fileInfo }: { fileInfo: FileDetails }) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useTranslations } from 'next-intl'
|
import { useTranslations } from 'next-intl'
|
||||||
|
|
||||||
export default function ViolationFileNotFound() {
|
export default function FilePageNotFound() {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export default function ViolationPpageFileStatistic() {
|
export default function FilePpageFileStatistic() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="block-wrapper"
|
className="block-wrapper"
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export default function ViolationPageNote() {
|
export default function FilePageNote() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="violation-page-note block-wrapper"
|
className="violation-page-note block-wrapper"
|
||||||
+2
-2
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { IconEyeDashed } from '@/app/ui/icons/icons';
|
import { IconEyeDashed } from '@/app/ui/icons/icons';
|
||||||
import { FileDetails } from '@/app/[locale]/pages/violations/[id]/page';
|
import { FileDetails } from '@/app/[locale]/pages/file/[id]/page';
|
||||||
|
|
||||||
export default function ViolationPageTitle({ fileInfo }: { fileInfo: FileDetails }) {
|
export default function FilePageTitle({ fileInfo }: { fileInfo: FileDetails }) {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
export default function ViolationPageViolationInfo() {
|
export default function FilePageViolationInfo() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="block-wrapper"
|
className="block-wrapper"
|
||||||
+2
-2
@@ -6,7 +6,7 @@ import Link from 'next/link';
|
|||||||
import { useRouter, usePathname } from 'next/navigation';
|
import { useRouter, usePathname } from 'next/navigation';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { formatDate } from '@/app/lib/formatDate';
|
import { formatDate } from '@/app/lib/formatDate';
|
||||||
import ViolationPageNote from '@/app/ui/violations/file-page/violation-page-note';
|
import ViolationPageNote from '@/app/ui/file-page/file-page-note';
|
||||||
|
|
||||||
interface ViolationFileDetail {
|
interface ViolationFileDetail {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -29,7 +29,7 @@ interface ViolationFile {
|
|||||||
has_previous: boolean
|
has_previous: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ViolationPageViolationsList({
|
export default function FilePageViolationsList({
|
||||||
fileViolations,
|
fileViolations,
|
||||||
currentPage,
|
currentPage,
|
||||||
fileId
|
fileId
|
||||||
@@ -293,7 +293,7 @@ export default function LocalFileCheck() {
|
|||||||
{searchResult}
|
{searchResult}
|
||||||
{fileLink && (
|
{fileLink && (
|
||||||
<Link
|
<Link
|
||||||
href={`/pages/violations/${fileLink}`}
|
href={`/pages/file/${fileLink}`}
|
||||||
className="local-file-check-link"
|
className="local-file-check-link"
|
||||||
>
|
>
|
||||||
{t('read-more')}
|
{t('read-more')}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { convertBytes } from '@/app/lib/convertBytes';
|
import { convertBytes } from '@/app/lib/convertBytes';
|
||||||
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import { FileDetails } from '@/app/[locale]/pages/violations/[id]/page';
|
import { FileDetails } from '@/app/[locale]/pages/file/[id]/page';
|
||||||
|
|
||||||
export function FileInfoModalWindow({ fileInfo, setWindowClose, setWindowChildren }: {
|
export function FileInfoModalWindow({ fileInfo, setWindowClose, setWindowChildren }: {
|
||||||
fileInfo: FileDetails,
|
fileInfo: FileDetails,
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ export default function PaymentTabTariffs() {
|
|||||||
setIsProcessing(false);
|
setIsProcessing(false);
|
||||||
setErrorMessage(null);
|
setErrorMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function PaymentConfirmationModal() {
|
function PaymentConfirmationModal() {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ export function FileSearchPanel(
|
|||||||
if (result.error) {
|
if (result.error) {
|
||||||
throw result.error;
|
throw result.error;
|
||||||
}
|
}
|
||||||
if (result.images.length) {
|
if (result.totalResults) {
|
||||||
setSearchedGlobalFiles(result.images);
|
setSearchedGlobalFiles(result.images);
|
||||||
setSearchTotalPages(result.totalPages);
|
setSearchTotalPages(result.totalPages);
|
||||||
setSearchCurrentPages(page);
|
setSearchCurrentPages(page);
|
||||||
@@ -133,7 +133,11 @@ export function FileSearchPanel(
|
|||||||
setSearchedGlobalFilesShowNull(true);
|
setSearchedGlobalFilesShowNull(true);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setGlobalSearchErrorMessage('error');
|
if (error) {
|
||||||
|
setGlobalSearchErrorMessage(error as string);
|
||||||
|
} else {
|
||||||
|
setGlobalSearchErrorMessage('error');
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await queryClient.invalidateQueries({ queryKey: ['userData'] });
|
await queryClient.invalidateQueries({ queryKey: ['userData'] });
|
||||||
await queryClient.invalidateQueries({ queryKey: ['userSearchData'] });
|
await queryClient.invalidateQueries({ queryKey: ['userSearchData'] });
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ export default function ViolationsTable() {
|
|||||||
<IconEye />
|
<IconEye />
|
||||||
</button> */}
|
</button> */}
|
||||||
<Link
|
<Link
|
||||||
href={`/pages/violations/${row.original.fileId}`}
|
href={`/pages/file/${row.original.fileId}`}
|
||||||
className="bg-violet-500 hover:bg-violet-600"
|
className="bg-violet-500 hover:bg-violet-600"
|
||||||
title={t('view')}
|
title={t('view')}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user