import { useTranslation } from 'react-i18next' import { Link } from '@tanstack/react-router' import { Badge, Panel } from '@/ui' import { ArrowRightIcon } from '@phosphor-icons/react' import { useDictionaryDependents } from '@/api/queries' import type { OnCloseAction } from '@/api/client' type Props = { dictionaryName: string } const onCloseVariant = (a: OnCloseAction): 'neutral' | 'warning' | 'error' => { if (a === 'CASCADE') return 'error' if (a === 'WARN') return 'warning' return 'neutral' } /** * Schema-level reverse FK card — "На этот словарь ссылаются:". * *

Показывает chip per (sourceDict.field → targetField, count, onClose mode). * Скрывает себя если 0 dependents (не loading и не error) — большинство * справочников не имеют incoming FK, не нужно занимать место. * *

Phase 1 (read-only). Phase 3 добавит preview cascade chain в close * confirmation dialog. */ export const DictionaryDependentsPanel = ({ dictionaryName }: Props) => { const { t } = useTranslation() const { data, isLoading, error } = useDictionaryDependents(dictionaryName) // Hide entirely в loading / error / empty — это "secondary" info card, // не должен конкурировать с records table за внимание. if (isLoading || error) return null if (!data || data.length === 0) return null return (

{t('lineage.usedBy.title')}

{t('lineage.usedBy.count', { count: data.length })}
) }