import { useState } from 'react'
import { createFileRoute } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import {
Badge,
Button,
EmptyState,
LoadingBlock,
PageHeader,
QueryErrorState,
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 (
}
onClick={() => {
stats.refetch()
dlq.refetch()
}}
>
{t('audit.filter.apply')}
}
/>
0 ? 'error' : 'success'}
/>
{dlq.error ? (
dlq.refetch()} />
) : dlq.isLoading ? (
) : !dlq.data || dlq.data.content.length === 0 ? (
) : (
<>
{t('outbox.dlq.col.id')}
{t('outbox.dlq.col.eventType')}
{t('outbox.dlq.col.dictionary')}
{t('outbox.dlq.col.aggregateId')}
{t('outbox.dlq.col.topic')}
{t('outbox.dlq.col.attempts')}
{t('outbox.dlq.col.lastError')}
{t('outbox.dlq.col.dlqAt')}
{dlq.data.content.map((row) => (
{row.id}
{row.eventType}
{row.dictionaryName ?? '—'}
{row.aggregateId}
{row.kafkaTopic}
{row.attemptCount}
{row.lastError ?? '—'}
{new Date(row.dlqAt).toLocaleString()}
))}
{t('audit.page.of', {
cur: (dlq.data.number ?? 0) + 1,
total: Math.max(dlq.data.totalPages ?? 1, 1),
})}
>
)}
)
}
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 (
)
}