add type interface, fix date formate, add translation for tokens error
This commit is contained in:
@@ -16,8 +16,21 @@ export interface SearchItem {
|
|||||||
pageUrl: string
|
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 }) {
|
export function FileSearchPanel({ fileId, ref, allowedExtensions }: { fileId: string | null, ref: any, allowedExtensions: AllowedExtensions }) {
|
||||||
const [searchedUserFiles, setSearchedUserFiles] = useState<string[]>([]);
|
const [searchedUserFiles, setSearchedUserFiles] = useState<FileInfo[]>([]);
|
||||||
const [searchedUserFilesShowNull, setSearchedUserFilesShowNull] = useState<boolean>(false);
|
const [searchedUserFilesShowNull, setSearchedUserFilesShowNull] = useState<boolean>(false);
|
||||||
const [searchedGlobalFiles, setSearchedGlobalFiles] = useState<SearchItem[]>([]);
|
const [searchedGlobalFiles, setSearchedGlobalFiles] = useState<SearchItem[]>([]);
|
||||||
const [searchedGlobalFilesShowNull, setSearchedGlobalFilesShowNull] = useState<boolean>(false);
|
const [searchedGlobalFilesShowNull, setSearchedGlobalFilesShowNull] = useState<boolean>(false);
|
||||||
@@ -53,7 +66,7 @@ export function FileSearchPanel({ fileId, ref, allowedExtensions }: { fileId: st
|
|||||||
if (result.content.length) {
|
if (result.content.length) {
|
||||||
setSearchedUserFiles(result.content);
|
setSearchedUserFiles(result.content);
|
||||||
setShowGlobalSearch(true);
|
setShowGlobalSearch(true);
|
||||||
handlerSearchGlobalFile(fileId, page)
|
handlerSearchGlobalFile(fileId, page);
|
||||||
} else {
|
} else {
|
||||||
setSearchedUserFilesShowNull(true);
|
setSearchedUserFilesShowNull(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import { IconEye, IconDownload } from '@/app/ui/icons/icons';
|
|||||||
import { getFileType } from '@/app/lib/getFileType';
|
import { getFileType } from '@/app/lib/getFileType';
|
||||||
import { AllowedExtensions } from '@/app/ui/search/section-search-file';
|
import { AllowedExtensions } from '@/app/ui/search/section-search-file';
|
||||||
import { FileTypeIcon } from '@/app/components/FileTypeIcon';
|
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 [isFileLoading, setIsFileLoading] = useState(false);
|
||||||
const [openWindow, setOpenWindow] = useState<boolean>(false);
|
const [openWindow, setOpenWindow] = useState<boolean>(false);
|
||||||
const [openWindowChildren, setOpenWindowChildren] = useState<ReactNode>(null);
|
const [openWindowChildren, setOpenWindowChildren] = useState<ReactNode>(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(() => {
|
setOpenWindowChildren(() => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -83,7 +85,7 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin
|
|||||||
<div className="info-item">
|
<div className="info-item">
|
||||||
<span className="info-label">Дата загрузки:</span>
|
<span className="info-label">Дата загрузки:</span>
|
||||||
<span className="info-value">
|
<span className="info-value">
|
||||||
{e.uploadDate ? e.uploadDate : '#'}
|
{e.uploadDate ? formatDate(e.uploadDate) : '#'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="info-item">
|
<div className="info-item">
|
||||||
@@ -95,7 +97,7 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin
|
|||||||
<div className="info-item">
|
<div className="info-item">
|
||||||
<span className="info-label">Статус защиты:</span>
|
<span className="info-label">Статус защиты:</span>
|
||||||
<span className="info-value">
|
<span className="info-value">
|
||||||
{e.status ? e.status : '#'}
|
{e.status ? t(e.status) : '#'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -121,7 +123,8 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin
|
|||||||
<div
|
<div
|
||||||
className="results-list"
|
className="results-list"
|
||||||
>
|
>
|
||||||
{list.map((e: any, index: number) => {
|
{list.map((e: FileInfo, index: number) => {
|
||||||
|
console.log(e);
|
||||||
const fileType = getFileType(e.originalFileName, allowedExtensions);
|
const fileType = getFileType(e.originalFileName, allowedExtensions);
|
||||||
|
|
||||||
if (e.similarityLevel !== 'DIFFERENT') {
|
if (e.similarityLevel !== 'DIFFERENT') {
|
||||||
@@ -148,7 +151,7 @@ export function SearchedUserFilesList({ list, allowedExtensions }: { list: strin
|
|||||||
{e.originalFileName}
|
{e.originalFileName}
|
||||||
</div>
|
</div>
|
||||||
<div className="result-details">
|
<div className="result-details">
|
||||||
Загружен: {e.uploadDate ? e.uploadDate : '#'} •
|
Загружен: {e.uploadDate ? formatDate(e.uploadDate) : '#'} •
|
||||||
Размер: {convertBytes(e.fileSize)}
|
Размер: {convertBytes(e.fileSize)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { IconImageFile, IconVideoFile, IconAudioFile, IconDocument } from '@/app/ui/icons/icons';
|
import { IconImageFile, IconVideoFile, IconAudioFile, IconDocument } from '@/app/ui/icons/icons';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
|
||||||
interface supportedFormats {
|
interface supportedFormats {
|
||||||
extensionVideo: string[]
|
extensionVideo: string[]
|
||||||
@@ -8,6 +9,8 @@ interface supportedFormats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function SupportedFormats({ extensionVideo, extensionAudio, extensionImage, extensionDocument }: supportedFormats) {
|
export function SupportedFormats({ extensionVideo, extensionAudio, extensionImage, extensionDocument }: supportedFormats) {
|
||||||
|
const t = useTranslations('Global');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="supported-formats">
|
<div className="supported-formats">
|
||||||
<div className="formats-title">
|
<div className="formats-title">
|
||||||
@@ -16,7 +19,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
|
|||||||
|
|
||||||
<div className="format-group">
|
<div className="format-group">
|
||||||
<div className="format-type image">
|
<div className="format-type image">
|
||||||
<IconImageFile /> Изображения
|
<IconImageFile /> {t('images')}
|
||||||
</div>
|
</div>
|
||||||
<div className="format-list">
|
<div className="format-list">
|
||||||
{extensionImage.join(', ')}
|
{extensionImage.join(', ')}
|
||||||
@@ -25,7 +28,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
|
|||||||
|
|
||||||
<div className="format-group">
|
<div className="format-group">
|
||||||
<div className="format-type video">
|
<div className="format-type video">
|
||||||
<IconVideoFile /> Видео
|
<IconVideoFile /> {t('videos')}
|
||||||
</div>
|
</div>
|
||||||
<div className="format-list">
|
<div className="format-list">
|
||||||
{extensionVideo.join(', ')}
|
{extensionVideo.join(', ')}
|
||||||
@@ -34,7 +37,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
|
|||||||
|
|
||||||
<div className="format-group">
|
<div className="format-group">
|
||||||
<div className="format-type audio">
|
<div className="format-type audio">
|
||||||
<IconAudioFile /> Аудио
|
<IconAudioFile /> {t('audios')}
|
||||||
</div>
|
</div>
|
||||||
<div className="format-list">
|
<div className="format-list">
|
||||||
{extensionAudio.join(', ')}
|
{extensionAudio.join(', ')}
|
||||||
@@ -43,7 +46,7 @@ export function SupportedFormats({ extensionVideo, extensionAudio, extensionImag
|
|||||||
|
|
||||||
<div className="format-group">
|
<div className="format-group">
|
||||||
<div className="format-type document">
|
<div className="format-type document">
|
||||||
<IconDocument /> Документы
|
<IconDocument /> {t('documents')}
|
||||||
</div>
|
</div>
|
||||||
<div className="format-list">
|
<div className="format-list">
|
||||||
{extensionDocument.join(', ')}
|
{extensionDocument.join(', ')}
|
||||||
|
|||||||
@@ -275,7 +275,8 @@
|
|||||||
"error-save": "Error saving",
|
"error-save": "Error saving",
|
||||||
"method": "Method",
|
"method": "Method",
|
||||||
"processed": "Processed",
|
"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": {
|
"Login-register-form": {
|
||||||
"and": "and",
|
"and": "and",
|
||||||
|
|||||||
@@ -275,7 +275,8 @@
|
|||||||
"error-save": "Ошибка при сохранении",
|
"error-save": "Ошибка при сохранении",
|
||||||
"method": "Способ",
|
"method": "Способ",
|
||||||
"processed": "Обработано",
|
"processed": "Обработано",
|
||||||
"request-date": "Дата запроса"
|
"request-date": "Дата запроса",
|
||||||
|
"user-not-have-tokens-for-protect": "У пользователя нет токенов для защиты"
|
||||||
},
|
},
|
||||||
"Login-register-form": {
|
"Login-register-form": {
|
||||||
"and": "и",
|
"and": "и",
|
||||||
|
|||||||
Reference in New Issue
Block a user