fix(dict): name column в records list — pick localized value, не [object Object]

Раньше для записей с x-localized name (КА, антенна, ground_station,
operator) колонка 'name / code' показывала literal '[object Object]'
потому что String({'ru-RU': 'Канопус', 'en-US': 'Kanopus'}) =
toString() стандартный → '[object Object]'.

Решение:
- Новый shared util lib/locales.ts:
  - pickLocalized(value, defaultLocale) — извлекает строку из i18n
    объекта или plain string. Fallback на first non-empty key
    если defaultLocale не найден.
  - recordDisplayName(data, defaultLocale) — name → code → '—' chain.
- Records list использует recordDisplayName с dict.defaultLocale
  (берётся из DictionaryDetail).
- SchemaDrivenForm дедуплицирован — был свой локальный pickLocalized,
  теперь импортирует из util'ы.

Tests: +13 (76 → 89), unit tests на pickLocalized + recordDisplayName
покрывают все edge cases (plain string, localized object, fallback
chain, null/undefined input).
This commit is contained in:
Zimin A.N.
2026-05-06 21:05:50 +03:00
parent 66e89ce707
commit 5e1b39db03
4 changed files with 124 additions and 17 deletions
@@ -30,6 +30,7 @@ import { DictionaryEditorDialog } from '@/components/schema/DictionaryEditorDial
import { RecordHistoryDrawer } from '@/components/record/RecordHistoryDrawer'
import { AoiPickerDialog, type AoiResult } from '@/components/geo/AoiPickerDialog'
import { nowIsoLocal } from '@/lib/dates'
import { recordDisplayName } from '@/lib/locales'
import { SCOPE_BORDER_TOP, SCOPE_DOT, SCOPE_ORDER } from '@/lib/scope-style'
/**
@@ -380,7 +381,10 @@ function DictionaryDetail() {
<span className="font-mono text-2xs">{r.businessKey}</span>
</TableCell>
<TableCell>
{String(r.data.name ?? r.data.code ?? '—')}
{recordDisplayName(
r.data,
detailQuery.data?.defaultLocale ?? 'ru-RU',
)}
</TableCell>
<TableCell>
<Badge variant="info">{r.dataScope}</Badge>