From 6990f78f69ed5e46d69617452ef2b44efe7957f2 Mon Sep 17 00:00:00 2001 From: smanylov Date: Thu, 26 Feb 2026 12:53:27 +0700 Subject: [PATCH] add type interface, fix date formate, add translation for tokens error --- src/app/ui/search/file-search-panel.tsx | 17 +++++++++++++++-- src/app/ui/search/searched-user-files-list.tsx | 15 +++++++++------ src/app/ui/search/supported-formats.tsx | 11 +++++++---- src/i18n/messages/en.json | 3 ++- src/i18n/messages/ru.json | 3 ++- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/app/ui/search/file-search-panel.tsx b/src/app/ui/search/file-search-panel.tsx index 9a2e67e..b10316f 100644 --- a/src/app/ui/search/file-search-panel.tsx +++ b/src/app/ui/search/file-search-panel.tsx @@ -16,8 +16,21 @@ export interface SearchItem { pageUrl: string } +export interface FileInfo { + fileId: string, + fileSize: number, + hammingDistance: number, + originalFileName: string, + ownerId: number, + similarityLevel: string, + status: string, + supportId: number, + uploadDate: string, + url: string +} + export function FileSearchPanel({ fileId, ref, allowedExtensions }: { fileId: string | null, ref: any, allowedExtensions: AllowedExtensions }) { - const [searchedUserFiles, setSearchedUserFiles] = useState([]); + const [searchedUserFiles, setSearchedUserFiles] = useState([]); const [searchedUserFilesShowNull, setSearchedUserFilesShowNull] = useState(false); const [searchedGlobalFiles, setSearchedGlobalFiles] = useState([]); const [searchedGlobalFilesShowNull, setSearchedGlobalFilesShowNull] = useState(false); @@ -53,7 +66,7 @@ export function FileSearchPanel({ fileId, ref, allowedExtensions }: { fileId: st if (result.content.length) { setSearchedUserFiles(result.content); setShowGlobalSearch(true); - handlerSearchGlobalFile(fileId, page) + handlerSearchGlobalFile(fileId, page); } else { setSearchedUserFilesShowNull(true); } diff --git a/src/app/ui/search/searched-user-files-list.tsx b/src/app/ui/search/searched-user-files-list.tsx index c5fe420..d3e3889 100644 --- a/src/app/ui/search/searched-user-files-list.tsx +++ b/src/app/ui/search/searched-user-files-list.tsx @@ -7,8 +7,10 @@ import { IconEye, IconDownload } from '@/app/ui/icons/icons'; import { getFileType } from '@/app/lib/getFileType'; import { AllowedExtensions } from '@/app/ui/search/section-search-file'; import { FileTypeIcon } from '@/app/components/FileTypeIcon'; +import { formatDate } from '@/app/lib/formatDate'; +import { FileInfo } from './file-search-panel'; -export function SearchedUserFilesList({ list, allowedExtensions }: { list: string[], allowedExtensions: AllowedExtensions }) { +export function SearchedUserFilesList({ list, allowedExtensions }: { list: FileInfo[], allowedExtensions: AllowedExtensions }) { const [isFileLoading, setIsFileLoading] = useState(false); const [openWindow, setOpenWindow] = useState(false); const [openWindowChildren, setOpenWindowChildren] = useState(null); @@ -41,7 +43,7 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin } }; - const handlerViewfile = async (e: any, fileType: string) => { + const handlerViewfile = async (e: FileInfo, fileType: string) => { setOpenWindowChildren(() => { return (
Дата загрузки: - {e.uploadDate ? e.uploadDate : '#'} + {e.uploadDate ? formatDate(e.uploadDate) : '#'}
@@ -95,7 +97,7 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin
Статус защиты: - {e.status ? e.status : '#'} + {e.status ? t(e.status) : '#'}
@@ -121,7 +123,8 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin
- {list.map((e: any, index: number) => { + {list.map((e: FileInfo, index: number) => { + console.log(e); const fileType = getFileType(e.originalFileName, allowedExtensions); if (e.similarityLevel !== 'DIFFERENT') { @@ -148,7 +151,7 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin {e.originalFileName}
- Загружен: {e.uploadDate ? e.uploadDate : '#'} • + Загружен: {e.uploadDate ? formatDate(e.uploadDate) : '#'} • Размер: {convertBytes(e.fileSize)}
diff --git a/src/app/ui/search/supported-formats.tsx b/src/app/ui/search/supported-formats.tsx index ce9b7ae..8b14cb8 100644 --- a/src/app/ui/search/supported-formats.tsx +++ b/src/app/ui/search/supported-formats.tsx @@ -1,4 +1,5 @@ import { IconImageFile, IconVideoFile, IconAudioFile, IconDocument } from '@/app/ui/icons/icons'; +import { useTranslations } from 'next-intl'; interface supportedFormats { extensionVideo: string[] @@ -8,6 +9,8 @@ interface supportedFormats { } export function SupportedFormats({ extensionVideo, extensionAudio, extensionImage, extensionDocument }: supportedFormats) { + const t = useTranslations('Global'); + return (
@@ -16,7 +19,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
- Изображения + {t('images')}
{extensionImage.join(', ')} @@ -25,7 +28,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
- Видео + {t('videos')}
{extensionVideo.join(', ')} @@ -34,7 +37,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
- Аудио + {t('audios')}
{extensionAudio.join(', ')} @@ -43,7 +46,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
- Документы + {t('documents')}
{extensionDocument.join(', ')} diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index 6e12cbc..d8bad60 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -275,7 +275,8 @@ "error-save": "Error saving", "method": "Method", "processed": "Processed", - "request-date": "Request date" + "request-date": "Request date", + "user-not-have-tokens-for-protect": "The user does not have any tokens for protection." }, "Login-register-form": { "and": "and", diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index 62ac3af..eeb21e4 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -275,7 +275,8 @@ "error-save": "Ошибка при сохранении", "method": "Способ", "processed": "Обработано", - "request-date": "Дата запроса" + "request-date": "Дата запроса", + "user-not-have-tokens-for-protect": "У пользователя нет токенов для защиты" }, "Login-register-form": { "and": "и",