fix(admin-ui): reviews — резолвить dictionaryId в имя словаря
В таблицах /reviews (Запись + Мои → Запись) колонка «Объект» показывала
UUID-prefix («254a662f…/REFLEXIO-OPTIC») вместо имени словаря, а ссылка
вела на /dictionaries/<uuid> — 404 (route ожидает name, не UUID).
DraftResponse несёт только dictionaryId (UUID); dictionaryName есть только
у schema-drafts. Резолвим через useDictionaries() — кешируется TanStack
Query, дополнительных запросов не делает.
Fallback на UUID-prefix без link'а, когда dict не в выдаче (scope-hide /
удалён) — лучше чем ведущая в 404 ссылка.
Files:
- routes/reviews.tsx — records-tab table (queue, ReviewsPage)
- components/reviews/MyDraftsPanel.tsx — RecordRow ("Мои" tab)
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
TableHeaderCell,
|
||||
TableRow,
|
||||
} from '@/ui'
|
||||
import { useMyDrafts, useMySchemaDrafts } from '@/api/queries'
|
||||
import { useDictionaries, useMyDrafts, useMySchemaDrafts } from '@/api/queries'
|
||||
import { UserCell } from '@/lib/useUserDisplay'
|
||||
import type {
|
||||
DraftOperation,
|
||||
@@ -303,6 +303,14 @@ function RecordRow({
|
||||
onClick: () => void
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
// DraftResponse несёт только dictionaryId (UUID) — резолвим в name через
|
||||
// global dictionaries list (кешируется TanStack Query). Fallback на
|
||||
// UUID-prefix без link'а если dict не в выдаче (scope-hide / deleted).
|
||||
const dictionaries = useDictionaries()
|
||||
const dictName = useMemo(
|
||||
() => dictionaries.data?.find((d) => d.id === draft.dictionaryId)?.name,
|
||||
[dictionaries.data, draft.dictionaryId],
|
||||
)
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell>
|
||||
@@ -311,15 +319,23 @@ function RecordRow({
|
||||
</Badge>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Link
|
||||
to="/dictionaries/$name"
|
||||
params={{ name: draft.dictionaryId }}
|
||||
className="text-mono text-accent hover:underline"
|
||||
>
|
||||
<span className="text-mute">{draft.dictionaryId.slice(0, 8)}…</span>
|
||||
<span className="mx-1 text-mute">/</span>
|
||||
<span>{draft.businessKey}</span>
|
||||
</Link>
|
||||
{dictName ? (
|
||||
<Link
|
||||
to="/dictionaries/$name"
|
||||
params={{ name: dictName }}
|
||||
className="text-mono text-accent hover:underline"
|
||||
>
|
||||
<span>{dictName}</span>
|
||||
<span className="mx-1 text-mute">/</span>
|
||||
<span>{draft.businessKey}</span>
|
||||
</Link>
|
||||
) : (
|
||||
<span className="text-mono" title={draft.dictionaryId}>
|
||||
<span className="text-mute">{draft.dictionaryId.slice(0, 8)}…</span>
|
||||
<span className="mx-1 text-mute">/</span>
|
||||
<span>{draft.businessKey}</span>
|
||||
</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant={operationVariant(draft.operation)}>{draft.operation}</Badge>
|
||||
|
||||
Reference in New Issue
Block a user