diff --git a/src/pages/topicExecutors/TopicExecutorsPage.tsx b/src/pages/topicExecutors/TopicExecutorsPage.tsx index 59c5e1e..5faed8d 100644 --- a/src/pages/topicExecutors/TopicExecutorsPage.tsx +++ b/src/pages/topicExecutors/TopicExecutorsPage.tsx @@ -21,8 +21,6 @@ import { IconPencil, IconTrash, IconPlus, - IconList, - IconUsers, IconInfoCircle, IconFile, IconCheck, @@ -35,6 +33,7 @@ import { } from '@/features/topicExecutors/hooks/useTopicExecutors' import { useUsers } from '@/features/users/hooks/useUsers' import { useTopics } from '@/features/topics/hooks/useTopics' +import { useCategories } from '@/features/categories/hooks/useCategories' import { groupExecutorsByTopic, TARGET_SYSTEMS, @@ -50,14 +49,30 @@ type ViewMode = 'cards' | 'table' export default function TopicExecutorsPage() { const [viewMode, setViewMode] = useState('cards') + + // ✅ Фильтры - адаптированы под дизайн Hierarchies const [topicFilter, setTopicFilter] = useState(null) + const [categoryFilter, setCategoryFilter] = useState(null) + const [userFilter, setUserFilter] = useState(null) const [targetSystemFilter, setTargetSystemFilter] = useState(null) + const [editExecutor, setEditExecutor] = useState(null) const [createModalOpened, setCreateModalOpened] = useState(false) const [presetGroup, setPresetGroup] = useState(null) + // ✅ Получаем категории + const { data: categories } = useCategories({ limit: 1000 }) + + // ✅ Получаем темы с учетом фильтра по категории + const { data: categoryTopics } = useTopics({ + limit: 1000, + ...(categoryFilter && { category_id: Number(categoryFilter) }), + }) + const { data, isLoading, isFetching } = useTopicExecutors({ ...(topicFilter && { topic_id: Number(topicFilter) }), + ...(userFilter && { user_id: Number(userFilter) }), + ...(categoryFilter && { category_id: Number(categoryFilter) }), ...(targetSystemFilter && { target_system: targetSystemFilter }), }) @@ -72,7 +87,18 @@ export default function TopicExecutorsPage() { return groupExecutorsByTopic(data.data) }, [data]) - const topicOptions = topics?.data?.map((t) => ({ + // ✅ Опции для фильтров + const userOptions = users?.data?.map((u) => ({ + value: String(u.id), + label: u.full_name || `Пользователь #${u.id}`, + })) || [] + + const categoryOptions = categories?.data?.map((c) => ({ + value: String(c.id), + label: c.name || '', + })) || [] + + const topicOptions = (categoryFilter ? categoryTopics?.data : topics?.data)?.map((t) => ({ value: String(t.id), label: t.name || '', })) || [] @@ -82,6 +108,16 @@ export default function TopicExecutorsPage() { label: s.label, })) + // ✅ Обработчик изменения фильтров - сбрасывает страницу и выделение + const handleFilterChange = + (setter: (value: string | null) => void) => (value: string | null) => { + setter(value) + // Если меняется категория, сбрасываем тему + if (setter === setCategoryFilter) { + setTopicFilter(null) + } + } + const handleDelete = (id: number) => { modals.openConfirmModal({ title: 'Подтвердите удаление', @@ -117,16 +153,19 @@ export default function TopicExecutorsPage() { return ( - {/* Заголовок */} + {/* Заголовок - адаптирован под дизайн Hierarchies */} Исполнители тем + + Всего: {data?.data?.length || 0} + setViewMode(v as ViewMode)} data={[ { value: 'cards', label: 'Карточки' }, - { value: 'table', label: 'Таблица'}, + { value: 'table', label: 'Таблица' }, ]} />