From 1b9b843f1abe65daa81588857b1998ec0aebf93f Mon Sep 17 00:00:00 2001 From: smanylov Date: Mon, 23 Feb 2026 13:41:07 +0700 Subject: [PATCH] add research button and translate --- src/app/actions/searchActions.ts | 81 +++++++++++++---------- src/app/styles/pages-styles.scss | 6 +- src/app/ui/search/file-search-panel.tsx | 88 ++++++++++++++----------- src/i18n/messages/en.json | 24 ++++++- src/i18n/messages/ru.json | 24 ++++++- 5 files changed, 145 insertions(+), 78 deletions(-) diff --git a/src/app/actions/searchActions.ts b/src/app/actions/searchActions.ts index ac481d8..696617b 100644 --- a/src/app/actions/searchActions.ts +++ b/src/app/actions/searchActions.ts @@ -34,38 +34,46 @@ export async function searchGlobalFiles(fileId: string, currentPage: number) { console.log(currentPage); //удалить когда поиск будет нормально работать - /* return { - images: [ - { - url: 'string1', - pageTitle: `string1 from page ${currentPage}`, - height: 100, - width: 100, - host: 'string1', - pageUrl: 'string1' - }, - { - url: 'string1', - pageTitle: `string2 from page ${currentPage}`, - height: 100, - width: 100, - host: 'string1', - pageUrl: 'string1' - }, - { - url: 'string1', - pageTitle: `string3 from page ${currentPage}`, - height: 100, - width: 100, - host: 'string1', - pageUrl: 'string1' - } - ], - page: 0, - pageSize: 0, - totalPages: 11, - totalResults: 100, - } */ + /* return { + images: [ + { + url: 'string1', + pageTitle: `string1 from page ${currentPage}`, + height: 100, + width: 100, + host: 'string1', + pageUrl: 'string1' + }, + { + url: 'string1', + pageTitle: `string2 from page ${currentPage}`, + height: 100, + width: 100, + host: 'string1', + pageUrl: 'string1' + }, + { + url: 'string1', + pageTitle: `string3 from page ${currentPage}`, + height: 100, + width: 100, + host: 'string1', + pageUrl: 'string1' + } + ], + page: 0, + pageSize: 0, + totalPages: 11, + totalResults: 100, + } */ + + /* return { + images: [], + page: 0, + pageSize: 0, + totalPages: 0, + totalResults: 0 + } */ try { const response = await fetch(`${API_BASE_URL}/api/v1/data`, { @@ -97,7 +105,14 @@ export async function searchGlobalFiles(fileId: string, currentPage: number) { } } catch (error) { - return error + return { + images: [], + page: 0, + pageSize: 0, + totalPages: 0, + totalResults: 0, + error: 'error' + } } } diff --git a/src/app/styles/pages-styles.scss b/src/app/styles/pages-styles.scss index d8f612d..3d0ae1e 100644 --- a/src/app/styles/pages-styles.scss +++ b/src/app/styles/pages-styles.scss @@ -3255,10 +3255,14 @@ .global-no-result { text-align: center; - padding: 60px 20px; + padding: 30px 20px; background: #f8fafc; border-radius: 16px; margin: 20px 0; + + &-text { + margin-bottom: 40px; + } } .global-error { diff --git a/src/app/ui/search/file-search-panel.tsx b/src/app/ui/search/file-search-panel.tsx index a21defb..3696267 100644 --- a/src/app/ui/search/file-search-panel.tsx +++ b/src/app/ui/search/file-search-panel.tsx @@ -4,6 +4,7 @@ import { useCallback, useState, useImperativeHandle } from 'react'; import { searchUserFiles, searchGlobalFiles } from '@/app/actions/searchActions'; import { useQueryClient } from '@tanstack/react-query'; import { Pagination } from '@/app/components/Pagination'; +import { useTranslations } from 'next-intl'; export interface SearchItem { url: string, @@ -24,6 +25,7 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a const [showGlobalSearch, setShowGlobalSearch] = useState(false); const queryClient = useQueryClient(); const [errorMessage, setErrorMessage] = useState(null); + const t = useTranslations('Global'); const [searchTotalPages, setSearchTotalPages] = useState(0); const [searchCurrentPages, setSearchCurrentPages] = useState(1); @@ -82,7 +84,7 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a setSearchedGlobalFilesShowNull(true); } } catch (error) { - + setErrorMessage('error'); } finally { await queryClient.invalidateQueries({ queryKey: ['userData'] }); await queryClient.invalidateQueries({ queryKey: ['userSearchData'] }); @@ -94,24 +96,22 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a return ( <> -
+
{errorMessage && (
- Ошибка поиска + {t('search-error')}
)}
@@ -121,53 +121,44 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a )} {searchedUserFilesShowNull && ( -
+
-
Результаты поиска
+
{t('search-results-title')}
- Найдено файлов: {searchedUserFiles.length} + {t('files-found', { count: searchedUserFiles.length })}
-
-

Похожих файлов не найдено

-

В вашей библиотеке нет файлов, похожих на загруженный

+
+

{t('no-similar-files-title')}

+

{t('no-similar-files-description')}

- Совет: Убедитесь, что вы загружали этот файл ранее через страницу "Маркировка" + {t('hint-title')} {t('hint-text')}
-
)} {showGlobalSearch && ( -
+
- Глобальный поиск изображений + {t('global-search-title')}
- Найти где ещё используется ваше изображение в интернете + {t('global-search-description')}
- Интернет поиск + {t('global-search-badge')}
-
- Поиск по всему интернету + {t('global-search-info-title')}
- Используем продвинутые технологии обратного поиска по изображению для поиска копий вашего контента - на сайтах, в социальных сетях и других источниках. Поможет обнаружить несанкционированное использование. + {t('global-search-info-text')}
@@ -175,8 +166,8 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
-
Глобальных поисков сегодня
-
0 из 10
+
{t('global-searches-today')}
+
0 {t('out-of')} 10
@@ -192,14 +183,14 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
- Поиск изображений в интернете... + {t('searching-internet')}
- Найдено в интернете + {t('found-on-internet')} {paginationLoading && (
@@ -212,23 +203,40 @@ export function FileSearchPanel({ fileId, ref }: { fileId: string | null, ref: a
- {searchedGlobalFilesShowNull && ( + {(searchedGlobalFilesShowNull && !loading) && (
-

Похожие изображения в интернете не найдены

-

Это может означать, что ваше изображение уникально и не используется на других сайтах.

+

{t('no-similar-global-title')}

+

+ {t('no-similar-global-description')} +

+
)} -
- Ошибка глобального поиска: +
+ {t('global-error-title')}
- +
)} - ) + ); } \ No newline at end of file diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index f5daf05..2200da7 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -242,7 +242,27 @@ "operation-history": "Operation history", "tariff-plans": "Tariff plans", "add-tokens": "Add tokens", - "error-upload-chunk-wav-file-not-have-riff": "Failed to upload file: .wav not have RIFF header." + "error-upload-chunk-wav-file-not-have-riff": "Failed to upload file: .wav not have RIFF header.", + "search-again": "Search again", + "start-search": "Start search", + "search-error": "Search error", + "search-results-title": "Search results", + "files-found": "Files found: {count}", + "no-similar-files-title": "No similar files found", + "no-similar-files-description": "Your library has no files similar to the uploaded one", + "hint-title": "Tip:", + "hint-text": "Make sure you have previously uploaded this file through the \"Marking\" page", + "global-search-title": "Global image search", + "global-search-description": "Find where else your image is used on the internet", + "global-search-badge": "Internet search", + "global-search-info-title": "Search across the entire internet", + "global-search-info-text": "We use advanced reverse image search technologies to find copies of your content on websites, social networks, and other sources. Helps detect unauthorized use.", + "global-searches-today": "Global searches today", + "searching-internet": "Searching for images on the internet...", + "found-on-internet": "Found on the internet", + "no-similar-global-title": "No similar images found on the internet", + "no-similar-global-description": "This may mean your image is unique and not used on other websites.", + "global-error-title": "Global search error:" }, "Login-register-form": { "and": "and", @@ -330,6 +350,6 @@ "inn-placeholder": "Enter 10 digits", "INN": "INN", "fullName-required": "Please fill in the field correctly.", - "fullName-too-short" : "Name must be at least 2 characters long." + "fullName-too-short": "Name must be at least 2 characters long." } } \ No newline at end of file diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index 786a747..90ded61 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -242,7 +242,27 @@ "operation-history": "История операций", "tariff-plans": "Тарифные планы", "add-tokens": "Пополнить токены", - "error-upload-chunk-wav-file-not-have-riff": "Не удалось загрузить файл: .wav не содержит заголовка RIFF." + "error-upload-chunk-wav-file-not-have-riff": "Не удалось загрузить файл: .wav не содержит заголовка RIFF.", + "search-again": "Повторный поиск", + "start-search": "Начать поиск", + "search-error": "Ошибка поиска", + "search-results-title": "Результаты поиска", + "files-found": "Найдено файлов: {count}", + "no-similar-files-title": "Похожих файлов не найдено", + "no-similar-files-description": "В вашей библиотеке нет файлов, похожих на загруженный", + "hint-title": "Совет:", + "hint-text": "Убедитесь, что вы загружали этот файл ранее через страницу \"Маркировка\"", + "global-search-title": "Глобальный поиск изображений", + "global-search-description": "Найти где ещё используется ваше изображение в интернете", + "global-search-badge": "Интернет поиск", + "global-search-info-title": "Поиск по всему интернету", + "global-search-info-text": "Используем продвинутые технологии обратного поиска по изображению для поиска копий вашего контента на сайтах, в социальных сетях и других источниках. Поможет обнаружить несанкционированное использование.", + "global-searches-today": "Глобальных поисков сегодня", + "searching-internet": "Поиск изображений в интернете...", + "found-on-internet": "Найдено в интернете", + "no-similar-global-title": "Похожие изображения в интернете не найдены", + "no-similar-global-description": "Это может означать, что ваше изображение уникально и не используется на других сайтах.", + "global-error-title": "Ошибка глобального поиска:" }, "Login-register-form": { "and": "и", @@ -330,6 +350,6 @@ "inn-placeholder": "Введите 10 цифр", "INN": "ИНН", "fullName-required": "Заполните поле корректно.", - "fullName-too-short" : "Имя должно содержать не менее 2 символов." + "fullName-too-short": "Имя должно содержать не менее 2 символов." } } \ No newline at end of file