Updated flows tree
Deploy Frontend / build-and-deploy (push) Successful in 1m7s Details

This commit is contained in:
romanskijdev 2026-08-04 12:20:27 +03:00
parent 62fe738c8d
commit 19f91269f5
1 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,4 @@
// src/features/hierarchies/hooks/useSystemOptions.ts
import { useQueries } from '@tanstack/react-query'
import { useCategories } from '@/features/categories/hooks/useCategories'
import { useFlowNodesTree, FLOW_NODES_QUERY_KEY } from '@/features/flowNodes/hooks/useFlowNodes'
@ -12,13 +13,25 @@ export interface SystemOption {
function extractSystemOptions(nodes: ApprovalFlowNode[] | null | undefined): SystemOption[] {
if (!nodes) return []
const seen = new Map<string, string>()
for (const n of nodes) {
if (n.is_multi_select && n.multi_select_key === 'systems' && n.multi_select_value) {
if (!seen.has(n.multi_select_value)) {
seen.set(n.multi_select_value, n.label || n.multi_select_value)
// НОВОЕ: Рекурсивная функция для обхода всех уровней вложенности
function traverse(nodeList: ApprovalFlowNode[]) {
for (const n of nodeList) {
if (n.is_multi_select && n.multi_select_key === 'systems' && n.multi_select_value) {
if (!seen.has(n.multi_select_value)) {
// Используем label (например "1С" или "ОКБ"), если он есть
seen.set(n.multi_select_value, n.label || n.multi_select_value)
}
}
// Если есть вложенные узлы — погружаемся в них
if (n.children && n.children.length > 0) {
traverse(n.children)
}
}
}
traverse(nodes)
return Array.from(seen.entries()).map(([value, label]) => ({ value, label }))
}