From ef5c56f04b9eb73a34eb73c96e76446c419a7dc2 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Tue, 28 Jul 2026 03:33:07 +0300 Subject: [PATCH] Add kind filter to ShowsPanel and update localization strings Introduced a new client-side filter for show types in the ShowsPanel, allowing users to filter shows by their kind. Updated the sorting logic to accommodate this new filter. Additionally, added corresponding localization strings for both English and Russian to support the new filter options. These changes enhance the user experience by providing more granular control over show listings. --- .../src/features/admin/shows/ShowsPanel.tsx | 23 +++++++++++++++++-- frontend/src/shared/lib/locales/en.ts | 1 + frontend/src/shared/lib/locales/ru.ts | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/frontend/src/features/admin/shows/ShowsPanel.tsx b/frontend/src/features/admin/shows/ShowsPanel.tsx index 9960d2d..8eaba21 100644 --- a/frontend/src/features/admin/shows/ShowsPanel.tsx +++ b/frontend/src/features/admin/shows/ShowsPanel.tsx @@ -41,6 +41,8 @@ export function ShowsPanel() { // Фильтр по жанру — серверный: в списке видно только основной жанр, а отбирать нужно и по остальным. const [genreFilter, setGenreFilter] = useState('all') + // Фильтр по типу — клиентский: тип уже приехал в списке, и гонять за ним запрос незачем. + const [kindFilter, setKindFilter] = useState<'all' | ShowKind>('all') // Отмеченные для массовых действий. Живут отдельно от фильтров: сузил список — выбор не потерялся. const [selected, setSelected] = useState([]) const { data: genres } = useQuery({ queryKey: qk.genres.all, queryFn: listGenres }) @@ -59,7 +61,8 @@ export function ShowsPanel() { s.name.toLowerCase().includes(q) || (s.originalName ?? '').toLowerCase().includes(q), ) : all - return sortRows(matched, sort, { + const byKind = kindFilter === 'all' ? matched : matched.filter((s) => s.kind === kindFilter) + return sortRows(byKind, sort, { name: (s) => s.name.toLowerCase(), kind: (s) => s.kind, // Без рейтинга — в начало: пустое значение сортируется раньше любого кода. @@ -68,7 +71,7 @@ export function ShowsPanel() { seasons: (s) => s.seasonCount, episodes: (s) => s.episodeCount, }) - }, [data, query, sort]) + }, [data, query, kindFilter, sort]) const totalPages = Math.max(1, Math.ceil(filtered.length / PAGE_SIZE)) const pageItems = filtered.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE) const invalidate = () => queryClient.invalidateQueries({ queryKey: qk.shows.all }) @@ -171,6 +174,22 @@ export function ShowsPanel() { setQuery(e.target.value) }} /> +