From 212899bc2b6db8c1b1ad20f068e63f54e17d03ca Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Mon, 27 Jul 2026 06:41:33 +0300 Subject: [PATCH] Enhance collection and group suggestions to manage existing items visibility Updated the CollectionSuggestions and GroupSuggestions components to include a toggle for displaying already created suggestions. Introduced new state management for handling visibility of existing items, along with localization updates for relevant UI strings in both English and Russian. This improves user experience by allowing admins to see both new and existing suggestions clearly. --- .../collections/CollectionSuggestions.tsx | 34 ++++++++++++++-- .../admin/groups/GroupSuggestions.tsx | 39 ++++++++++++++++--- frontend/src/shared/lib/locales/en.ts | 6 +++ frontend/src/shared/lib/locales/ru.ts | 6 +++ 4 files changed, 76 insertions(+), 9 deletions(-) diff --git a/frontend/src/features/admin/collections/CollectionSuggestions.tsx b/frontend/src/features/admin/collections/CollectionSuggestions.tsx index 8dd917b..a5d60f8 100644 --- a/frontend/src/features/admin/collections/CollectionSuggestions.tsx +++ b/frontend/src/features/admin/collections/CollectionSuggestions.tsx @@ -13,12 +13,16 @@ import { createCollectionFromSuggestion, suggestCollections } from './api' /** * Что стоит собрать во франшизу. Состав виден целиком до создания — по названиям иногда * промахивается, и проверить глазами должно быть проще, чем разбирать потом. + * + * Уже созданное по умолчанию скрыто: строка без кнопки — шум. Счётчик скрытого остаётся видимым, + * чтобы предложение не выглядело пропавшим бесследно. */ export function CollectionSuggestions() { const { t } = useTranslation() const queryClient = useQueryClient() const onError = useApiError() const [collapsed, setCollapsed] = useState(false) + const [showExisting, setShowExisting] = useState(false) const { data, isLoading } = useQuery({ queryKey: qk.collections.suggestions, @@ -38,6 +42,10 @@ export function CollectionSuggestions() { if (isLoading || !data || data.length === 0) return null + const fresh = data.filter((s) => !s.alreadyExists) + const existing = data.length - fresh.length + const visible = showExisting ? data : fresh + return (
{!collapsed && ( <>

{t('admin.collections.suggestions.hint')}

-
diff --git a/frontend/src/features/admin/groups/GroupSuggestions.tsx b/frontend/src/features/admin/groups/GroupSuggestions.tsx index 2e77856..e28d119 100644 --- a/frontend/src/features/admin/groups/GroupSuggestions.tsx +++ b/frontend/src/features/admin/groups/GroupSuggestions.tsx @@ -13,15 +13,18 @@ import { DurationLabel } from './DurationLabel' /** * Что имеет смысл завести группой при нынешней библиотеке. Разбор делает сервер (жанры, типы, - * рейтинги, крупные сериалы), здесь — только показ и кнопка. Уже созданное остаётся в списке - * помеченным: исчезнувшее без следа предложение читается как сбой, а «уже есть» объясняет, - * почему кнопки нет. + * рейтинги, крупные сериалы), здесь — только показ и кнопка. + * + * Уже созданное по умолчанию скрыто: строка без кнопки — это шум, а список должен состоять из того, + * что можно сделать. Но и пропадать бесследно оно не должно, иначе непонятно, куда делось + * предложение, — поэтому счётчик скрытого виден и раскрывается. */ export function GroupSuggestions() { const { t } = useTranslation() const queryClient = useQueryClient() const onError = useApiError() const [collapsed, setCollapsed] = useState(false) + const [showExisting, setShowExisting] = useState(false) const { data, isLoading } = useQuery({ queryKey: qk.groups.suggestions, @@ -40,6 +43,10 @@ export function GroupSuggestions() { // Пока предлагать нечего (пустая библиотека или всё уже создано) — секции нет вовсе. if (isLoading || !data || data.length === 0) return null + const fresh = data.filter((s) => !s.alreadyExists) + const existing = data.length - fresh.length + const visible = showExisting ? data : fresh + return (
@@ -51,15 +58,24 @@ export function GroupSuggestions() { {collapsed ? : } {t('admin.groups.suggestions.title')} - {data.filter((s) => !s.alreadyExists).length} + {fresh.length}
{!collapsed && ( <>

{t('admin.groups.suggestions.hint')}

-
diff --git a/frontend/src/shared/lib/locales/en.ts b/frontend/src/shared/lib/locales/en.ts index 954de95..ce99860 100644 --- a/frontend/src/shared/lib/locales/en.ts +++ b/frontend/src/shared/lib/locales/en.ts @@ -126,6 +126,9 @@ export const en = { stats: '{{shows}} shows · {{units}} units', exists: 'already exists', created: 'Group created', + allCreated: 'Every suggestion has been created already.', + showExisting: 'Show already created ({{count}})', + hideExisting: 'Hide already created', kinds: { Genre: 'genre', ShowKind: 'kind', @@ -172,6 +175,9 @@ export const en = { parts: '{{count}} parts', exists: 'already exists', created: 'Collection created', + allCreated: 'Every suggestion has been created already.', + showExisting: 'Show already created ({{count}})', + hideExisting: 'Hide already created', sources: { Metadata: 'from metadata', NameGuess: 'by names' }, }, }, diff --git a/frontend/src/shared/lib/locales/ru.ts b/frontend/src/shared/lib/locales/ru.ts index 87a7aae..82254e3 100644 --- a/frontend/src/shared/lib/locales/ru.ts +++ b/frontend/src/shared/lib/locales/ru.ts @@ -126,6 +126,9 @@ export const ru = { stats: '{{shows}} шоу · {{units}} ед.', exists: 'уже есть', created: 'Группа создана', + allCreated: 'Все предложения уже созданы.', + showExisting: 'Показать уже созданные ({{count}})', + hideExisting: 'Скрыть уже созданные', kinds: { Genre: 'жанр', ShowKind: 'тип', @@ -172,6 +175,9 @@ export const ru = { parts: '{{count}} частей', exists: 'уже есть', created: 'Коллекция создана', + allCreated: 'Все предложения уже созданы.', + showExisting: 'Показать уже созданные ({{count}})', + hideExisting: 'Скрыть уже созданные', sources: { Metadata: 'из метаданных', NameGuess: 'по названиям' }, }, },