Files
mdm-ordinis/ordinis-admin-ui/src/routes/outbox.tsx
T
Zimin A.N. b94912789f fix(fonts): semantic typography utilities per handoff (7 roles)
Заменяет blanket override из MR !45 на типизированную type scale per
design_handoff_ordinis_mdm/README.md "Scale" section.

Семь semantic @utility в styles.css:
  text-title-xl  22/600   — modal title, section header
  text-title-lg  17/600   — page title в editor
  text-title-md  15/600   — dictionary card title
  text-body      13/400   — workhorse: body, buttons, tabs, inputs
  text-cell      12.5/500 — table cell text
  text-mono      11/500   — Mono: IDs, dates, FK refs (font-mono baked in)
  text-cap       10.5/600 — Tektur UPPERCASE caption (font/uppercase baked in)

Audit phases:
  P1: добавил 7 утилит, font/uppercase/tracking baked где надо
  P2: 43 deterministic codemods (font-mono+text-2xs/[11px] → text-mono,
      [15/17/22]px+font-semibold → text-title-*, [12.5]px → text-cell,
      [10.5]px+uppercase+tracking → text-cap)
  P3: 64 text-sm → text-body (handoff workhorse), 84 text-2xs context-aware
      (TableCell → text-cell, bare → text-cell, плюс cleanup caps в backticks
      template literals который Phase 2 пропустил), 25 text-xs (6 → text-mono
      когда с font-mono, 19 → text-cell), 8 titles text-base/lg → text-title-*
  P4: убрал --text-2xs override (no users), оставил --text-sm: 13px scoped
      к @nstart/ui passthrough (см. comment в styles.css — убирается в Stage 3.9)

Stats:
  text-body: 69 | text-cell: 99 | text-mono: 50 | text-cap: 42
  text-title-xl: 5 | text-title-lg: 5 | text-title-md: 7
  text-sm/text-2xs/text-xs в src/: 0 (только в styles.css комментариях)

Поведение всех 277 typography usages теперь явно соответствует handoff —
каждое место осознанно выбрано под роль, не плажирующий override.
2026-05-11 14:31:35 +03:00

175 lines
5.4 KiB
TypeScript

import { useState } from 'react'
import { createFileRoute } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import {
Alert,
Badge,
Button,
EmptyState,
LoadingBlock,
PageHeader,
Table,
TableBody,
TableCell,
TableHead,
TableHeaderCell,
TableRow,
} from '@/ui'
import { ArrowsClockwiseIcon } from '@phosphor-icons/react'
import { useDlq, useOutboxStats } from '@/api/queries'
export const Route = createFileRoute('/outbox')({
component: OutboxPage,
})
function OutboxPage() {
const { t } = useTranslation()
const [page, setPage] = useState(0)
const size = 50
const stats = useOutboxStats()
const dlq = useDlq(page, size)
return (
<div className="space-y-6">
<PageHeader
title={t('outbox.title')}
description={t('outbox.subtitle')}
actions={
<Button
type="button"
variant="secondary"
leftIcon={<ArrowsClockwiseIcon size={16} />}
onClick={() => {
stats.refetch()
dlq.refetch()
}}
>
{t('audit.filter.apply')}
</Button>
}
/>
<div className="grid grid-cols-2 gap-4">
<StatCard
label={t('outbox.stats.pending')}
value={stats.data?.pending ?? '—'}
tone="info"
/>
<StatCard
label={t('outbox.stats.dlq')}
value={stats.data?.dlq ?? '—'}
tone={(stats.data?.dlq ?? 0) > 0 ? 'error' : 'success'}
/>
</div>
{dlq.error ? (
<Alert variant="error" title={t('error.failed')}>
{String(dlq.error)}
</Alert>
) : dlq.isLoading ? (
<LoadingBlock size="md" label={t('loading')} />
) : !dlq.data || dlq.data.content.length === 0 ? (
<EmptyState title={t('outbox.dlq.empty')} />
) : (
<>
<Table>
<TableHead>
<TableRow>
<TableHeaderCell>{t('outbox.dlq.col.id')}</TableHeaderCell>
<TableHeaderCell>{t('outbox.dlq.col.eventType')}</TableHeaderCell>
<TableHeaderCell>{t('outbox.dlq.col.dictionary')}</TableHeaderCell>
<TableHeaderCell>{t('outbox.dlq.col.aggregateId')}</TableHeaderCell>
<TableHeaderCell>{t('outbox.dlq.col.topic')}</TableHeaderCell>
<TableHeaderCell>{t('outbox.dlq.col.attempts')}</TableHeaderCell>
<TableHeaderCell>{t('outbox.dlq.col.lastError')}</TableHeaderCell>
<TableHeaderCell>{t('outbox.dlq.col.dlqAt')}</TableHeaderCell>
</TableRow>
</TableHead>
<TableBody>
{dlq.data.content.map((row) => (
<TableRow key={row.id}>
<TableCell>
<span className="text-mono">{row.id}</span>
</TableCell>
<TableCell>
<Badge variant="warning">{row.eventType}</Badge>
</TableCell>
<TableCell>{row.dictionaryName ?? '—'}</TableCell>
<TableCell>
<span className="text-mono">{row.aggregateId}</span>
</TableCell>
<TableCell>
<span className="text-mono">{row.kafkaTopic}</span>
</TableCell>
<TableCell>{row.attemptCount}</TableCell>
<TableCell>
<span
className="text-cell text-ink-2 truncate max-w-md inline-block align-middle"
title={row.lastError ?? ''}
>
{row.lastError ?? '—'}
</span>
</TableCell>
<TableCell>
<span className="text-cell tabular-nums">
{new Date(row.dlqAt).toLocaleString()}
</span>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<div className="flex items-center justify-end gap-3 text-body">
<Button
type="button"
variant="secondary"
onClick={() => setPage((p) => Math.max(0, p - 1))}
disabled={page <= 0}
>
{t('audit.page.prev')}
</Button>
<span className="tabular-nums">
{t('audit.page.of', {
cur: (dlq.data.number ?? 0) + 1,
total: Math.max(dlq.data.totalPages ?? 1, 1),
})}
</span>
<Button
type="button"
variant="secondary"
onClick={() => setPage((p) => p + 1)}
disabled={(dlq.data.number ?? 0) + 1 >= (dlq.data.totalPages ?? 1)}
>
{t('audit.page.next')}
</Button>
</div>
</>
)}
</div>
)
}
type StatCardProps = {
label: string
value: number | string
tone: 'info' | 'success' | 'error'
}
function StatCard({ label, value, tone }: StatCardProps) {
const colour =
tone === 'error'
? 'text-mars'
: tone === 'success'
? 'text-grass'
: 'text-accent'
return (
<div className="bg-white border border-line rounded-lg p-4">
<div className="text-cap text-ink-2 mb-1">
{label}
</div>
<div className={`text-2xl font-sans tabular-nums ${colour}`}>{value}</div>
</div>
)
}