import Link from 'next/link';
import { t } from '@/i18n';
import { adminApi, adminErrorMessage } from '@/lib/admin-api';
import { grouped } from '@/lib/format';
import { routes } from '@/lib/site';
import { AdminSection, AdminTable, Pill, statusTone, ts } from '@/components/admin/admin-ui';
export const dynamic = 'force-dynamic';
export default async function AdminRunsPage({ searchParams }: { searchParams: Promise<{ connector?: string; status?: string }> }) {
const sp = await searchParams;
try {
const r = await adminApi.runs({ connector: sp.connector, status: sp.status, limit: 300 });
const connectors = Array.from(new Set(r.items.map((x) => x.connector).filter((x): x is string => !!x))).sort();
return (
{t('common.all')}
{connectors.map((c) => (
{c}
))}
}
>
`${x.run_id}-${x.dataset}-${i}`}
columns={[
{ key: 'run', header: t('admin.runs.run'), cell: (x) => (x.run_id ? {x.run_id} : t('admin.na')) },
{ key: 'c', header: t('admin.connectors.connector'), cell: (x) => x.connector },
{ key: 'd', header: t('source.runs.dataset'), cell: (x) => {x.dataset}, className: 'max-w-[22rem]' },
{ key: 's', header: t('source.runs.status'), cell: (x) => {x.status ?? t('admin.na')} },
{ key: 'st', header: t('source.runs.started'), cell: (x) => ts(x.started_at) },
{ key: 'rows', header: t('source.runs.rows'), numeric: true, cell: (x) => (x.rows_valid != null ? grouped(x.rows_valid) : t('admin.na')) },
{ key: 'w', header: t('source.runs.warnings'), numeric: true, cell: (x) => (x.warnings != null ? grouped(x.warnings) : t('admin.na')) },
{ key: 'e', header: t('source.runs.errors'), numeric: true, cell: (x) => (x.errors ? {grouped(x.errors)} : '0') },
{ key: 'm', header: t('admin.issues.message'), cell: (x) => {x.message}, className: 'max-w-[24rem]' },
]}
/>
);
} catch (e) {
return
{adminErrorMessage(e)}
;
}
}